enzanki-website-template 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_includes/footer.html +21 -21
- data/_includes/header.html +45 -45
- data/_includes/htmlheader.html +71 -68
- data/_includes/navbarlink.html +24 -24
- data/_includes/youtube-embed.html +4 -4
- data/_includes/ytblock.html +8 -8
- data/_layouts/category.html +33 -27
- data/_layouts/revealjs.html +67 -67
- data/_layouts/youtube-upload.html +11 -11
- data/assets/css/main.css +63 -63
- data/assets/js/live.js +237 -237
- data/assets/js/main.js +132 -132
- data/assets/js/rollbar.js +14 -14
- metadata +3 -3
data/assets/css/main.css
CHANGED
@@ -1,63 +1,63 @@
|
|
1
|
-
body {
|
2
|
-
padding-top: 55px;
|
3
|
-
padding-bottom: 20px;
|
4
|
-
}
|
5
|
-
:target:before, .thumbnail:before {
|
6
|
-
content: "";
|
7
|
-
display: block;
|
8
|
-
height: 55px; /* fixed header height*/
|
9
|
-
margin: -55px 0 0; /* negative fixed header height */
|
10
|
-
}
|
11
|
-
|
12
|
-
.navbar-brand>.avatar {
|
13
|
-
border-radius: 2px;
|
14
|
-
}
|
15
|
-
|
16
|
-
/* Code below is modified from http://stackoverflow.com/a/38118591/6820516 */
|
17
|
-
|
18
|
-
.marquee {
|
19
|
-
width: 100%;
|
20
|
-
left: 0px;
|
21
|
-
position: fixed;
|
22
|
-
margin: 0 auto;
|
23
|
-
white-space: nowrap;
|
24
|
-
overflow: hidden;
|
25
|
-
}
|
26
|
-
.marquee p {
|
27
|
-
display: inline-block;
|
28
|
-
padding-left: 100%;
|
29
|
-
text-indent: 0;
|
30
|
-
animation: marquee linear infinite;
|
31
|
-
}
|
32
|
-
|
33
|
-
@keyframes marquee {
|
34
|
-
0% {
|
35
|
-
transform: translate(0%, 0);
|
36
|
-
}
|
37
|
-
100% {
|
38
|
-
transform: translate(-100%, 0);
|
39
|
-
}
|
40
|
-
}
|
41
|
-
|
42
|
-
/* End modified code.*/
|
43
|
-
|
44
|
-
/* Code below is modified from http://codepen.io/ashblue/pen/mCtuA/ */
|
45
|
-
|
46
|
-
.table-editable {
|
47
|
-
position: relative;
|
48
|
-
}
|
49
|
-
|
50
|
-
.table-remove {
|
51
|
-
color: #700;
|
52
|
-
cursor: pointer;
|
53
|
-
}
|
54
|
-
|
55
|
-
.table-add {
|
56
|
-
color: #070;
|
57
|
-
cursor: pointer;
|
58
|
-
position: absolute;
|
59
|
-
top: 8px;
|
60
|
-
right: 0;
|
61
|
-
}
|
62
|
-
|
63
|
-
/* End modified code. */
|
1
|
+
body {
|
2
|
+
padding-top: 55px;
|
3
|
+
padding-bottom: 20px;
|
4
|
+
}
|
5
|
+
:target:before, .thumbnail:before {
|
6
|
+
content: "";
|
7
|
+
display: block;
|
8
|
+
height: 55px; /* fixed header height*/
|
9
|
+
margin: -55px 0 0; /* negative fixed header height */
|
10
|
+
}
|
11
|
+
|
12
|
+
.navbar-brand>.avatar {
|
13
|
+
border-radius: 2px;
|
14
|
+
}
|
15
|
+
|
16
|
+
/* Code below is modified from http://stackoverflow.com/a/38118591/6820516 */
|
17
|
+
|
18
|
+
.marquee {
|
19
|
+
width: 100%;
|
20
|
+
left: 0px;
|
21
|
+
position: fixed;
|
22
|
+
margin: 0 auto;
|
23
|
+
white-space: nowrap;
|
24
|
+
overflow: hidden;
|
25
|
+
}
|
26
|
+
.marquee p {
|
27
|
+
display: inline-block;
|
28
|
+
padding-left: 100%;
|
29
|
+
text-indent: 0;
|
30
|
+
animation: marquee linear infinite;
|
31
|
+
}
|
32
|
+
|
33
|
+
@keyframes marquee {
|
34
|
+
0% {
|
35
|
+
transform: translate(0%, 0);
|
36
|
+
}
|
37
|
+
100% {
|
38
|
+
transform: translate(-100%, 0);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
/* End modified code.*/
|
43
|
+
|
44
|
+
/* Code below is modified from http://codepen.io/ashblue/pen/mCtuA/ */
|
45
|
+
|
46
|
+
.table-editable {
|
47
|
+
position: relative;
|
48
|
+
}
|
49
|
+
|
50
|
+
.table-remove {
|
51
|
+
color: #700;
|
52
|
+
cursor: pointer;
|
53
|
+
}
|
54
|
+
|
55
|
+
.table-add {
|
56
|
+
color: #070;
|
57
|
+
cursor: pointer;
|
58
|
+
position: absolute;
|
59
|
+
top: 8px;
|
60
|
+
right: 0;
|
61
|
+
}
|
62
|
+
|
63
|
+
/* End modified code. */
|
data/assets/js/live.js
CHANGED
@@ -1,237 +1,237 @@
|
|
1
|
-
---
|
2
|
-
---
|
3
|
-
|
4
|
-
/*
|
5
|
-
Live.js - One script closer to Designing in the Browser
|
6
|
-
Written for Handcraft.com by Martin Kool (@mrtnkl).
|
7
|
-
|
8
|
-
Version 4.
|
9
|
-
Recent change: Made stylesheet and mimetype checks case insensitive.
|
10
|
-
|
11
|
-
http://livejs.com
|
12
|
-
http://livejs.com/license (MIT)
|
13
|
-
@livejs
|
14
|
-
|
15
|
-
Include live.js#css to monitor css changes only.
|
16
|
-
Include live.js#js to monitor js changes only.
|
17
|
-
Include live.js#html to monitor html changes only.
|
18
|
-
Mix and match to monitor a preferred combination such as live.js#html,css
|
19
|
-
|
20
|
-
By default, just include live.js to monitor all css, js and html changes.
|
21
|
-
|
22
|
-
Live.js can also be loaded as a bookmarklet. It is best to only use it for CSS then,
|
23
|
-
as a page reload due to a change in html or css would not re-include the bookmarklet.
|
24
|
-
To monitor CSS and be notified that it has loaded, include it as: live.js#css,notify
|
25
|
-
*/
|
26
|
-
(function () {
|
27
|
-
|
28
|
-
var headers = { "Etag": 1, "Last-Modified": 1, "Content-Length": 1, "Content-Type": 1 },
|
29
|
-
resources = {},
|
30
|
-
pendingRequests = {},
|
31
|
-
currentLinkElements = {},
|
32
|
-
oldLinkElements = {},
|
33
|
-
interval = {{ page.live-reload-time | default: site.live-reload-time | default: 5000 }},
|
34
|
-
loaded = false,
|
35
|
-
active = { "html": 1, "css": 1, "js": 1 };
|
36
|
-
|
37
|
-
var Live = {
|
38
|
-
|
39
|
-
// performs a cycle per interval
|
40
|
-
heartbeat: function () {
|
41
|
-
if (document.body) {
|
42
|
-
// make sure all resources are loaded on first activation
|
43
|
-
if (!loaded) Live.loadresources();
|
44
|
-
Live.checkForChanges();
|
45
|
-
}
|
46
|
-
setTimeout(Live.heartbeat, interval);
|
47
|
-
},
|
48
|
-
|
49
|
-
// loads all local css and js resources upon first activation
|
50
|
-
loadresources: function () {
|
51
|
-
|
52
|
-
// helper method to assert if a given url is local
|
53
|
-
function isLocal(url) {
|
54
|
-
var loc = document.location,
|
55
|
-
reg = new RegExp("^\\.|^\/(?!\/)|^[\\w]((?!://).)*$|" + loc.protocol + "//" + loc.host);
|
56
|
-
return url.match(reg);
|
57
|
-
}
|
58
|
-
|
59
|
-
// gather all resources
|
60
|
-
var scripts = document.getElementsByTagName("script"),
|
61
|
-
links = document.getElementsByTagName("link"),
|
62
|
-
uris = [];
|
63
|
-
|
64
|
-
// track local js urls
|
65
|
-
for (var i = 0; i < scripts.length; i++) {
|
66
|
-
var script = scripts[i], src = script.getAttribute("src");
|
67
|
-
if (src && isLocal(src))
|
68
|
-
uris.push(src);
|
69
|
-
if (src && src.match(/\blive.js#/)) {
|
70
|
-
for (var type in active)
|
71
|
-
active[type] = src.match("[#,|]" + type) != null
|
72
|
-
if (src.match("notify"))
|
73
|
-
alert("Live.js is loaded.");
|
74
|
-
}
|
75
|
-
}
|
76
|
-
if (!active.js) uris = [];
|
77
|
-
if (active.html) uris.push(document.location.href);
|
78
|
-
|
79
|
-
// track local css urls
|
80
|
-
for (var i = 0; i < links.length && active.css; i++) {
|
81
|
-
var link = links[i], rel = link.getAttribute("rel"), href = link.getAttribute("href", 2);
|
82
|
-
if (href && rel && rel.match(new RegExp("stylesheet", "i")) && isLocal(href)) {
|
83
|
-
uris.push(href);
|
84
|
-
currentLinkElements[href] = link;
|
85
|
-
}
|
86
|
-
}
|
87
|
-
|
88
|
-
// initialize the resources info
|
89
|
-
for (var i = 0; i < uris.length; i++) {
|
90
|
-
var url = uris[i];
|
91
|
-
Live.getHead(url, function (url, info) {
|
92
|
-
resources[url] = info;
|
93
|
-
});
|
94
|
-
}
|
95
|
-
|
96
|
-
// add rule for morphing between old and new css files
|
97
|
-
var head = document.getElementsByTagName("head")[0],
|
98
|
-
style = document.createElement("style"),
|
99
|
-
rule = "transition: all .3s ease-out;"
|
100
|
-
css = [".livejs-loading * { ", rule, " -webkit-", rule, "-moz-", rule, "-o-", rule, "}"].join('');
|
101
|
-
style.setAttribute("type", "text/css");
|
102
|
-
head.appendChild(style);
|
103
|
-
style.styleSheet ? style.styleSheet.cssText = css : style.appendChild(document.createTextNode(css));
|
104
|
-
|
105
|
-
// yep
|
106
|
-
loaded = true;
|
107
|
-
},
|
108
|
-
|
109
|
-
// check all tracking resources for changes
|
110
|
-
checkForChanges: function () {
|
111
|
-
for (var url in resources) {
|
112
|
-
if (pendingRequests[url])
|
113
|
-
continue;
|
114
|
-
|
115
|
-
Live.getHead(url, function (url, newInfo) {
|
116
|
-
var oldInfo = resources[url],
|
117
|
-
hasChanged = false;
|
118
|
-
resources[url] = newInfo;
|
119
|
-
for (var header in oldInfo) {
|
120
|
-
// do verification based on the header type
|
121
|
-
var oldValue = oldInfo[header],
|
122
|
-
newValue = newInfo[header],
|
123
|
-
contentType = newInfo["Content-Type"];
|
124
|
-
switch (header.toLowerCase()) {
|
125
|
-
case "etag":
|
126
|
-
if (!newValue) break;
|
127
|
-
// fall through to default
|
128
|
-
default:
|
129
|
-
hasChanged = oldValue != newValue;
|
130
|
-
break;
|
131
|
-
}
|
132
|
-
// if changed, act
|
133
|
-
if (hasChanged) {
|
134
|
-
Live.refreshResource(url, contentType);
|
135
|
-
break;
|
136
|
-
}
|
137
|
-
}
|
138
|
-
});
|
139
|
-
}
|
140
|
-
},
|
141
|
-
|
142
|
-
// act upon a changed url of certain content type
|
143
|
-
refreshResource: function (url, type) {
|
144
|
-
switch (type.toLowerCase()) {
|
145
|
-
// css files can be reloaded dynamically by replacing the link element
|
146
|
-
case "text/css":
|
147
|
-
var link = currentLinkElements[url],
|
148
|
-
html = document.body.parentNode,
|
149
|
-
head = link.parentNode,
|
150
|
-
next = link.nextSibling,
|
151
|
-
newLink = document.createElement("link");
|
152
|
-
|
153
|
-
html.className = html.className.replace(/\s*livejs\-loading/gi, '') + ' livejs-loading';
|
154
|
-
newLink.setAttribute("type", "text/css");
|
155
|
-
newLink.setAttribute("rel", "stylesheet");
|
156
|
-
newLink.setAttribute("href", url + "?now=" + new Date() * 1);
|
157
|
-
next ? head.insertBefore(newLink, next) : head.appendChild(newLink);
|
158
|
-
currentLinkElements[url] = newLink;
|
159
|
-
oldLinkElements[url] = link;
|
160
|
-
|
161
|
-
// schedule removal of the old link
|
162
|
-
Live.removeoldLinkElements();
|
163
|
-
break;
|
164
|
-
|
165
|
-
// check if an html resource is our current url, then reload
|
166
|
-
case "text/html":
|
167
|
-
if (url != document.location.href)
|
168
|
-
return;
|
169
|
-
|
170
|
-
// local javascript changes cause a reload as well
|
171
|
-
case "text/javascript":
|
172
|
-
case "application/javascript":
|
173
|
-
case "application/x-javascript":
|
174
|
-
document.location.reload();
|
175
|
-
}
|
176
|
-
},
|
177
|
-
|
178
|
-
// removes the old stylesheet rules only once the new one has finished loading
|
179
|
-
removeoldLinkElements: function () {
|
180
|
-
var pending = 0;
|
181
|
-
for (var url in oldLinkElements) {
|
182
|
-
// if this sheet has any cssRules, delete the old link
|
183
|
-
try {
|
184
|
-
var link = currentLinkElements[url],
|
185
|
-
oldLink = oldLinkElements[url],
|
186
|
-
html = document.body.parentNode,
|
187
|
-
sheet = link.sheet || link.styleSheet,
|
188
|
-
rules = sheet.rules || sheet.cssRules;
|
189
|
-
if (rules.length >= 0) {
|
190
|
-
oldLink.parentNode.removeChild(oldLink);
|
191
|
-
delete oldLinkElements[url];
|
192
|
-
setTimeout(function () {
|
193
|
-
html.className = html.className.replace(/\s*livejs\-loading/gi, '');
|
194
|
-
}, 100);
|
195
|
-
}
|
196
|
-
} catch (e) {
|
197
|
-
pending++;
|
198
|
-
}
|
199
|
-
if (pending) setTimeout(Live.removeoldLinkElements, 50);
|
200
|
-
}
|
201
|
-
},
|
202
|
-
|
203
|
-
// performs a HEAD request and passes the header info to the given callback
|
204
|
-
getHead: function (url, callback) {
|
205
|
-
pendingRequests[url] = true;
|
206
|
-
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XmlHttp");
|
207
|
-
xhr.open("HEAD", url + "?reloadtime=" + new Date().getTime(), true);
|
208
|
-
xhr.setRequestHeader("Cache-Control", "no-cache");
|
209
|
-
xhr.onreadystatechange = function () {
|
210
|
-
delete pendingRequests[url];
|
211
|
-
if (xhr.readyState == 4 && xhr.status != 304) {
|
212
|
-
xhr.getAllResponseHeaders();
|
213
|
-
var info = {};
|
214
|
-
for (var h in headers) {
|
215
|
-
var value = xhr.getResponseHeader(h);
|
216
|
-
// adjust the simple Etag variant to match on its significant part
|
217
|
-
if (h.toLowerCase() == "etag" && value) value = value.replace(/^W\//, '');
|
218
|
-
if (h.toLowerCase() == "content-type" && value) value = value.replace(/^(.*?);.*?$/i, "$1");
|
219
|
-
info[h] = value;
|
220
|
-
}
|
221
|
-
callback(url, info);
|
222
|
-
}
|
223
|
-
}
|
224
|
-
xhr.send();
|
225
|
-
}
|
226
|
-
};
|
227
|
-
|
228
|
-
// start listening
|
229
|
-
if (document.location.protocol != "file:") {
|
230
|
-
if (!window.liveJsLoaded)
|
231
|
-
Live.heartbeat();
|
232
|
-
|
233
|
-
window.liveJsLoaded = true;
|
234
|
-
}
|
235
|
-
else if (window.console)
|
236
|
-
console.log("Live.js doesn't support the file protocol. It needs http.");
|
237
|
-
})();
|
1
|
+
---
|
2
|
+
---
|
3
|
+
|
4
|
+
/*
|
5
|
+
Live.js - One script closer to Designing in the Browser
|
6
|
+
Written for Handcraft.com by Martin Kool (@mrtnkl).
|
7
|
+
|
8
|
+
Version 4.
|
9
|
+
Recent change: Made stylesheet and mimetype checks case insensitive.
|
10
|
+
|
11
|
+
http://livejs.com
|
12
|
+
http://livejs.com/license (MIT)
|
13
|
+
@livejs
|
14
|
+
|
15
|
+
Include live.js#css to monitor css changes only.
|
16
|
+
Include live.js#js to monitor js changes only.
|
17
|
+
Include live.js#html to monitor html changes only.
|
18
|
+
Mix and match to monitor a preferred combination such as live.js#html,css
|
19
|
+
|
20
|
+
By default, just include live.js to monitor all css, js and html changes.
|
21
|
+
|
22
|
+
Live.js can also be loaded as a bookmarklet. It is best to only use it for CSS then,
|
23
|
+
as a page reload due to a change in html or css would not re-include the bookmarklet.
|
24
|
+
To monitor CSS and be notified that it has loaded, include it as: live.js#css,notify
|
25
|
+
*/
|
26
|
+
(function () {
|
27
|
+
|
28
|
+
var headers = { "Etag": 1, "Last-Modified": 1, "Content-Length": 1, "Content-Type": 1 },
|
29
|
+
resources = {},
|
30
|
+
pendingRequests = {},
|
31
|
+
currentLinkElements = {},
|
32
|
+
oldLinkElements = {},
|
33
|
+
interval = {{ page.live-reload-time | default: site.live-reload-time | default: 5000 }},
|
34
|
+
loaded = false,
|
35
|
+
active = { "html": 1, "css": 1, "js": 1 };
|
36
|
+
|
37
|
+
var Live = {
|
38
|
+
|
39
|
+
// performs a cycle per interval
|
40
|
+
heartbeat: function () {
|
41
|
+
if (document.body) {
|
42
|
+
// make sure all resources are loaded on first activation
|
43
|
+
if (!loaded) Live.loadresources();
|
44
|
+
Live.checkForChanges();
|
45
|
+
}
|
46
|
+
setTimeout(Live.heartbeat, interval);
|
47
|
+
},
|
48
|
+
|
49
|
+
// loads all local css and js resources upon first activation
|
50
|
+
loadresources: function () {
|
51
|
+
|
52
|
+
// helper method to assert if a given url is local
|
53
|
+
function isLocal(url) {
|
54
|
+
var loc = document.location,
|
55
|
+
reg = new RegExp("^\\.|^\/(?!\/)|^[\\w]((?!://).)*$|" + loc.protocol + "//" + loc.host);
|
56
|
+
return url.match(reg);
|
57
|
+
}
|
58
|
+
|
59
|
+
// gather all resources
|
60
|
+
var scripts = document.getElementsByTagName("script"),
|
61
|
+
links = document.getElementsByTagName("link"),
|
62
|
+
uris = [];
|
63
|
+
|
64
|
+
// track local js urls
|
65
|
+
for (var i = 0; i < scripts.length; i++) {
|
66
|
+
var script = scripts[i], src = script.getAttribute("src");
|
67
|
+
if (src && isLocal(src))
|
68
|
+
uris.push(src);
|
69
|
+
if (src && src.match(/\blive.js#/)) {
|
70
|
+
for (var type in active)
|
71
|
+
active[type] = src.match("[#,|]" + type) != null
|
72
|
+
if (src.match("notify"))
|
73
|
+
alert("Live.js is loaded.");
|
74
|
+
}
|
75
|
+
}
|
76
|
+
if (!active.js) uris = [];
|
77
|
+
if (active.html) uris.push(document.location.href);
|
78
|
+
|
79
|
+
// track local css urls
|
80
|
+
for (var i = 0; i < links.length && active.css; i++) {
|
81
|
+
var link = links[i], rel = link.getAttribute("rel"), href = link.getAttribute("href", 2);
|
82
|
+
if (href && rel && rel.match(new RegExp("stylesheet", "i")) && isLocal(href)) {
|
83
|
+
uris.push(href);
|
84
|
+
currentLinkElements[href] = link;
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
// initialize the resources info
|
89
|
+
for (var i = 0; i < uris.length; i++) {
|
90
|
+
var url = uris[i];
|
91
|
+
Live.getHead(url, function (url, info) {
|
92
|
+
resources[url] = info;
|
93
|
+
});
|
94
|
+
}
|
95
|
+
|
96
|
+
// add rule for morphing between old and new css files
|
97
|
+
var head = document.getElementsByTagName("head")[0],
|
98
|
+
style = document.createElement("style"),
|
99
|
+
rule = "transition: all .3s ease-out;"
|
100
|
+
css = [".livejs-loading * { ", rule, " -webkit-", rule, "-moz-", rule, "-o-", rule, "}"].join('');
|
101
|
+
style.setAttribute("type", "text/css");
|
102
|
+
head.appendChild(style);
|
103
|
+
style.styleSheet ? style.styleSheet.cssText = css : style.appendChild(document.createTextNode(css));
|
104
|
+
|
105
|
+
// yep
|
106
|
+
loaded = true;
|
107
|
+
},
|
108
|
+
|
109
|
+
// check all tracking resources for changes
|
110
|
+
checkForChanges: function () {
|
111
|
+
for (var url in resources) {
|
112
|
+
if (pendingRequests[url])
|
113
|
+
continue;
|
114
|
+
|
115
|
+
Live.getHead(url, function (url, newInfo) {
|
116
|
+
var oldInfo = resources[url],
|
117
|
+
hasChanged = false;
|
118
|
+
resources[url] = newInfo;
|
119
|
+
for (var header in oldInfo) {
|
120
|
+
// do verification based on the header type
|
121
|
+
var oldValue = oldInfo[header],
|
122
|
+
newValue = newInfo[header],
|
123
|
+
contentType = newInfo["Content-Type"];
|
124
|
+
switch (header.toLowerCase()) {
|
125
|
+
case "etag":
|
126
|
+
if (!newValue) break;
|
127
|
+
// fall through to default
|
128
|
+
default:
|
129
|
+
hasChanged = oldValue != newValue;
|
130
|
+
break;
|
131
|
+
}
|
132
|
+
// if changed, act
|
133
|
+
if (hasChanged) {
|
134
|
+
Live.refreshResource(url, contentType);
|
135
|
+
break;
|
136
|
+
}
|
137
|
+
}
|
138
|
+
});
|
139
|
+
}
|
140
|
+
},
|
141
|
+
|
142
|
+
// act upon a changed url of certain content type
|
143
|
+
refreshResource: function (url, type) {
|
144
|
+
switch (type.toLowerCase()) {
|
145
|
+
// css files can be reloaded dynamically by replacing the link element
|
146
|
+
case "text/css":
|
147
|
+
var link = currentLinkElements[url],
|
148
|
+
html = document.body.parentNode,
|
149
|
+
head = link.parentNode,
|
150
|
+
next = link.nextSibling,
|
151
|
+
newLink = document.createElement("link");
|
152
|
+
|
153
|
+
html.className = html.className.replace(/\s*livejs\-loading/gi, '') + ' livejs-loading';
|
154
|
+
newLink.setAttribute("type", "text/css");
|
155
|
+
newLink.setAttribute("rel", "stylesheet");
|
156
|
+
newLink.setAttribute("href", url + "?now=" + new Date() * 1);
|
157
|
+
next ? head.insertBefore(newLink, next) : head.appendChild(newLink);
|
158
|
+
currentLinkElements[url] = newLink;
|
159
|
+
oldLinkElements[url] = link;
|
160
|
+
|
161
|
+
// schedule removal of the old link
|
162
|
+
Live.removeoldLinkElements();
|
163
|
+
break;
|
164
|
+
|
165
|
+
// check if an html resource is our current url, then reload
|
166
|
+
case "text/html":
|
167
|
+
if (url != document.location.href)
|
168
|
+
return;
|
169
|
+
|
170
|
+
// local javascript changes cause a reload as well
|
171
|
+
case "text/javascript":
|
172
|
+
case "application/javascript":
|
173
|
+
case "application/x-javascript":
|
174
|
+
document.location.reload();
|
175
|
+
}
|
176
|
+
},
|
177
|
+
|
178
|
+
// removes the old stylesheet rules only once the new one has finished loading
|
179
|
+
removeoldLinkElements: function () {
|
180
|
+
var pending = 0;
|
181
|
+
for (var url in oldLinkElements) {
|
182
|
+
// if this sheet has any cssRules, delete the old link
|
183
|
+
try {
|
184
|
+
var link = currentLinkElements[url],
|
185
|
+
oldLink = oldLinkElements[url],
|
186
|
+
html = document.body.parentNode,
|
187
|
+
sheet = link.sheet || link.styleSheet,
|
188
|
+
rules = sheet.rules || sheet.cssRules;
|
189
|
+
if (rules.length >= 0) {
|
190
|
+
oldLink.parentNode.removeChild(oldLink);
|
191
|
+
delete oldLinkElements[url];
|
192
|
+
setTimeout(function () {
|
193
|
+
html.className = html.className.replace(/\s*livejs\-loading/gi, '');
|
194
|
+
}, 100);
|
195
|
+
}
|
196
|
+
} catch (e) {
|
197
|
+
pending++;
|
198
|
+
}
|
199
|
+
if (pending) setTimeout(Live.removeoldLinkElements, 50);
|
200
|
+
}
|
201
|
+
},
|
202
|
+
|
203
|
+
// performs a HEAD request and passes the header info to the given callback
|
204
|
+
getHead: function (url, callback) {
|
205
|
+
pendingRequests[url] = true;
|
206
|
+
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XmlHttp");
|
207
|
+
xhr.open("HEAD", url + "?reloadtime=" + new Date().getTime(), true);
|
208
|
+
xhr.setRequestHeader("Cache-Control", "no-cache");
|
209
|
+
xhr.onreadystatechange = function () {
|
210
|
+
delete pendingRequests[url];
|
211
|
+
if (xhr.readyState == 4 && xhr.status != 304) {
|
212
|
+
xhr.getAllResponseHeaders();
|
213
|
+
var info = {};
|
214
|
+
for (var h in headers) {
|
215
|
+
var value = xhr.getResponseHeader(h);
|
216
|
+
// adjust the simple Etag variant to match on its significant part
|
217
|
+
if (h.toLowerCase() == "etag" && value) value = value.replace(/^W\//, '');
|
218
|
+
if (h.toLowerCase() == "content-type" && value) value = value.replace(/^(.*?);.*?$/i, "$1");
|
219
|
+
info[h] = value;
|
220
|
+
}
|
221
|
+
callback(url, info);
|
222
|
+
}
|
223
|
+
}
|
224
|
+
xhr.send();
|
225
|
+
}
|
226
|
+
};
|
227
|
+
|
228
|
+
// start listening
|
229
|
+
if (document.location.protocol != "file:") {
|
230
|
+
if (!window.liveJsLoaded)
|
231
|
+
Live.heartbeat();
|
232
|
+
|
233
|
+
window.liveJsLoaded = true;
|
234
|
+
}
|
235
|
+
else if (window.console)
|
236
|
+
console.log("Live.js doesn't support the file protocol. It needs http.");
|
237
|
+
})();
|