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; var countdown_interval;
// Add an update link // 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 // Grab the settings
var settings = new script_settings('auto-reload'); var settings = new script_settings('auto-reload');

View File

@ -24,7 +24,7 @@ $(document).ready(function(){
var thread = $(this).parents('[id^="thread_"]'); var thread = $(this).parents('[id^="thread_"]');
var id = thread.attr('id').replace(/^thread_/, ''); var id = thread.attr('id').replace(/^thread_/, '');
$.ajax({ $.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, context: document.body,
success: function(data) { success: function(data) {
var last_expanded = false; var last_expanded = false;

View File

@ -87,23 +87,22 @@ $(document).ready(function(){
hidden_data[board] = {}; // id : timestamp hidden_data[board] = {}; // id : timestamp
} }
$('<a class="post-hide-link" href="javascript:void(0)" title="Hide Post" style="float: right">[]</a>') $('<a class="post-hide-link" href="javascript:void(0)" title="Hide Post" style="float: left; margin-right: 5px">[]</a>')
.insertAfter(post.children('p.intro').children('a.post_no:last')) .insertBefore(post.children('p.intro').children('input.delete'))
.click(function() { .click(function() {
hidden_data[board][id] = Math.round(Date.now() / 1000); hidden_data[board][id] = Math.round(Date.now() / 1000);
store_data(); store_data();
var hide_link = $(this); var hide_link = $(this);
post.children('div').hide(); post.children('div').hide();
hide_link.hide(); hide_link.hide();
$('<a class="post-show-link" href="javascript:void(0)" title="Show Post" style="float: right">[+]</a>') $('<a class="post-show-link" href="javascript:void(0)" title="Show Post" style="float: left; margin-right: 5px">[+]</a>')
.insertAfter(post.children('p.intro').children('a.post_no:last')) .insertBefore(post.children('p.intro').children('input.delete'))
.click(function() { .click(function() {
delete hidden_data[board][id]; delete hidden_data[board][id];
store_data(); store_data();
post.children('div').show(); post.children('div').show();
hide_link.show(); hide_link.show();
$(this).remove(); $(this).remove();
}); });
}); });
if (hidden_data[board][id]) if (hidden_data[board][id])

View File

@ -212,11 +212,17 @@ onready(function(){
if (this.isImage && !this.isSpoiler) { if (this.isImage && !this.isSpoiler) {
// video files uses jpg for thumbnail // 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; thumb_url = '/'+ board +'/thumb/' + this.tim + this.ext;
} else { } else {
thumb_url = (this.isSpoiler) ? '/static/spoiler.png' : '/static/file.png'; 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 // file infos
var $ele = $('<div class="file">') var $ele = $('<div class="file">')
.append($('<p class="fileinfo">') .append($('<p class="fileinfo">')
@ -224,7 +230,7 @@ onready(function(){
.append('<a>'+ this.filename + file_ext +'</a>') .append('<a>'+ this.filename + file_ext +'</a>')
.append('<span class="unimportant"> ('+ bytesToSize(this.fsize) +', '+ this.w +'x'+ this.h +')</span>') .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 // image
var $img = $('<img class="post-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); $postForm.find('textarea:not([name="body"]),input[type="hidden"]:not(.captcha_cookie)').removeAttr('id').appendTo($dummyStuff);
@ -374,6 +380,7 @@
$postForm.show(); $postForm.show();
} }
$postForm.find('textarea[name="body"]').focus();
$(window).on('stylesheet', function() { $(window).on('stylesheet', function() {
do_css(); do_css();
if ($('link#stylesheet').attr('href')) { if ($('link#stylesheet').attr('href')) {

View File

@ -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;
@ -333,16 +354,23 @@ function citeReply(id, with_link) {
// ??? // ???
textarea.value += '>>' + id + '\n'; textarea.value += '>>' + id + '\n';
} }
if (typeof $ != 'undefined') {
var select = document.getSelection().toString(); // multiline quotes
var select = sessionStorage.quoteClipboard;
if (select) { if (select) {
var body = $('#reply_' + id + ', #op_' + id).find('div.body'); // TODO: support for OPs select = select.split('\n');
var index = body.text().indexOf(select.replace('\n', '')); // for some reason this only works like this select.forEach(function (str) {
if (index > -1) { if (str !== '') {
textarea.value += '>' + select + '\n'; str = '>' + str + '\n';
} else {
str = '\n';
} }
textarea.value += str;
});
delete sessionStorage.quoteClipboard;
} }
if (typeof $ != 'undefined') {
$(window).trigger('cite', [id, with_link]); $(window).trigger('cite', [id, with_link]);
$(textarea).change(); $(textarea).change();
} }
@ -403,6 +431,11 @@ var script_settings = function(script_name) {
function init() { function init() {
init_stylechooser(); init_stylechooser();
// store highlighted text for citeReply()
document.querySelector('form[name="postcontrols"]').addEventListener('mouseup', function (e) {
sessionStorage.quoteClipboard = window.getSelection().toString();
});
{% endraw %} {% endraw %}
{% if config.allow_delete %} {% if config.allow_delete %}
if (document.forms.postcontrols) { if (document.forms.postcontrols) {