-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
60 lines (59 loc) · 2.25 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html>
<head>
<title>Google Spreadsheet Javascript</title>
<script type="text/javascript" src="jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="google-spreadsheet.js"></script>
<style>
body{
background-color: black;
color: green;
font-size: .8em;
font-family: sans-serif;
}
h1,a{ color: yellow}
input{
font-size: .8em;
background-color: black;
color:white;
}
</style>
</head>
<body>
<h1>Google Spreadsheet Javascript</h1>
Here is the most basic usage:
<pre id='code'></pre>
And here are the results:
<pre id='results'></pre>
<div id='links'>
Github URL: <a href='https://github.com/mikeymckay/google-spreadsheet-javascript'>https://github.com/mikeymckay/google-spreadsheet-javascript</a><br/>
Source URL for above spreadsheet data: <span id='spreadsheet_url'></span><br/>
Try your own spreadsheet (needs to be <a href='https://docs.google.com/support/bin/answer.py?hl=en&answer=47134'>published</a>):<br/>
<input style='width:700px' name='url' type='text'></input>
<input onclick='document.location = document.location.pathname + "?url="+$("input[name]").val()' type='submit'></input>
</div>
<iframe width='500' height='300' frameborder='0' ></iframe>
<script>
</script>
<script id='script'>
localStorage.clear();
var sample_url = "https://docs.google.com/spreadsheets/d/11YHCgcqeT2Eqz2B_fpe1ddV6dCssQTI4TH4BcriT11Q/pubhtml?gid=0&single=true";
var url_parameter = document.location.search.split(/\?url=/)[1]
var url = url_parameter || sample_url;
var googleSpreadsheet = new GoogleSpreadsheet();
googleSpreadsheet.url(url);
googleSpreadsheet.load(function(result) {
$('#results').html(JSON.stringify(result).replace(/,/g,",\n"));
});
</script>
<script>
$('#code').html($('#script').html())
$('#spreadsheet_url').html("<a href='"+url+"'>"+url+"</a>");
$('#iframe').attr("src",url);
$('input[name]').val(url);
if (url != sample_url){
$("div#links").append("<br/><a href='"+document.location.pathname+"'>Original Sample Spreadsheet</a>")
}
</script>
</body>
</html>