forked from GithubBackups/vichan
This commit is contained in:
commit
233fb8e0f7
@ -37,7 +37,30 @@ $(document).ready(function(){
|
||||
var countdown_interval;
|
||||
|
||||
// Add an update link
|
||||
$('.boardlist.bottom').prev().after("<span id='updater'><a href='#' id='update_thread' style='padding-left:10px'>["+_("Update")+"]</a> (<input type='checkbox' id='auto_update_status' checked> "+_("Auto")+") <span id='update_secs'></span></span>");
|
||||
$('.boardlist.bottom').prev().after("<span id='updater'><a href='#' id='update_thread' style='padding-left:10px'>["+_("Update")+"]</a> (<input type='checkbox' id='auto_update_status'> "+_("Auto")+") <span id='update_secs'></span></span>");
|
||||
|
||||
// Adds Options panel item
|
||||
if (typeof localStorage.auto_thread_update === 'undefined') {
|
||||
localStorage.auto_thread_update = 'true'; //default value
|
||||
}
|
||||
if (window.Options && Options.get_tab('general')) {
|
||||
Options.extend_tab('general', '<label id="auto-thread-update"><input type="checkbox">' + _('Auto update thread') + '</label>');
|
||||
$('#auto-thread-update>input').on('click', function() {
|
||||
if ($('#auto-thread-update>input').is(':checked')) {
|
||||
localStorage.auto_thread_update = 'true';
|
||||
} else {
|
||||
localStorage.auto_thread_update = 'false';
|
||||
}
|
||||
});
|
||||
if (localStorage.auto_thread_update === 'true') {
|
||||
$('#show-relative-time>input').prop('checked', true);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the updater checkbox according to user setting
|
||||
if (localStorage.auto_thread_update === 'true') {
|
||||
$('#auto_update_status').prop('checked', true);
|
||||
}
|
||||
|
||||
// Grab the settings
|
||||
var settings = new script_settings('auto-reload');
|
||||
@ -51,19 +74,19 @@ $(document).ready(function(){
|
||||
|
||||
var end_of_page = false;
|
||||
|
||||
var new_posts = 0;
|
||||
var new_posts = 0;
|
||||
var first_new_post = null;
|
||||
|
||||
var title = document.title;
|
||||
|
||||
if (typeof update_title == "undefined") {
|
||||
var update_title = function() {
|
||||
if (new_posts) {
|
||||
document.title = "("+new_posts+") "+title;
|
||||
} else {
|
||||
document.title = title;
|
||||
}
|
||||
};
|
||||
var update_title = function() {
|
||||
if (new_posts) {
|
||||
document.title = "("+new_posts+") "+title;
|
||||
} else {
|
||||
document.title = title;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof add_title_collector != "undefined")
|
||||
@ -130,8 +153,8 @@ $(document).ready(function(){
|
||||
clearInterval(countdown_interval);
|
||||
}
|
||||
|
||||
var epoch = (new Date).getTime();
|
||||
var epochold = epoch;
|
||||
var epoch = (new Date).getTime();
|
||||
var epochold = epoch;
|
||||
|
||||
var timeDiff = function (delay) {
|
||||
if((epoch-epochold) > delay) {
|
||||
|
@ -24,7 +24,7 @@ $(document).ready(function(){
|
||||
var thread = $(this).parents('[id^="thread_"]');
|
||||
var id = thread.attr('id').replace(/^thread_/, '');
|
||||
$.ajax({
|
||||
url: thread.find('p.intro a.post_no:first').attr('href'),
|
||||
url: thread.find('div.post:not(.hidden) p.intro a.post_no:first').attr('href'),
|
||||
context: document.body,
|
||||
success: function(data) {
|
||||
var last_expanded = false;
|
||||
|
@ -87,23 +87,22 @@ $(document).ready(function(){
|
||||
hidden_data[board] = {}; // id : timestamp
|
||||
}
|
||||
|
||||
$('<a class="post-hide-link" href="javascript:void(0)" title="Hide Post" style="float: right">[–]</a>')
|
||||
.insertAfter(post.children('p.intro').children('a.post_no:last'))
|
||||
$('<a class="post-hide-link" href="javascript:void(0)" title="Hide Post" style="float: left; margin-right: 5px">[–]</a>')
|
||||
.insertBefore(post.children('p.intro').children('input.delete'))
|
||||
.click(function() {
|
||||
hidden_data[board][id] = Math.round(Date.now() / 1000);
|
||||
store_data();
|
||||
var hide_link = $(this);
|
||||
post.children('div').hide();
|
||||
hide_link.hide();
|
||||
$('<a class="post-show-link" href="javascript:void(0)" title="Show Post" style="float: right">[+]</a>')
|
||||
.insertAfter(post.children('p.intro').children('a.post_no:last'))
|
||||
$('<a class="post-show-link" href="javascript:void(0)" title="Show Post" style="float: left; margin-right: 5px">[+]</a>')
|
||||
.insertBefore(post.children('p.intro').children('input.delete'))
|
||||
.click(function() {
|
||||
delete hidden_data[board][id];
|
||||
store_data();
|
||||
post.children('div').show();
|
||||
hide_link.show();
|
||||
$(this).remove();
|
||||
|
||||
});
|
||||
});
|
||||
if (hidden_data[board][id])
|
||||
|
@ -212,11 +212,17 @@ onready(function(){
|
||||
|
||||
if (this.isImage && !this.isSpoiler) {
|
||||
// video files uses jpg for thumbnail
|
||||
if (this.ext === '.webm' || this.ext === '.mp4') this.ext = '.jpg';
|
||||
if (this.ext === '.webm' || this.ext === '.mp4' || this.ext === '.jpeg') this.ext = '.jpg';
|
||||
thumb_url = '/'+ board +'/thumb/' + this.tim + this.ext;
|
||||
} else {
|
||||
thumb_url = (this.isSpoiler) ? '/static/spoiler.png' : '/static/file.png';
|
||||
}
|
||||
|
||||
// truncate long filenames
|
||||
if (this.filename.length > 23) {
|
||||
this.filename = this.filename.substr(0, 22) + '…';
|
||||
}
|
||||
|
||||
// file infos
|
||||
var $ele = $('<div class="file">')
|
||||
.append($('<p class="fileinfo">')
|
||||
@ -224,7 +230,7 @@ onready(function(){
|
||||
.append('<a>'+ this.filename + file_ext +'</a>')
|
||||
.append('<span class="unimportant"> ('+ bytesToSize(this.fsize) +', '+ this.w +'x'+ this.h +')</span>')
|
||||
);
|
||||
if (multifile) $ele.addClass('multifile').css('max-width', '200px');
|
||||
if (multifile) $ele.addClass('multifile').css('width', this.thumb_w + 30);
|
||||
|
||||
// image
|
||||
var $img = $('<img class="post-image">')
|
||||
|
@ -278,7 +278,13 @@
|
||||
}
|
||||
});
|
||||
|
||||
$postForm.find('textarea[name="body"]').removeAttr('id').removeAttr('cols').attr('placeholder', _('Comment'));
|
||||
$postForm.find('textarea[name="body"]').removeAttr('id').removeAttr('cols').attr('placeholder', _('Comment'))
|
||||
.on('keydown', function (e) {
|
||||
//close quick reply when esc is prssed
|
||||
if (e.which === 27) {
|
||||
$('.close-btn').trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
$postForm.find('textarea:not([name="body"]),input[type="hidden"]:not(.captcha_cookie)').removeAttr('id').appendTo($dummyStuff);
|
||||
|
||||
@ -374,6 +380,7 @@
|
||||
$postForm.show();
|
||||
}
|
||||
|
||||
$postForm.find('textarea[name="body"]').focus();
|
||||
$(window).on('stylesheet', function() {
|
||||
do_css();
|
||||
if ($('link#stylesheet').attr('href')) {
|
||||
|
@ -22,58 +22,58 @@ function fmt(s,a) {
|
||||
}
|
||||
|
||||
function until($timestamp) {
|
||||
var $difference = $timestamp - Date.now()/1000|0, $num;
|
||||
switch(true){
|
||||
case ($difference < 60):
|
||||
return "" + $difference + ' ' + _('second(s)');
|
||||
case ($difference < 3600): //60*60 = 3600
|
||||
return "" + ($num = Math.round($difference/(60))) + ' ' + _('minute(s)');
|
||||
case ($difference < 86400): //60*60*24 = 86400
|
||||
return "" + ($num = Math.round($difference/(3600))) + ' ' + _('hour(s)');
|
||||
case ($difference < 604800): //60*60*24*7 = 604800
|
||||
return "" + ($num = Math.round($difference/(86400))) + ' ' + _('day(s)');
|
||||
case ($difference < 31536000): //60*60*24*365 = 31536000
|
||||
return "" + ($num = Math.round($difference/(604800))) + ' ' + _('week(s)');
|
||||
default:
|
||||
return "" + ($num = Math.round($difference/(31536000))) + ' ' + _('year(s)');
|
||||
}
|
||||
var $difference = $timestamp - Date.now()/1000|0, $num;
|
||||
switch(true){
|
||||
case ($difference < 60):
|
||||
return "" + $difference + ' ' + _('second(s)');
|
||||
case ($difference < 3600): //60*60 = 3600
|
||||
return "" + ($num = Math.round($difference/(60))) + ' ' + _('minute(s)');
|
||||
case ($difference < 86400): //60*60*24 = 86400
|
||||
return "" + ($num = Math.round($difference/(3600))) + ' ' + _('hour(s)');
|
||||
case ($difference < 604800): //60*60*24*7 = 604800
|
||||
return "" + ($num = Math.round($difference/(86400))) + ' ' + _('day(s)');
|
||||
case ($difference < 31536000): //60*60*24*365 = 31536000
|
||||
return "" + ($num = Math.round($difference/(604800))) + ' ' + _('week(s)');
|
||||
default:
|
||||
return "" + ($num = Math.round($difference/(31536000))) + ' ' + _('year(s)');
|
||||
}
|
||||
}
|
||||
|
||||
function ago($timestamp) {
|
||||
var $difference = (Date.now()/1000|0) - $timestamp, $num;
|
||||
switch(true){
|
||||
case ($difference < 60) :
|
||||
return "" + $difference + ' ' + _('second(s)');
|
||||
case ($difference < 3600): //60*60 = 3600
|
||||
return "" + ($num = Math.round($difference/(60))) + ' ' + _('minute(s)');
|
||||
case ($difference < 86400): //60*60*24 = 86400
|
||||
return "" + ($num = Math.round($difference/(3600))) + ' ' + _('hour(s)');
|
||||
case ($difference < 604800): //60*60*24*7 = 604800
|
||||
return "" + ($num = Math.round($difference/(86400))) + ' ' + _('day(s)');
|
||||
case ($difference < 31536000): //60*60*24*365 = 31536000
|
||||
return "" + ($num = Math.round($difference/(604800))) + ' ' + _('week(s)');
|
||||
default:
|
||||
return "" + ($num = Math.round($difference/(31536000))) + ' ' + _('year(s)');
|
||||
}
|
||||
var $difference = (Date.now()/1000|0) - $timestamp, $num;
|
||||
switch(true){
|
||||
case ($difference < 60) :
|
||||
return "" + $difference + ' ' + _('second(s)');
|
||||
case ($difference < 3600): //60*60 = 3600
|
||||
return "" + ($num = Math.round($difference/(60))) + ' ' + _('minute(s)');
|
||||
case ($difference < 86400): //60*60*24 = 86400
|
||||
return "" + ($num = Math.round($difference/(3600))) + ' ' + _('hour(s)');
|
||||
case ($difference < 604800): //60*60*24*7 = 604800
|
||||
return "" + ($num = Math.round($difference/(86400))) + ' ' + _('day(s)');
|
||||
case ($difference < 31536000): //60*60*24*365 = 31536000
|
||||
return "" + ($num = Math.round($difference/(604800))) + ' ' + _('week(s)');
|
||||
default:
|
||||
return "" + ($num = Math.round($difference/(31536000))) + ' ' + _('year(s)');
|
||||
}
|
||||
}
|
||||
|
||||
var datelocale =
|
||||
{ days: [_('Sunday'), _('Monday'), _('Tuesday'), _('Wednesday'), _('Thursday'), _('Friday'), _('Saturday')]
|
||||
, shortDays: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")]
|
||||
, 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')]
|
||||
, AM: _('AM')
|
||||
, PM: _('PM')
|
||||
, am: _('am')
|
||||
, pm: _('pm')
|
||||
};
|
||||
{ days: [_('Sunday'), _('Monday'), _('Tuesday'), _('Wednesday'), _('Thursday'), _('Friday'), _('Saturday')]
|
||||
, shortDays: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")]
|
||||
, 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')]
|
||||
, AM: _('AM')
|
||||
, PM: _('PM')
|
||||
, am: _('am')
|
||||
, pm: _('pm')
|
||||
};
|
||||
|
||||
|
||||
function alert(a) {
|
||||
var handler, div;
|
||||
var close = function() {
|
||||
handler.fadeOut(400, function() { handler.remove(); });
|
||||
return false;
|
||||
handler.fadeOut(400, function() { handler.remove(); });
|
||||
return false;
|
||||
};
|
||||
|
||||
handler = $("<div id='alert_handler'></div>").hide().appendTo('body');
|
||||
@ -254,6 +254,27 @@ function get_cookie(cookie_name) {
|
||||
}
|
||||
|
||||
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") {
|
||||
// don't highlight on middle click
|
||||
var e = event || window.event;
|
||||
@ -333,16 +354,23 @@ function citeReply(id, with_link) {
|
||||
// ???
|
||||
textarea.value += '>>' + id + '\n';
|
||||
}
|
||||
if (typeof $ != 'undefined') {
|
||||
var select = document.getSelection().toString();
|
||||
if (select) {
|
||||
var body = $('#reply_' + id + ', #op_' + id).find('div.body'); // TODO: support for OPs
|
||||
var index = body.text().indexOf(select.replace('\n', '')); // for some reason this only works like this
|
||||
if (index > -1) {
|
||||
textarea.value += '>' + select + '\n';
|
||||
}
|
||||
}
|
||||
|
||||
// multiline quotes
|
||||
var select = sessionStorage.quoteClipboard;
|
||||
if (select) {
|
||||
select = select.split('\n');
|
||||
select.forEach(function (str) {
|
||||
if (str !== '') {
|
||||
str = '>' + str + '\n';
|
||||
} else {
|
||||
str = '\n';
|
||||
}
|
||||
textarea.value += str;
|
||||
});
|
||||
delete sessionStorage.quoteClipboard;
|
||||
}
|
||||
|
||||
if (typeof $ != 'undefined') {
|
||||
$(window).trigger('cite', [id, with_link]);
|
||||
$(textarea).change();
|
||||
}
|
||||
@ -403,6 +431,11 @@ var script_settings = function(script_name) {
|
||||
function init() {
|
||||
init_stylechooser();
|
||||
|
||||
// store highlighted text for citeReply()
|
||||
document.querySelector('form[name="postcontrols"]').addEventListener('mouseup', function (e) {
|
||||
sessionStorage.quoteClipboard = window.getSelection().toString();
|
||||
});
|
||||
|
||||
{% endraw %}
|
||||
{% if config.allow_delete %}
|
||||
if (document.forms.postcontrols) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user