-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·194 lines (158 loc) · 6.23 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.6.0/styles/arduino-light.min.css">
</head>
<body>
<div id="loader">
<div id="loader-spinner"></div>
<span id="loader-text"></span>
</div>
<div id="wrapper" class="is-quiet">
<div class="nav">
<div class="container">
<div class="navigation">
<a href="//kyshel.com">Kyshel</a>
/
<a href="about.html">About</a>
</div>
<a id="owner_link" class="user" href="/mbostock">
<img id="avatar" class="avatar" src="https://avatars.githubusercontent.com/u/11898075?v=3" width="30" height="30">
<span id="owner_name">Kyshel</span>
</a>
’s Gist
<a id="link_id" class="gist gist-id self" title="View Gist on GitHub." href="#">#</a>
<div id="update_time" class="date">Updated August 28, 2016</div>
</div>
</div>
<div class="container">
<h1 id="description"></h1>
<div id="raw">
<iframe id="iframe_raw" src="" sandbox="allow-popups allow-scripts allow-forms allow-same-origin" marginwidth="0" marginheight="0" style="border: solid 1px #eee;" scrolling="no"></iframe>
</div>
<div class="index-pop">
<a id="link_pop" target="_blank" title="Open Block 4063269 a new window." href="">Open<svg height="16" width="12"><path d="M11 10h1v3c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V3c0-0.55 0.45-1 1-1h3v1H1v10h10V10zM6 2l2.25 2.25-3.25 3.25 1.5 1.5 3.25-3.25 2.25 2.25V2H6z"></path></svg></a>
</div>
<div id="readme" class="gist-readme">
</div>
<div id="source">
<h2>index.html<a name="index.html" class="anchor" href="#index.html">#</a></h2>
<pre><code id="code" class="" ><h1>this is h1</h1></code></pre>
</div>
<div class="gist-license">
<h2>LICENSE<a name="license" class="anchor" href="#license">#</a></h2>
<div id="license"></div>
</div>
</div>
</div> <!-- wrapper -->
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.6.0/highlight.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/showdown/1.4.3/showdown.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript">
function showLoader($text){
$('#loader-text').html($text);
$('#loader').removeClass('is-quiet');
$('#loader').addClass('is-active');
}
function hideLoader(){
$('#loader').removeClass('is-active');
$('#loader').addClass('is-quiet');
}
function showWrapper(){
$('#wrapper').removeClass('is-quiet');
$('#wrapper').addClass('is-active');
}
function loadgist(gistid) {
showLoader('Loading ...')
$.ajax({
url: 'https://api.github.com/gists/'+gistid,
type: 'GET',
dataType: 'jsonp'
}).success( function(gistdata) {
console.log(gistdata);
renderPage(gistdata);
hideLoader()
showWrapper()
}).error( function(e) {
});
}
function renderPage(gistdata) {
var owner_name=gistdata.data.owner.login,
avatar_url=gistdata.data.owner.avatar_url,
update_time=new Date(gistdata.data.updated_at),
gist_id=gistdata.data.id
description=gistdata.data.description;
var month = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
document.getElementById('owner_link').href="https://github.com/"+owner_name;
document.getElementById('avatar').src=avatar_url;
document.getElementById('owner_name').innerHTML=owner_name;
document.getElementById('link_id').href="https://gist.github.com/"+owner_name+"/"+gist_id;
document.getElementById('link_id').innerHTML=gist_id;
document.getElementById('update_time').innerHTML="Updated "
+month[update_time.getMonth()] + " "
+update_time.getDate() + ", "
+update_time.getFullYear();
document.getElementById('description').innerHTML=(description=='')?gist_id:description;
document.getElementById('link_pop').href="raw/?id="+gistid;
document.getElementById('link_pop').title="Open Gist "+gistid+" a new window";
var files= gistdata.data.files;
for (file in files) {
if (files.hasOwnProperty(file)) {
var filename = files[file].filename;
var filecontent = files[file].content;
if (filename == 'index.html') {
document.getElementById('iframe_raw').src = "raw/?id="+gistid;
document.getElementById('code').innerHTML = escapeHtml(filecontent);
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
}else if(filename == 'readme.md'){
var converter = new showdown.Converter(),
text = filecontent,
html = converter.makeHtml(text);
document.getElementById('readme').innerHTML=html;
}else if(filename == '.json'){
var object_json=JSON.parse(filecontent);
var height=object_json.hasOwnProperty('height')?object_json.height:'700px';
var license=object_json.hasOwnProperty('license')?object_json.license:'This block appears to have <a target="_blank" href="http://choosealicense.com/no-license/">no license</a>. Please contact <a target="_blank" href="https://github.com/'+owner_name+'">the author</a> to request a license.';
document.getElementById('iframe_raw').height=height;
$.getJSON("data.json", function(json) {
lic_lists=json.license;
var show=lic_lists.hasOwnProperty(license)?lic_lists[license]:'Released under the <a target="_blank" href="https://opensource.org/licenses/'+license+'">'+license+' License</a>';
document.getElementById('license').innerHTML=show;
});
}
}
}
}
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
function escapeHtml(text) {
var map = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": '''
};
return text.replace(/[&<>"']/g, function(m) { return map[m]; });
}
var gistid=getParameterByName('id');
if(gistid==null){
window.location.href="about.html"
}
loadgist(gistid);
</script>
</body>
</html>