Vanilla commit.
[tinybbs.git] / javascript / main.js
blobaea7a4e012401de10dd5ab4a8ebe82718649b62a
1 function highlightReply(id)
3         var divs = document.getElementsByTagName('div');
5         for (var i = 0; i < divs.length; i++)
6         {
7                 if (divs[i].className.indexOf('body') != -1)
8                         divs[i].className = divs[i].className.replace(/highlighted/, '');
9         }
11         if (id)
12                 document.getElementById('reply_box_' + id).className += ' highlighted';
15 function focusId(id)
17         document.getElementById(id).focus();
18         init();
21 function checkOrUncheckAllCheckboxes()
23         tmp = document.fuck_off;
25         for (i = 0; i < tmp.elements.length; i++)
26         {
27                 if (tmp.elements[i].type == 'checkbox')
28                 {
29                         if (tmp.master_checkbox.checked == true)
30                                 tmp.elements[i].checked = true;
31                         else
32                                 tmp.elements[i].checked = false;
33                 }
34         }
37 function submitDummyForm(theAction, theVariableName, theVariableValue, confirmMessage)
39         if (confirmMessage === undefined)
40                 var tmp = confirm('Really?');
41         else
42                 var tmp = confirm(confirmMessage);
44         if (tmp)
45         {
46                 var form = document.getElementById('dummy_form');
47                 form.action = theAction;
48                 form.some_var.name = theVariableName;
49                 form.some_var.value = theVariableValue;
50                 form.submit();
51         }
53         return false;
56 function updateCharactersRemaining(theInputOrTextarea, theElementToUpdate, maxCharacters)
58         tmp = document.getElementById(theElementToUpdate);
59         tmp.firstChild.data = maxCharacters - document.getElementById(theInputOrTextarea).value.length;
62 function printCharactersRemaining(idOfTrackerElement, numDefaultCharacters)
64         document.write(' (<STRONG ID="' + idOfTrackerElement + '">' + numDefaultCharacters + '</STRONG> characters left)');
67 function removeSnapbackLink()
69         var tmp = document.getElementById("snapback_link");
71         if (tmp)
72                 tmp.parentNode.removeChild(tmp);
75 function createSnapbackLink(lastReplyId)
77         removeSnapbackLink();
79         var div = document.createElement('DIV');
80         div.id = 'snapback_link';
81         var a = document.createElement('A');
82         a.href = '#reply_' + lastReplyId;
83         a.onclick = function () { highlightReply(lastReplyId); removeSnapbackLink(); };
84         a.className = 'help_cursor';
85         a.title = 'Click me to snap back!';
86         var strong = document.createElement('STRONG');
87         strong.appendChild(document.createTextNode('↕'));
88         a.appendChild(strong);
89         div.appendChild(a);
90         document.body.appendChild(div);
93 function init()
95         if (document.getElementById(window.location.hash.substring(1)) && window.location.hash.indexOf('reply_') != -1)
96                 highlightReply(window.location.hash.substring(7));
97         else if (window.location.hash.indexOf('new') != -1)
98                 highlightReply(document.getElementById('new_id').value);
101 window.onload = init;