From 28c2dd9d065c20c2a8a70d62aa7b6e79b66cd2e7 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Wed, 14 Mar 2012 19:41:56 +1100 Subject: quick reply --- js/quick-reply.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 js/quick-reply.js (limited to 'js/quick-reply.js') diff --git a/js/quick-reply.js b/js/quick-reply.js new file mode 100644 index 00000000..e963ca6e --- /dev/null +++ b/js/quick-reply.js @@ -0,0 +1,45 @@ +/* + * quick-reply.js + * https://github.com/savetheinternet/Tinyboard-Tools/blob/master/js/quick-reply.js + * + * Released under the MIT license + * Copyright (c) 2012 Michael Save + * + * Usage: + * $config['additional_javascript'][] = $config['root'] . 'jquery.min.js'; + * $config['additional_javascript'][] = $config['root'] . 'quick-reply.js'; + * + */ + +$(document).ready(function(){ + if($('div.banner').length != 0) + return; // not index + + txt_new_topic = $('form[name=post] input[type=submit]').val(); + txt_new_reply = 'New Reply'; + + undo_quick_reply = function() { + $('div.banner').remove(); + $('form[name=post] input[type=submit]').val(txt_new_topic); + $('form[name=post] input[name=quick-reply]').remove(); + } + + $('div.post.op').each(function() { + var id = $(this).children('p.intro').children('a.post_no:eq(1)').text(); + $('[Quick reply]').insertAfter($(this).children('p.intro').children('a:last')).click(function() { + $('div.banner').remove(); + $('') + .insertBefore('form[name=post]'); + $('form[name=post] input[type=submit]').val(txt_new_reply); + + $('').appendTo($('form[name=post]')); + + $('form[name=post] textarea').select(); + + window.scrollTo(0, 0); + + return false; + }); + }); +}); + -- cgit v1.3 From d3b1f4cfa31c6c5a451b0bc5df500c51a8d04186 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Wed, 14 Mar 2012 20:19:35 +1100 Subject: Quick reply needs $config['quick_reply'] = true; --- js/quick-reply.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/quick-reply.js') diff --git a/js/quick-reply.js b/js/quick-reply.js index e963ca6e..f0587cd9 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -6,6 +6,7 @@ * Copyright (c) 2012 Michael Save * * Usage: + * $config['quick_reply'] = true; * $config['additional_javascript'][] = $config['root'] . 'jquery.min.js'; * $config['additional_javascript'][] = $config['root'] . 'quick-reply.js'; * -- cgit v1.3 From 6d56e006007ce950b1211e627108367125f1ec78 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Wed, 14 Mar 2012 22:04:27 +1100 Subject: use "Submit" for submit button if appropriate --- js/quick-reply.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/quick-reply.js') diff --git a/js/quick-reply.js b/js/quick-reply.js index f0587cd9..0062cd1e 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -17,7 +17,7 @@ $(document).ready(function(){ return; // not index txt_new_topic = $('form[name=post] input[type=submit]').val(); - txt_new_reply = 'New Reply'; + txt_new_reply = txt_new_topic == 'Submit' ? txt_new_topic : 'New Reply'; undo_quick_reply = function() { $('div.banner').remove(); -- cgit v1.3 From 34301da174acd3cfb326f03693657aeacd58be27 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Thu, 15 Mar 2012 16:19:26 +1100 Subject: local-time.js: convert times into user's timezone --- js/auto-reload.js | 3 ++- js/forced-anon.js | 4 ++-- js/local-time.js | 42 ++++++++++++++++++++++++++++++++++++++++++ js/quick-reply.js | 4 ++-- 4 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 js/local-time.js (limited to 'js/quick-reply.js') diff --git a/js/auto-reload.js b/js/auto-reload.js index 3789a136..70b4acc3 100644 --- a/js/auto-reload.js +++ b/js/auto-reload.js @@ -8,7 +8,8 @@ * Copyright (c) 2012 Michael Save * * Usage: - * $config['additional_javascript'][] = $config['root'] . 'auto-reload.js'; + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/auto-reload.js'; * */ diff --git a/js/forced-anon.js b/js/forced-anon.js index 86af4063..6949769d 100644 --- a/js/forced-anon.js +++ b/js/forced-anon.js @@ -6,8 +6,8 @@ * Copyright (c) 2012 Michael Save * * Usage: - * $config['additional_javascript'][] = $config['root'] . 'jquery.min.js'; - * $config['additional_javascript'][] = $config['root'] . 'forced-anon.js'; + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/forced-anon.js'; * */ diff --git a/js/local-time.js b/js/local-time.js new file mode 100644 index 00000000..6d0a163a --- /dev/null +++ b/js/local-time.js @@ -0,0 +1,42 @@ +/* + * local-time.js + * https://github.com/savetheinternet/Tinyboard-Tools/blob/master/js/local-time.js + * + * Released under the MIT license + * Copyright (c) 2012 Michael Save + * + * Usage: + * $config['quick_reply'] = true; + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/local-time.js'; + * + */ + +$(document).ready(function(){ + var iso8601 = function(s) { + s = s.replace(/\.\d\d\d+/,""); // remove milliseconds + s = s.replace(/-/,"/").replace(/-/,"/"); + s = s.replace(/T/," ").replace(/Z/," UTC"); + s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400 + return new Date(s); + }; + var zeropad = function(num, count) { + return [Math.pow(10, count - num.toString().length), num].join('').substr(1); + }; + + $('time').each(function() { + if(!$(this).text().match(/^\d+\/\d+\/\d+ \(\w+\) \d+:\d+:\d+$/)) + return; + + var t = iso8601($(this).attr('datetime')); + + $(this).text( + // date + zeropad(t.getMonth() + 1, 2) + "/" + zeropad(t.getDate(), 2) + "/" + t.getFullYear().toString().substring(2) + + " (" + ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][t.getDay()] + ") " + + // time + zeropad(t.getHours(), 2) + ":" + zeropad(t.getMinutes(), 2) + ":" + zeropad(t.getSeconds(), 2) + ); + }); +}); + diff --git a/js/quick-reply.js b/js/quick-reply.js index 0062cd1e..cc1a45a2 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -7,8 +7,8 @@ * * Usage: * $config['quick_reply'] = true; - * $config['additional_javascript'][] = $config['root'] . 'jquery.min.js'; - * $config['additional_javascript'][] = $config['root'] . 'quick-reply.js'; + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/quick-reply.js'; * */ -- cgit v1.3