$.extend; move isDST into $
This commit is contained in:
parent
fde1813f1b
commit
dda969cac7
104
4chan_x.js
104
4chan_x.js
@ -56,7 +56,7 @@
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var $, $$, DAY, a, arr, as, autoWatch, autohide, b, board, callback, changeCheckbox, changeValue, clearHidden, closeQR, config, cooldown, cutoff, d, delform, down, editSauce, el, expand, expandComment, expandThread, formSubmit, g, getConfig, getThread, getTime, hide, hideReply, hideThread, href, html, i, id, iframe, iframeLoad, imageClick, imageExpand, imageExpandClick, imageHover, imageResize, imageThumb, imageToggle, imageType, imageTypeChange, img, inAfter, inBefore, input, inputs, keyModeInsert, keyModeNormal, keydown, keypress, l1, lastChecked, log, m, mv, n, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, option, options, parseResponse, pathname, qrListener, qrText, quickReply, recaptcha, recaptchaListener, recaptchaReload, redirect, replace, replyNav, report, request, rm, scroll, scrollThread, show, showReply, showThread, slice, span, src, start, stopPropagation, temp, text, textContent, thread, threadF, threads, tn, tzOffset, ui, up, updateAuto, updateCallback, updateFavicon, updateInterval, updateNow, updateTime, updateTitle, updateVerbose, updaterMake, util, watch, watchX, watcher, watcherUpdate, x, zeroPad, _, _base, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _len7, _m, _n, _ref, _ref2, _ref3, _ref4, _ref5;
|
||||
var $, $$, DAY, a, arr, as, autoWatch, autohide, b, board, callback, changeCheckbox, changeValue, clearHidden, closeQR, config, cooldown, cutoff, d, delform, down, editSauce, el, expand, expandComment, expandThread, formSubmit, g, getConfig, getThread, getTime, hide, hideReply, hideThread, href, html, i, id, iframe, iframeLoad, imageClick, imageExpand, imageExpandClick, imageHover, imageResize, imageThumb, imageToggle, imageType, imageTypeChange, img, inAfter, inBefore, input, inputs, keyModeInsert, keyModeNormal, keydown, keypress, l1, lastChecked, log, m, mv, n, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, option, options, parseResponse, pathname, qrListener, qrText, quickReply, recaptcha, recaptchaListener, recaptchaReload, redirect, replace, replyNav, report, request, rm, scroll, scrollThread, show, showReply, showThread, slice, span, src, start, stopPropagation, temp, text, textContent, thread, threadF, threads, tn, tzOffset, ui, up, updateAuto, updateCallback, updateFavicon, updateInterval, updateNow, updateTime, updateTitle, updateVerbose, updaterMake, watch, watchX, watcher, watcherUpdate, x, zeroPad, _, _base, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _len7, _m, _n, _ref, _ref2, _ref3, _ref4, _ref5;
|
||||
var __slice = Array.prototype.slice;
|
||||
if (typeof console != "undefined" && console !== null) {
|
||||
log = console.log;
|
||||
@ -232,6 +232,63 @@
|
||||
}
|
||||
return root.querySelector(selector);
|
||||
};
|
||||
$.extend = function(object, properties) {
|
||||
var key, val;
|
||||
for (key in properties) {
|
||||
val = properties[key];
|
||||
object[key] = val;
|
||||
}
|
||||
return object;
|
||||
};
|
||||
$.extend($, {
|
||||
bind: function(el, eventType, handler) {
|
||||
return el.addEventListener(eventType, handler, true);
|
||||
},
|
||||
unbind: function(el, eventType, handler) {
|
||||
return el.removeEventListener(eventType, handler, true);
|
||||
},
|
||||
isDST: function() {
|
||||
/*
|
||||
http://en.wikipedia.org/wiki/Daylight_saving_time_in_the_United_States
|
||||
Since 2007, daylight saving time starts on the second Sunday of March
|
||||
and ends on the first Sunday of November, with all time changes taking
|
||||
place at 2:00 AM (0200) local time.
|
||||
*/ var date, month, sunday;
|
||||
date = new Date();
|
||||
month = date.getMonth();
|
||||
if (month < 2 || 10 < month) {
|
||||
return false;
|
||||
}
|
||||
if ((2 < month && month < 10)) {
|
||||
return true;
|
||||
}
|
||||
sunday = date.getDate() - date.getDay();
|
||||
if (month === 2) {
|
||||
if (sunday < 8) {
|
||||
return false;
|
||||
}
|
||||
if (sunday < 15 && date.getDay() === 0) {
|
||||
if (date.getHour() < 1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (month === 10) {
|
||||
if (sunday < 1) {
|
||||
return true;
|
||||
}
|
||||
if (sunday < 8 && date.getDay() === 0) {
|
||||
if (date.getHour() < 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
$$ = function(selector, root) {
|
||||
var node, result, _i, _len, _results;
|
||||
if (root == null) {
|
||||
@ -1419,49 +1476,6 @@
|
||||
return favicon.src = g.favEmpty;
|
||||
}
|
||||
};
|
||||
util = {
|
||||
isDST: function() {
|
||||
/*
|
||||
http://en.wikipedia.org/wiki/Daylight_saving_time_in_the_United_States
|
||||
Since 2007, daylight saving time starts on the second Sunday of March
|
||||
and ends on the first Sunday of November, with all time changes taking
|
||||
place at 2:00 AM (0200) local time.
|
||||
*/ var date, month, sunday;
|
||||
date = new Date();
|
||||
month = date.getMonth();
|
||||
if (month < 2 || 10 < month) {
|
||||
return false;
|
||||
}
|
||||
if ((2 < month && month < 10)) {
|
||||
return true;
|
||||
}
|
||||
sunday = date.getDate() - date.getDay();
|
||||
if (month === 2) {
|
||||
if (sunday < 8) {
|
||||
return false;
|
||||
}
|
||||
if (sunday < 15 && date.getDay() === 0) {
|
||||
if (date.getHour() < 1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (month === 10) {
|
||||
if (sunday < 1) {
|
||||
return true;
|
||||
}
|
||||
if (sunday < 8 && date.getDay() === 0) {
|
||||
if (date.getHour() < 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
g = {
|
||||
callbacks: [],
|
||||
expand: false,
|
||||
@ -1487,7 +1501,7 @@
|
||||
g.hiddenReplies = JSON.parse(GM_getValue("hiddenReplies/" + g.BOARD + "/", '[]'));
|
||||
tzOffset = (new Date()).getTimezoneOffset() / 60;
|
||||
g.chanOffset = 5 - tzOffset;
|
||||
if (util.isDST()) {
|
||||
if ($.isDST()) {
|
||||
g.chanOffset -= 1;
|
||||
}
|
||||
if (location.hostname.split('.')[0] === 'sys') {
|
||||
|
||||
112
script.coffee
112
script.coffee
@ -136,6 +136,67 @@ g = null #globals
|
||||
#utility
|
||||
$ = (selector, root=d.body) ->
|
||||
root.querySelector selector
|
||||
|
||||
$.extend = (object, properties) ->
|
||||
for key, val of properties
|
||||
object[key] = val
|
||||
object
|
||||
|
||||
$.extend $,
|
||||
bind: (el, eventType, handler) ->
|
||||
el.addEventListener eventType, handler, true
|
||||
unbind: (el, eventType, handler) ->
|
||||
el.removeEventListener eventType, handler, true
|
||||
isDST: ->
|
||||
# XXX this should be isDSTinNY
|
||||
###
|
||||
http://en.wikipedia.org/wiki/Daylight_saving_time_in_the_United_States
|
||||
Since 2007, daylight saving time starts on the second Sunday of March
|
||||
and ends on the first Sunday of November, with all time changes taking
|
||||
place at 2:00 AM (0200) local time.
|
||||
###
|
||||
|
||||
date = new Date()
|
||||
month = date.getMonth()
|
||||
|
||||
#this is the easy part
|
||||
if month < 2 or 10 < month
|
||||
return false
|
||||
if 2 < month < 10
|
||||
return true
|
||||
|
||||
# (sunday's date) = (today's date) - (number of days past sunday)
|
||||
# date is not zero-indexed
|
||||
sunday = date.getDate() - date.getDay()
|
||||
|
||||
if month is 2
|
||||
#before second sunday
|
||||
if sunday < 8
|
||||
return false
|
||||
|
||||
#during second sunday
|
||||
if sunday < 15 and date.getDay() is 0
|
||||
if date.getHour() < 1
|
||||
return false
|
||||
return true
|
||||
|
||||
#after second sunday
|
||||
return true
|
||||
|
||||
if month is 10
|
||||
# before first sunday
|
||||
if sunday < 1
|
||||
return true
|
||||
|
||||
# during first sunday
|
||||
if sunday < 8 and date.getDay() is 0
|
||||
if date.getHour() < 1
|
||||
return true
|
||||
return false
|
||||
|
||||
#after first sunday
|
||||
return false
|
||||
|
||||
$$ = (selector, root=d.body) ->
|
||||
result = root.querySelectorAll selector
|
||||
node for node in result
|
||||
@ -1051,55 +1112,6 @@ watchX = ->
|
||||
favicon = input.previousSibling
|
||||
favicon.src = g.favEmpty
|
||||
|
||||
util =
|
||||
isDST: ->
|
||||
###
|
||||
http://en.wikipedia.org/wiki/Daylight_saving_time_in_the_United_States
|
||||
Since 2007, daylight saving time starts on the second Sunday of March
|
||||
and ends on the first Sunday of November, with all time changes taking
|
||||
place at 2:00 AM (0200) local time.
|
||||
###
|
||||
|
||||
date = new Date()
|
||||
month = date.getMonth()
|
||||
|
||||
#this is the easy part
|
||||
if month < 2 or 10 < month
|
||||
return false
|
||||
if 2 < month < 10
|
||||
return true
|
||||
|
||||
# (sunday's date) = (today's date) - (number of days past sunday)
|
||||
# date is not zero-indexed
|
||||
sunday = date.getDate() - date.getDay()
|
||||
|
||||
if month is 2
|
||||
#before second sunday
|
||||
if sunday < 8
|
||||
return false
|
||||
|
||||
#during second sunday
|
||||
if sunday < 15 and date.getDay() is 0
|
||||
if date.getHour() < 1
|
||||
return false
|
||||
return true
|
||||
|
||||
#after second sunday
|
||||
return true
|
||||
|
||||
if month is 10
|
||||
# before first sunday
|
||||
if sunday < 1
|
||||
return true
|
||||
|
||||
# during first sunday
|
||||
if sunday < 8 and date.getDay() is 0
|
||||
if date.getHour() < 1
|
||||
return true
|
||||
return false
|
||||
|
||||
#after first sunday
|
||||
return false
|
||||
|
||||
#main
|
||||
g =
|
||||
@ -1131,7 +1143,7 @@ g.hiddenReplies = JSON.parse(GM_getValue("hiddenReplies/#{g.BOARD}/", '[]'))
|
||||
tzOffset = (new Date()).getTimezoneOffset() / 60
|
||||
# GMT -8 is given as +480; would GMT +8 be -480 ?
|
||||
g.chanOffset = 5 - tzOffset# 4chan = EST = GMT -5
|
||||
if util.isDST() then g.chanOffset -= 1
|
||||
if $.isDST() then g.chanOffset -= 1
|
||||
|
||||
if location.hostname.split('.')[0] is 'sys'
|
||||
if recaptcha = $ '#recaptcha_response_field'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user