This commit is contained in:
8chan 2015-01-28 17:57:59 -08:00
commit 233fb8e0f7
6 changed files with 140 additions and 72 deletions

View File

@ -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');

View File

@ -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;

View File

@ -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])

View File

@ -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">')

View File

@ -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')) {

View File

@ -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();
// multiline quotes
var select = sessionStorage.quoteClipboard;
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';
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) {