summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-04-30 02:31:45 +1000
committerMichael Save <savetheinternet@tinyboard.org>2012-04-30 02:31:45 +1000
commit760023fd32be74608e93d8de0d5269a121e1956d (patch)
treef5bd4cd6714ed18353dec7b216f22bffc65881a0 /js
parent704ae86682dbe9b366e673534fe6d1eb706e2fd7 (diff)
js/show-op.js
Diffstat (limited to 'js')
-rw-r--r--js/show-op.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/js/show-op.js b/js/show-op.js
new file mode 100644
index 00000000..df9cf31b
--- /dev/null
+++ b/js/show-op.js
@@ -0,0 +1,49 @@
+/*
+ * show-op
+ * https://github.com/savetheinternet/Tinyboard/blob/master/js/show-op.js
+ *
+ * Adds "(OP)" to >>X links when the OP is quoted.
+ *
+ * Released under the MIT license
+ * Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org>
+ *
+ * Usage:
+ * $config['additional_javascript'][] = 'js/jquery.min.js';
+ * $config['additional_javascript'][] = 'js/show-op.js';
+ *
+ */
+
+$(document).ready(function(){
+ var showOPLinks = function() {
+ var OP;
+
+ if ($('div.banner').length == 0) {
+ OP = $(this).parent().find('div.post.op a.post_no:eq(1)').text();
+ } else {
+ OP = $('div.post.op a.post_no:eq(1)').text();
+ }
+
+ console.log(OP);
+
+ $(this).find('p.body a:not([rel="nofollow"])').each(function() {
+ var postID;
+
+ if(postID = $(this).text().match(/^>>(\d+)$/))
+ postID = postID[1];
+ else
+ return;
+
+ if (postID == OP) {
+ $(this).after(' <small>(OP)</small>');
+ }
+ });
+ };
+
+ $('div.post.reply').each(showOPLinks);
+
+ // allow to work with auto-reload.js, etc.
+ $(document).bind('new_post', function(e, post) {
+ $(post).each(showOPLinks);
+ });
+});
+