mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-12-01 02:27:24 +01:00
Merge pull request #368 from marktaiwan/highlight-reply
highlightReply: check for linking to external post
This commit is contained in:
commit
cf090aecea
@ -22,58 +22,58 @@ function fmt(s,a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function until($timestamp) {
|
function until($timestamp) {
|
||||||
var $difference = $timestamp - Date.now()/1000|0, $num;
|
var $difference = $timestamp - Date.now()/1000|0, $num;
|
||||||
switch(true){
|
switch(true){
|
||||||
case ($difference < 60):
|
case ($difference < 60):
|
||||||
return "" + $difference + ' ' + _('second(s)');
|
return "" + $difference + ' ' + _('second(s)');
|
||||||
case ($difference < 3600): //60*60 = 3600
|
case ($difference < 3600): //60*60 = 3600
|
||||||
return "" + ($num = Math.round($difference/(60))) + ' ' + _('minute(s)');
|
return "" + ($num = Math.round($difference/(60))) + ' ' + _('minute(s)');
|
||||||
case ($difference < 86400): //60*60*24 = 86400
|
case ($difference < 86400): //60*60*24 = 86400
|
||||||
return "" + ($num = Math.round($difference/(3600))) + ' ' + _('hour(s)');
|
return "" + ($num = Math.round($difference/(3600))) + ' ' + _('hour(s)');
|
||||||
case ($difference < 604800): //60*60*24*7 = 604800
|
case ($difference < 604800): //60*60*24*7 = 604800
|
||||||
return "" + ($num = Math.round($difference/(86400))) + ' ' + _('day(s)');
|
return "" + ($num = Math.round($difference/(86400))) + ' ' + _('day(s)');
|
||||||
case ($difference < 31536000): //60*60*24*365 = 31536000
|
case ($difference < 31536000): //60*60*24*365 = 31536000
|
||||||
return "" + ($num = Math.round($difference/(604800))) + ' ' + _('week(s)');
|
return "" + ($num = Math.round($difference/(604800))) + ' ' + _('week(s)');
|
||||||
default:
|
default:
|
||||||
return "" + ($num = Math.round($difference/(31536000))) + ' ' + _('year(s)');
|
return "" + ($num = Math.round($difference/(31536000))) + ' ' + _('year(s)');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ago($timestamp) {
|
function ago($timestamp) {
|
||||||
var $difference = (Date.now()/1000|0) - $timestamp, $num;
|
var $difference = (Date.now()/1000|0) - $timestamp, $num;
|
||||||
switch(true){
|
switch(true){
|
||||||
case ($difference < 60) :
|
case ($difference < 60) :
|
||||||
return "" + $difference + ' ' + _('second(s)');
|
return "" + $difference + ' ' + _('second(s)');
|
||||||
case ($difference < 3600): //60*60 = 3600
|
case ($difference < 3600): //60*60 = 3600
|
||||||
return "" + ($num = Math.round($difference/(60))) + ' ' + _('minute(s)');
|
return "" + ($num = Math.round($difference/(60))) + ' ' + _('minute(s)');
|
||||||
case ($difference < 86400): //60*60*24 = 86400
|
case ($difference < 86400): //60*60*24 = 86400
|
||||||
return "" + ($num = Math.round($difference/(3600))) + ' ' + _('hour(s)');
|
return "" + ($num = Math.round($difference/(3600))) + ' ' + _('hour(s)');
|
||||||
case ($difference < 604800): //60*60*24*7 = 604800
|
case ($difference < 604800): //60*60*24*7 = 604800
|
||||||
return "" + ($num = Math.round($difference/(86400))) + ' ' + _('day(s)');
|
return "" + ($num = Math.round($difference/(86400))) + ' ' + _('day(s)');
|
||||||
case ($difference < 31536000): //60*60*24*365 = 31536000
|
case ($difference < 31536000): //60*60*24*365 = 31536000
|
||||||
return "" + ($num = Math.round($difference/(604800))) + ' ' + _('week(s)');
|
return "" + ($num = Math.round($difference/(604800))) + ' ' + _('week(s)');
|
||||||
default:
|
default:
|
||||||
return "" + ($num = Math.round($difference/(31536000))) + ' ' + _('year(s)');
|
return "" + ($num = Math.round($difference/(31536000))) + ' ' + _('year(s)');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var datelocale =
|
var datelocale =
|
||||||
{ days: [_('Sunday'), _('Monday'), _('Tuesday'), _('Wednesday'), _('Thursday'), _('Friday'), _('Saturday')]
|
{ days: [_('Sunday'), _('Monday'), _('Tuesday'), _('Wednesday'), _('Thursday'), _('Friday'), _('Saturday')]
|
||||||
, shortDays: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")]
|
, shortDays: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")]
|
||||||
, months: [_('January'), _('February'), _('March'), _('April'), _('May'), _('June'), _('July'), _('August'), _('September'), _('October'), _('November'), _('December')]
|
, months: [_('January'), _('February'), _('March'), _('April'), _('May'), _('June'), _('July'), _('August'), _('September'), _('October'), _('November'), _('December')]
|
||||||
, shortMonths: [_('Jan'), _('Feb'), _('Mar'), _('Apr'), _('May'), _('Jun'), _('Jul'), _('Aug'), _('Sep'), _('Oct'), _('Nov'), _('Dec')]
|
, shortMonths: [_('Jan'), _('Feb'), _('Mar'), _('Apr'), _('May'), _('Jun'), _('Jul'), _('Aug'), _('Sep'), _('Oct'), _('Nov'), _('Dec')]
|
||||||
, AM: _('AM')
|
, AM: _('AM')
|
||||||
, PM: _('PM')
|
, PM: _('PM')
|
||||||
, am: _('am')
|
, am: _('am')
|
||||||
, pm: _('pm')
|
, pm: _('pm')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function alert(a) {
|
function alert(a) {
|
||||||
var handler, div;
|
var handler, div;
|
||||||
var close = function() {
|
var close = function() {
|
||||||
handler.fadeOut(400, function() { handler.remove(); });
|
handler.fadeOut(400, function() { handler.remove(); });
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
handler = $("<div id='alert_handler'></div>").hide().appendTo('body');
|
handler = $("<div id='alert_handler'></div>").hide().appendTo('body');
|
||||||
@ -254,6 +254,27 @@ function get_cookie(cookie_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function highlightReply(id, event) {
|
function highlightReply(id, event) {
|
||||||
|
// check if external post
|
||||||
|
var post_list, arr, i;
|
||||||
|
|
||||||
|
post_list = document.querySelectorAll('a.post_no');
|
||||||
|
for (i = 0, arr = []; i<post_list.length; i++) {
|
||||||
|
arr.push(post_list[i]);
|
||||||
|
}
|
||||||
|
arr = arr.filter(function (ele) {
|
||||||
|
if (ele.hasAttribute('id') || ((' '+ ele.parentElement.parentElement.className +' ').indexOf(' hidden ') > -1)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for (i = 0, post_list = []; i < arr.length; i++) {
|
||||||
|
post_list.push(arr[i].innerHTML);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (post_list.indexOf(id) == -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
if (typeof window.event != "undefined") {
|
if (typeof window.event != "undefined") {
|
||||||
// don't highlight on middle click
|
// don't highlight on middle click
|
||||||
var e = event || window.event;
|
var e = event || window.event;
|
||||||
|
Loading…
Reference in New Issue
Block a user