working sans min_sec
This commit is contained in:
parent
31db0025c1
commit
3b537a83bf
100
4chan_x.user.js
100
4chan_x.user.js
@ -59,7 +59,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var $, $$, Favicon, NAMESPACE, Recaptcha, anonymize, config, cooldown, d, expandComment, expandThread, g, imageHover, imgExpand, imgGif, imgPreloading, keybinds, localize, log, main, nav, nodeInserted, options, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, watcher, _config, _ref;
|
var $, $$, Favicon, NAMESPACE, Recaptcha, anonymize, config, cooldown, d, expandComment, expandThread, g, imageHover, imgExpand, imgGif, imgPreloading, keybinds, log, main, nav, nodeInserted, options, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, sauce, threadHiding, threadStats, threading, time, titlePost, ui, unread, updater, watcher, _config, _ref;
|
||||||
var __slice = Array.prototype.slice;
|
var __slice = Array.prototype.slice;
|
||||||
if (typeof console !== "undefined" && console !== null) {
|
if (typeof console !== "undefined" && console !== null) {
|
||||||
log = function(arg) {
|
log = function(arg) {
|
||||||
@ -315,13 +315,6 @@
|
|||||||
config: function(name) {
|
config: function(name) {
|
||||||
return $.getValue(name, _config[name]);
|
return $.getValue(name, _config[name]);
|
||||||
},
|
},
|
||||||
zeroPad: function(n) {
|
|
||||||
if (n < 10) {
|
|
||||||
return '0' + n;
|
|
||||||
} else {
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
x: function(path, root) {
|
x: function(path, root) {
|
||||||
if (root == null) {
|
if (root == null) {
|
||||||
root = d.body;
|
root = d.body;
|
||||||
@ -1667,19 +1660,30 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
({
|
time = {
|
||||||
time: function() {
|
|
||||||
return {
|
|
||||||
init: function() {
|
|
||||||
return g.callbacks.push(function(root) {});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
localize = {
|
|
||||||
init: function() {
|
init: function() {
|
||||||
|
var code, format;
|
||||||
|
format = '%m/%d/%y(%D)%H:%i';
|
||||||
|
code = format.replace(/%(.)/g, function(s, c) {
|
||||||
|
switch (c) {
|
||||||
|
case '%':
|
||||||
|
return '%';
|
||||||
|
case 'A':
|
||||||
|
case 'D':
|
||||||
|
case 'H':
|
||||||
|
case 'd':
|
||||||
|
case 'i':
|
||||||
|
case 'm':
|
||||||
|
case 'y':
|
||||||
|
return "' + time." + c + "() + '";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
time.funk = Function('time', "return '" + code + "'");
|
||||||
return g.callbacks.push(function(root) {
|
return g.callbacks.push(function(root) {
|
||||||
var date, day, dotw, hour, meridiem, min_sec, month, s, time, year, _, _ref;
|
var day, hour, min_sec, month, s, timeEl, year, _, _ref;
|
||||||
if (root.className === 'inline') {
|
if (root.className === 'inline') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1688,23 +1692,51 @@
|
|||||||
year = "20" + year;
|
year = "20" + year;
|
||||||
month -= 1;
|
month -= 1;
|
||||||
hour = g.chanOffset + Number(hour);
|
hour = g.chanOffset + Number(hour);
|
||||||
date = new Date(year, month, day, hour);
|
time.date = new Date(year, month, day, hour);
|
||||||
year = date.getFullYear() - 2000;
|
timeEl = $.el('time', {
|
||||||
month = $.zeroPad(date.getMonth() + 1);
|
textContent: time.funk(time)
|
||||||
day = $.zeroPad(date.getDate());
|
|
||||||
hour = date.getHours();
|
|
||||||
meridiem = '';
|
|
||||||
if ($.config('Localized am/pm')) {
|
|
||||||
meridiem = hour < 12 ? 'AM' : 'PM';
|
|
||||||
hour = hour % 12 || 12;
|
|
||||||
}
|
|
||||||
hour = $.zeroPad(hour);
|
|
||||||
dotw = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][date.getDay()];
|
|
||||||
time = $.el('time', {
|
|
||||||
textContent: " " + month + "/" + day + "/" + year + "(" + dotw + ")" + hour + ":" + min_sec + meridiem + " "
|
|
||||||
});
|
});
|
||||||
return $.replace(s, time);
|
return $.replace(s, timeEl);
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
zeroPad: function(n) {
|
||||||
|
if (n < 10) {
|
||||||
|
return '0' + n;
|
||||||
|
} else {
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
A: function() {
|
||||||
|
if (this.date.getHours() < 12) {
|
||||||
|
return 'AM';
|
||||||
|
} else {
|
||||||
|
return 'PM';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
D: function() {
|
||||||
|
return ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][this.date.getDay()];
|
||||||
|
},
|
||||||
|
H: function() {
|
||||||
|
return this.zeroPad(this.date.getHours());
|
||||||
|
},
|
||||||
|
a: function() {
|
||||||
|
if (this.date.getHours < 12) {
|
||||||
|
return 'am';
|
||||||
|
} else {
|
||||||
|
return 'pm';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
d: function() {
|
||||||
|
return this.zeroPad(this.date.getDate());
|
||||||
|
},
|
||||||
|
i: function() {
|
||||||
|
return this.zeroPad(this.date.getMinutes());
|
||||||
|
},
|
||||||
|
m: function() {
|
||||||
|
return this.zeroPad(this.date.getMonth() + 1);
|
||||||
|
},
|
||||||
|
y: function() {
|
||||||
|
return this.date.getFullYear() - 2000;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
titlePost = {
|
titlePost = {
|
||||||
|
|||||||
@ -202,8 +202,6 @@ $.extend $,
|
|||||||
style
|
style
|
||||||
config: (name) ->
|
config: (name) ->
|
||||||
$.getValue name, _config[name]
|
$.getValue name, _config[name]
|
||||||
zeroPad: (n) ->
|
|
||||||
if n < 10 then '0' + n else n
|
|
||||||
x: (path, root=d.body) ->
|
x: (path, root=d.body) ->
|
||||||
d.evaluate(path, root, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).
|
d.evaluate(path, root, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).
|
||||||
singleNodeValue
|
singleNodeValue
|
||||||
@ -1313,13 +1311,16 @@ sauce =
|
|||||||
href: prefix + suffix
|
href: prefix + suffix
|
||||||
$.append span, $.tn(' '), link
|
$.append span, $.tn(' '), link
|
||||||
|
|
||||||
time: ->
|
time =
|
||||||
init: ->
|
init: ->
|
||||||
g.callbacks.push (root) ->
|
format = '%m/%d/%y(%D)%H:%i'
|
||||||
return
|
code = format.replace /%(.)/g, (s, c) ->
|
||||||
|
switch c
|
||||||
|
when '%' then '%'
|
||||||
|
when 'A', 'D', 'H', 'd', 'i', 'm', 'y' then "' + time.#{c}() + '"
|
||||||
|
else s
|
||||||
|
time.funk = Function 'time', "return '#{code}'"
|
||||||
|
|
||||||
localize =
|
|
||||||
init: ->
|
|
||||||
g.callbacks.push (root) ->
|
g.callbacks.push (root) ->
|
||||||
return if root.className is 'inline'
|
return if root.className is 'inline'
|
||||||
s = $('span[id^=no]', root).previousSibling
|
s = $('span[id^=no]', root).previousSibling
|
||||||
@ -1328,28 +1329,30 @@ localize =
|
|||||||
year = "20#{year}"
|
year = "20#{year}"
|
||||||
month -= 1 #months start at 0
|
month -= 1 #months start at 0
|
||||||
hour = g.chanOffset + Number hour
|
hour = g.chanOffset + Number hour
|
||||||
date = new Date year, month, day, hour
|
time.date = new Date year, month, day, hour
|
||||||
year = date.getFullYear() - 2000
|
#XXX min_sec unused
|
||||||
month = $.zeroPad date.getMonth() + 1
|
|
||||||
day = $.zeroPad date.getDate()
|
timeEl = $.el 'time',
|
||||||
hour = date.getHours()
|
textContent: time.funk time
|
||||||
meridiem = ''
|
$.replace s, timeEl
|
||||||
if $.config 'Localized am/pm'
|
|
||||||
meridiem = if hour < 12 then 'AM' else 'PM'
|
zeroPad: (n) -> if n < 10 then '0' + n else n
|
||||||
hour = hour % 12 or 12
|
A: -> if @date.getHours() < 12 then 'AM' else 'PM'
|
||||||
hour = $.zeroPad hour
|
D: -> [
|
||||||
dotw = [
|
'Sun'
|
||||||
'Sun'
|
'Mon'
|
||||||
'Mon'
|
'Tue'
|
||||||
'Tue'
|
'Wed'
|
||||||
'Wed'
|
'Thu'
|
||||||
'Thu'
|
'Fri'
|
||||||
'Fri'
|
'Sat'
|
||||||
'Sat'
|
][@date.getDay()]
|
||||||
][date.getDay()]
|
H: -> @zeroPad @date.getHours()
|
||||||
time = $.el 'time',
|
a: -> if @date.getHours < 12 then 'am' else 'pm'
|
||||||
textContent: " #{month}/#{day}/#{year}(#{dotw})#{hour}:#{min_sec}#{meridiem} "
|
d: -> @zeroPad @date.getDate()
|
||||||
$.replace s, time
|
i: -> @zeroPad @date.getMinutes()
|
||||||
|
m: -> @zeroPad @date.getMonth() + 1
|
||||||
|
y: -> @date.getFullYear() - 2000
|
||||||
|
|
||||||
titlePost =
|
titlePost =
|
||||||
init: ->
|
init: ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user