Mercurial > urweb
comparison lib/js/urweb.js @ 1988:abb6981a2c4c
Merge with small clean-ups
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Tue, 18 Feb 2014 07:07:01 -0500 |
parents | b2254554542f |
children | 9356e8f91ea4 |
comparison
equal
deleted
inserted
replaced
1970:6bea98c7f736 | 1988:abb6981a2c4c |
---|---|
215 g: function (d) { return xPad(parseInt(Dt.formats.G(d)%100, 10), 0); }, | 215 g: function (d) { return xPad(parseInt(Dt.formats.G(d)%100, 10), 0); }, |
216 G: function (d) { | 216 G: function (d) { |
217 var y = d.getFullYear(); | 217 var y = d.getFullYear(); |
218 var V = parseInt(Dt.formats.V(d), 10); | 218 var V = parseInt(Dt.formats.V(d), 10); |
219 var W = parseInt(Dt.formats.W(d), 10); | 219 var W = parseInt(Dt.formats.W(d), 10); |
220 | 220 |
221 if(W > V) { | 221 if(W > V) { |
222 y++; | 222 y++; |
223 } else if(W===0 && V>=52) { | 223 } else if(W===0 && V>=52) { |
224 y--; | 224 y--; |
225 } | 225 } |
226 | 226 |
227 return y; | 227 return y; |
228 }, | 228 }, |
229 H: ["getHours", "0"], | 229 H: ["getHours", "0"], |
230 I: function (d) { var I=d.getHours()%12; return xPad(I===0?12:I, 0); }, | 230 I: function (d) { var I=d.getHours()%12; return xPad(I===0?12:I, 0); }, |
231 j: function (d) { | 231 j: function (d) { |
260 } | 260 } |
261 else if(idow === 0) | 261 else if(idow === 0) |
262 { | 262 { |
263 idow = Dt.formats.V(new Date("" + (d.getFullYear()-1) + "/12/31")); | 263 idow = Dt.formats.V(new Date("" + (d.getFullYear()-1) + "/12/31")); |
264 } | 264 } |
265 | 265 |
266 return xPad(idow, 0); | 266 return xPad(idow, 0); |
267 }, | 267 }, |
268 w: "getDay", | 268 w: "getDay", |
269 W: function (d) { | 269 W: function (d) { |
270 var doy = parseInt(Dt.formats.j(d), 10); | 270 var doy = parseInt(Dt.formats.j(d), 10); |
343 function strftime(fmt, thisTime) | 343 function strftime(fmt, thisTime) |
344 { | 344 { |
345 var thisDate = new Date(); | 345 var thisDate = new Date(); |
346 thisDate.setTime(Math.floor(thisTime / 1000)); | 346 thisDate.setTime(Math.floor(thisTime / 1000)); |
347 return Dt.format(thisDate, fmt); | 347 return Dt.format(thisDate, fmt); |
348 }; | 348 }; |
349 | |
350 function fromDatetime(year, month, date, hour, minute, second) { | |
351 return (new Date(year, month, date, hour, minute, second)).getTime() * 1000; | |
352 }; | |
353 | |
354 function datetimeYear(t) { | |
355 return (new Date(t / 1000)).getYear() + 1900; | |
356 }; | |
357 | |
358 function datetimeMonth(t) { | |
359 return (new Date(t / 1000)).getMonth(); | |
360 }; | |
361 | |
362 function datetimeDay(t) { | |
363 return (new Date(t / 1000)).getDate(); | |
364 }; | |
365 | |
366 function datetimeHour(t) { | |
367 return (new Date(t / 1000)).getHours(); | |
368 }; | |
369 | |
370 function datetimeMinute(t) { | |
371 return (new Date(t / 1000)).getMinutes(); | |
372 }; | |
373 | |
374 function datetimeSecond(t) { | |
375 return (new Date(t / 1000)).getSeconds(); | |
376 }; | |
377 | |
378 function datetimeDayOfWeek(t) { | |
379 return (new Date(t / 1000)).getDay(); | |
380 }; | |
349 | 381 |
350 | 382 |
351 // Error handling | 383 // Error handling |
352 | 384 |
353 function uw_debug(msg) { | 385 function uw_debug(msg) { |
715 | 747 |
716 function runScripts(node) { | 748 function runScripts(node) { |
717 if (node.tagName == "SCRIPT") { | 749 if (node.tagName == "SCRIPT") { |
718 var savedScript = thisScript; | 750 var savedScript = thisScript; |
719 thisScript = node; | 751 thisScript = node; |
720 | 752 |
721 try { | 753 try { |
722 eval(thisScript.text); | 754 eval(thisScript.text); |
723 } catch (v) { | 755 } catch (v) { |
724 doExn(v); | 756 doExn(v); |
725 } | 757 } |
1100 var x = document.createElement("script"); | 1132 var x = document.createElement("script"); |
1101 x.dead = false; | 1133 x.dead = false; |
1102 x.signal = s_class; | 1134 x.signal = s_class; |
1103 x.sources = null; | 1135 x.sources = null; |
1104 x.closures = htmlCls; | 1136 x.closures = htmlCls; |
1105 | 1137 |
1106 x.recreate = function(v) { | 1138 x.recreate = function(v) { |
1107 for (var ls = x.closures; ls != htmlCls; ls = ls.next) | 1139 for (var ls = x.closures; ls != htmlCls; ls = ls.next) |
1108 freeClosure(ls.data); | 1140 freeClosure(ls.data); |
1109 | 1141 |
1110 var cls = {v : null}; | 1142 var cls = {v : null}; |
1121 var x = document.createElement("script"); | 1153 var x = document.createElement("script"); |
1122 x.dead = false; | 1154 x.dead = false; |
1123 x.signal = s_style; | 1155 x.signal = s_style; |
1124 x.sources = null; | 1156 x.sources = null; |
1125 x.closures = htmlCls2; | 1157 x.closures = htmlCls2; |
1126 | 1158 |
1127 x.recreate = function(v) { | 1159 x.recreate = function(v) { |
1128 for (var ls = x.closures; ls != htmlCls2; ls = ls.next) | 1160 for (var ls = x.closures; ls != htmlCls2; ls = ls.next) |
1129 freeClosure(ls.data); | 1161 freeClosure(ls.data); |
1130 | 1162 |
1131 var cls = {v : null}; | 1163 var cls = {v : null}; |