summaryrefslogtreecommitdiffstats
path: root/static/functions
diff options
context:
space:
mode:
Diffstat (limited to 'static/functions')
-rw-r--r--static/functions/artists.js369
-rw-r--r--static/functions/bbcode.js11
-rw-r--r--static/functions/browse.js225
-rw-r--r--static/functions/captcha.js4
-rw-r--r--static/functions/class_ajax.js116
-rw-r--r--static/functions/class_cookie.js23
-rw-r--r--static/functions/class_countdown.js39
-rw-r--r--static/functions/class_hotkey.js0
-rw-r--r--static/functions/class_storage.js70
-rw-r--r--static/functions/collage.js21
-rw-r--r--static/functions/comments.js213
-rw-r--r--static/functions/delays.js60
-rw-r--r--static/functions/global.js94
-rw-r--r--static/functions/inbox.js16
-rw-r--r--static/functions/iphone.js187
-rw-r--r--static/functions/notifications.js5
-rw-r--r--static/functions/reportsv2.js251
-rw-r--r--static/functions/requests.js182
-rw-r--r--static/functions/rippy.js15
-rw-r--r--static/functions/script_start.js285
-rw-r--r--static/functions/sizzle.js7
-rw-r--r--static/functions/staffpm.js110
-rw-r--r--static/functions/subscriptions.js21
-rw-r--r--static/functions/torrent.js172
-rw-r--r--static/functions/transitions.js98
-rw-r--r--static/functions/upload.js272
-rw-r--r--static/functions/user.js137
-rw-r--r--static/functions/validate.js106
-rw-r--r--static/functions/wiki.js5
29 files changed, 3114 insertions, 0 deletions
diff --git a/static/functions/artists.js b/static/functions/artists.js
new file mode 100644
index 0000000..e612d24
--- /dev/null
+++ b/static/functions/artists.js
@@ -0,0 +1,369 @@
+var dragObjects = null;
+var dragObjectPlaceholder = null;
+
+function editOrdering() {
+ $('#editlayout').hide();
+ $('#releasetypes').hide();
+ $('#linkbox').hide();
+ $('.sidebar').hide();
+ $('.main_column > .box').hide(); // Artist info
+ $('.main_column > #requests').hide();
+
+ $('#savelayout').show();
+ $('#emptylinkbox').show();
+ $('#torrents_allopenclose').show();
+
+ dragObjects = new Array();
+
+ var elems = $('#torrents_tables table').objects;
+ for(i in elems) {
+ var elemID = elems[i].id;
+ if(elemID == undefined) { continue; }
+ if(elemID.indexOf('torrents_') == 0) {
+ $('#'+elemID).show();
+ dragObjects[elemID] = new dragObject(elemID, elemID+'_handle', startDrag, moveDrag, endDrag);
+ var classes = elems[i].className.split(' ');
+ for(var j=0; classes.length; j++) {
+ if(classes[j].indexOf('releases_') == 0) {
+ $('.'+classes[j].replace('_table', '')).hide();
+ $('.artist_editcol').show();
+ $('.artist_normalcol').hide();
+ break;
+ }
+ }
+ }
+ }
+
+ for(i in dragObjects) { dragObjects[i].StartListening(); }
+}
+
+function saveOrdering() {
+ $('#savelayout').hide();
+ $('#savinglayout').show();
+
+ var elems = $('#torrents_tables table').objects;
+ var releaseTypes = "{";
+ for(i in elems) {
+ var elemID = elems[i].id;
+ var releaseType = null;
+ if(elemID == undefined) { continue; }
+ if(elemID.indexOf('torrents_') == 0) {
+ var classes = elems[i].className.split(' ');
+ for(var j=0; classes.length; j++) {
+ if(classes[j] == null) { break; }
+ if(classes[j].indexOf('releases_') == 0) {
+ releaseType = classes[j].split('_')[1];
+ }
+ }
+ }
+ if(releaseType != null) { releaseTypes += '"' + releaseType + '":' + ($('#releases_' + releaseType + '_defaultopen').raw().checked ? 1 : 0) + ","; }
+ }
+ releaseTypes = releaseTypes.substring(0, releaseTypes.length-1) + '}';
+ var postData = new Array();
+ postData['layoutdefaults'] = releaseTypes;
+ ajax.post("artist.php?action=ajax_edit_artistlayout", postData, saveOrderingCallback);
+}
+
+function saveOrderingCallback(response) {
+
+ //Let's do what the user asked for, shall we.
+ //Show/hide
+ var releaseTypes = json.decode(response);
+ for(releaseType in releaseTypes) {
+ if(releaseTypes[releaseType] == 1) { setShow(releaseType, true); }
+ else { setShow(releaseType, false); }
+ }
+
+ //Ordering in linkbox
+ var prevOrderedLink = null;
+ for(releaseType in releaseTypes) {
+ var elem = $('#torrents_' + releaseType + '_anchorlink').raw();
+ if(elem == undefined) { continue; }
+ if(prevOrderedLink == null) { prevOrderedLink = elem; }
+ else {
+ prevOrderedLink.parentNode.insertBefore(elem, prevOrderedLink.nextSibling);
+ prevOrderedLink = elem;
+ }
+ }
+
+ //Now let's return to the non editing layout.
+ var elems = $('#torrents_tables table').objects;
+ for(i in elems) {
+ var elemID = elems[i].id;
+ if(elemID == undefined) { continue; }
+ if(elemID.indexOf('torrents_') == 0) {
+ var classes = elems[i].className.split(' ');
+ var empty = false;
+ for(var j=0; classes.length; j++) {
+ if(classes[j] == null) { break; }
+ if(classes[j].indexOf('releases_') == 0) {
+ $('.artist_editcol').hide();
+ $('.artist_normalcol').show();
+ }
+ if(classes[j].indexOf('empty') == 0) { empty = true; }
+ }
+ if(empty) { $('#'+elemID).hide(); }
+ }
+ }
+
+ for(i in dragObjects) { dragObjects[i].StopListening(); }
+ dragObjects = null;
+
+ $('#savinglayout').hide();
+ $('#emptylinkbox').hide();
+ $('#torrents_allopenclose').hide();
+
+ $('#editlayout').show();
+ $('#releasetypes').show();
+ $('#linkbox').show();
+ $('.sidebar').show();
+ $('.main_column > .box').show(); // Artist info
+ $('.main_column > #requests').show();
+}
+
+function setDefaultShow(id, show) {
+ if(id == 'all') {
+ var elems = $('#torrents_tables table').objects;
+ for(i in elems) {
+ var elemID = elems[i].id;
+ var releaseType = null;
+ if(elemID == undefined) { continue; }
+ if(elemID.indexOf('torrents_') == 0) {
+ var classes = elems[i].className.split(' ');
+ for(var j=0; classes.length; j++) {
+ if(classes[j] == null) { break; }
+ if(classes[j].indexOf('releases_') == 0) {
+ releaseType = classes[j].split('_')[1];
+ }
+ }
+ }
+ setDefaultShow(releaseType, show);
+ }
+ }
+ else if(show) {
+ $('#releases_'+id+'_openlink').hide();
+ $('#releases_'+id+'_closedlink').show();
+ $('#releases_'+id+'_defaultopen').raw().checked = 'checked';
+ }
+ else {
+ $('#releases_'+id+'_openlink').show();
+ $('#releases_'+id+'_closedlink').hide();
+ $('#releases_'+id+'_defaultopen').raw().checked = '';
+ }
+}
+
+function setShow(id, show) {
+ if(show) {
+ $('#releases_'+id+'_viewlink').hide();
+ $('#releases_'+id+'_hidelink').show();
+ $('.releases_'+id).show();
+ }
+ else {
+ $('#releases_'+id+'_viewlink').show();
+ $('#releases_'+id+'_hidelink').hide();
+ $('.releases_'+id).hide();
+ }
+}
+
+function startDrag(element) {
+ element.style.top = element.offsetTop + 'px';
+ element.style.left = element.offsetLeft + 'px';
+ element.style.height = element.offsetHeight + 'px';
+ element.style.width = element.offsetWidth + 'px';
+ element.style.position = 'absolute';
+ element.style.zIndex = '100';
+
+ $('body').objects[0].style.cursor = 'move';
+
+ dragObjectPlaceholder = document.createElement('TABLE');
+ dragObjectPlaceholder.style.backgroundColor = '#DDDDDD';
+ dragObjectPlaceholder.style.height = element.style.height;
+ dragObjectPlaceholder.style.width = element.style.width;
+ element.parentNode.insertBefore(dragObjectPlaceholder, element);
+}
+
+function moveDrag(element) {
+ if(
+ (element.offsetTop > (dragObjectPlaceholder.offsetTop + parseInt(dragObjectPlaceholder.style.height))) ||
+ ((element.offsetTop + parseInt(dragObjectPlaceholder.style.height)) < dragObjectPlaceholder.offsetTop)
+ ) {
+ var bestItem = 'END';
+ elems = element.parentNode.childNodes;
+
+ for(var i=0; i < elems.length; i++) {
+ elem = elems[i];
+ if(elem == element || elem.nodeName != 'TABLE') { continue; }
+
+ if((element.offsetTop > dragObjectPlaceholder.offsetTop) && (elem.offsetTop - element.offsetTop) > parseInt(element.style.height)) {
+ bestItem = elem;
+ break;
+ }
+ else if((element.offsetTop < dragObjectPlaceholder.offsetTop) && (elem.offsetTop + parseInt(element.style.height)) > element.offsetTop) {
+ bestItem = elem;
+ break;
+ }
+ }
+ if(bestItem == dragObjectPlaceholder) { return; }
+
+ if(bestItem != 'END') { element.parentNode.insertBefore(dragObjectPlaceholder, element.parentNode.childNodes[i]); }
+ else { element.parentNode.appendChild(dragObjectPlaceholder); }
+ }
+}
+
+function endDrag(element) {
+ $('body').objects[0].style.cursor = '';
+ element.style.top = '';
+ element.style.left = '';
+ element.style.zIndex = '';
+ element.style.position = '';
+
+ element.parentNode.replaceChild(element, dragObjectPlaceholder);
+ dragObjectPlaceholder = null;
+}
+
+//Slightly modified from: http://www.switchonthecode.com/tutorials/javascript-draggable-elements
+function addEvent(element, eventName, callback) {
+ if(element.addEventListener) { element.addEventListener(eventName, callback, false); }
+ else if(element.attachEvent) { element.attachEvent("on" + eventName, callback); }
+}
+
+function removeEvent(element, eventName, callback) {
+ if(element.removeEventListener) { element.removeEventListener(eventName, callback, false); }
+ else if(element.detachEvent) { element.detachEvent("on" + eventName, callback); }
+}
+
+function cancelEvent(e) {
+ e = e ? e : window.event;
+ if(e.stopPropagation) { e.stopPropagation(); }
+ if(e.preventDefault) { e.preventDefault(); }
+ e.cancelBubble = true;
+ e.cancel = true;
+ e.returnValue = false;
+ return false;
+}
+
+function Position(x, y) {
+ this.X = x;
+ this.Y = y;
+
+ this.Add = function(val) {
+ var newPos = new Position(this.X, this.Y);
+ if(val != null) {
+ if(!isNaN(val.X)) { newPos.X += val.X; }
+ if(!isNaN(val.Y)) { newPos.Y += val.Y; }
+ }
+ return newPos;
+ }
+
+ this.Subtract = function(val) {
+ var newPos = new Position(this.X, this.Y);
+ if(val != null) {
+ if(!isNaN(val.X)) { newPos.X -= val.X; }
+ if(!isNaN(val.Y)) { newPos.Y -= val.Y; }
+ }
+ return newPos;
+ }
+
+ this.Check = function() {
+ var newPos = new Position(this.X, this.Y);
+ if(isNaN(newPos.X)) { newPos.X = 0; }
+ if(isNaN(newPos.Y)) { newPos.Y = 0; }
+ return newPos;
+ }
+
+ this.Apply = function(element, horizontal, vertical) {
+ if(!isNaN(this.X) && horizontal) { element.style.left = this.X + 'px'; }
+ if(!isNaN(this.Y) && vertical) { element.style.top = this.Y + 'px'; }
+ }
+}
+
+function absoluteCursorPostion(eventObj) {
+ eventObj = eventObj ? eventObj : window.event;
+
+ if(isNaN(window.scrollX)) {
+ return new Position(eventObj.clientX + document.documentElement.scrollLeft + document.body.scrollLeft, eventObj.clientY + document.documentElement.scrollTop + document.body.scrollTop);
+ }
+ else { return new Position(eventObj.clientX + window.scrollX, eventObj.clientY + window.scrollY); }
+}
+
+function dragObject(element, handlerElement, startCallback, moveCallback, endCallback) {
+ if(typeof(element) == "string") { element = $('#' + element).raw(); }
+ if(element == null) { return; }
+
+ if(typeof(handlerElement) == "string") { handlerElement = $('#' + handlerElement).raw(); }
+ if(handlerElement == null) { handlerElement = element; }
+
+ var cursorStartPos = null;
+ var elementStartPos = null;
+ var dragging = false;
+ var listening = false;
+ var disposed = false;
+
+ function dragStart(eventObj) {
+ if(dragging || !listening || disposed) { return; }
+ dragging = true;
+
+ cursorStartPos = absoluteCursorPostion(eventObj);
+ elementStartPos = new Position(parseInt(element.offsetLeft), parseInt(element.offsetTop));
+ elementStartPos = elementStartPos.Check();
+
+ if(startCallback != null) { startCallback(element); }
+
+ addEvent(document, "mousemove", dragGo);
+ addEvent(document, "mouseup", dragStopHook);
+
+ return cancelEvent(eventObj);
+ }
+
+ function dragGo(eventObj) {
+ if(!dragging || disposed) { return; }
+
+ var newPos = absoluteCursorPostion(eventObj);
+ newPos = newPos.Add(elementStartPos).Subtract(cursorStartPos);
+ newPos.Apply(element, false, true);
+ if(moveCallback != null) { moveCallback(element); }
+
+ return cancelEvent(eventObj);
+ }
+
+ function dragStop() {
+ if(!dragging || disposed) { return; }
+ removeEvent(document, "mousemove", dragGo);
+ removeEvent(document, "mouseup", dragStopHook);
+ cursorStartPos = null;
+ elementStartPos = null;
+
+ if(endCallback != null) { endCallback(element); }
+ dragging = false;
+ }
+
+ function dragStopHook(eventObj) {
+ dragStop();
+ return cancelEvent(eventObj);
+ }
+
+ this.Dispose = function() {
+ if(disposed) { return; }
+ this.StopListening(true);
+ element = null;
+ handlerElement = null
+ startCallback = null;
+ moveCallback = null
+ endCallback = null;
+ disposed = true;
+ }
+
+ this.StartListening = function() {
+ if(listening || disposed) { return; }
+ listening = true;
+ addEvent(handlerElement, "mousedown", dragStart);
+ }
+
+ this.StopListening = function(stopCurrentDragging) {
+ if(!listening || disposed) { return; }
+ removeEvent(handlerElement, "mousedown", dragStart);
+ listening = false;
+
+ if(stopCurrentDragging && dragging) { dragStop(); }
+ }
+}
diff --git a/static/functions/bbcode.js b/static/functions/bbcode.js
new file mode 100644
index 0000000..6f2a527
--- /dev/null
+++ b/static/functions/bbcode.js
@@ -0,0 +1,11 @@
+var BBCode = {
+ spoiler: function(link) {
+ if($(link.nextSibling).has_class('hidden')) {
+ $(link.nextSibling).show();
+ $(link).html('Hide');
+ } else {
+ $(link.nextSibling).hide();
+ $(link).html('Show');
+ }
+ }
+};
diff --git a/static/functions/browse.js b/static/functions/browse.js
new file mode 100644
index 0000000..7ca942e
--- /dev/null
+++ b/static/functions/browse.js
@@ -0,0 +1,225 @@
+function show_peers (TorrentID, Page) {
+ if(Page>0) {
+ ajax.get('torrents.php?action=peerlist&page='+Page+'&torrentid=' + TorrentID,function(response){
+ $('#peers_' + TorrentID).show().raw().innerHTML=response;
+ });
+ } else {
+ if ($('#peers_' + TorrentID).raw().innerHTML === '') {
+ $('#peers_' + TorrentID).show().raw().innerHTML = '<h4>Loading...</h4>';
+ ajax.get('torrents.php?action=peerlist&torrentid=' + TorrentID,function(response){
+ $('#peers_' + TorrentID).show().raw().innerHTML=response;
+ });
+ } else {
+ $('#peers_' + TorrentID).toggle();
+ }
+ }
+ $('#snatches_' + TorrentID).hide();
+ $('#downloads_' + TorrentID).hide();
+ $('#files_' + TorrentID).hide();
+ $('#reported_' + TorrentID).hide();
+}
+
+function show_snatches (TorrentID, Page){
+ if(Page>0) {
+ ajax.get('torrents.php?action=snatchlist&page='+Page+'&torrentid=' + TorrentID,function(response){
+ $('#snatches_' + TorrentID).show().raw().innerHTML=response;
+ });
+ } else {
+ if ($('#snatches_' + TorrentID).raw().innerHTML === '') {
+ $('#snatches_' + TorrentID).show().raw().innerHTML = '<h4>Loading...</h4>';
+ ajax.get('torrents.php?action=snatchlist&torrentid=' + TorrentID,function(response){
+ $('#snatches_' + TorrentID).show().raw().innerHTML=response;
+ });
+ } else {
+ $('#snatches_' + TorrentID).toggle();
+ }
+ }
+ $('#peers_' + TorrentID).hide();
+ $('#downloads_' + TorrentID).hide();
+ $('#files_' + TorrentID).hide();
+ $('#reported_' + TorrentID).hide();
+}
+
+function show_downloads (TorrentID, Page){
+ if(Page>0) {
+ ajax.get('torrents.php?action=downloadlist&page='+Page+'&torrentid=' + TorrentID,function(response){
+ $('#downloads_' + TorrentID).show().raw().innerHTML=response;
+ });
+ } else {
+ if ($('#downloads_' + TorrentID).raw().innerHTML === '') {
+ $('#downloads_' + TorrentID).show().raw().innerHTML = '<h4>Loading...</h4>';
+ ajax.get('torrents.php?action=downloadlist&torrentid=' + TorrentID,function(response){
+ $('#downloads_' + TorrentID).raw().innerHTML=response;
+ });
+ } else {
+ $('#downloads_' + TorrentID).toggle();
+ }
+ }
+ $('#peers_' + TorrentID).hide();
+ $('#snatches_' + TorrentID).hide();
+ $('#files_' + TorrentID).hide();
+ $('#reported_' + TorrentID).hide();
+}
+
+function show_files(TorrentID){
+ $('#files_' + TorrentID).toggle();
+ $('#peers_' + TorrentID).hide();
+ $('#snatches_' + TorrentID).hide();
+ $('#downloads_' + TorrentID).hide();
+ $('#reported_' + TorrentID).hide();
+}
+
+function show_reported(TorrentID){
+ $('#files_' + TorrentID).hide();
+ $('#peers_' + TorrentID).hide();
+ $('#snatches_' + TorrentID).hide();
+ $('#downloads_' + TorrentID).hide();
+ $('#reported_' + TorrentID).toggle();
+}
+
+function add_tag(tag) {
+ if ($('#tags').raw().value == "") {
+ $('#tags').raw().value = tag;
+ } else {
+ $('#tags').raw().value = $('#tags').raw().value + ", " + tag;
+ }
+}
+
+function toggle_group(groupid, link, event) {
+ var clickedRow = link;
+ while (clickedRow.nodeName != 'TR') {
+ clickedRow = clickedRow.parentNode;
+ }
+ var group_rows = clickedRow.parentNode.children;
+ //var showing = has_class(nextElementSibling(clickedRow), 'hidden'); // nextElementSibling(clickedRow) is a .edition
+ var showing = $(clickedRow).nextElementSibling().has_class('hidden');
+ var allGroups = event.ctrlKey;
+ for (var i = 0; i < group_rows.length; i++) {
+ var row = $(group_rows[i]);
+ if (row.has_class('colhead_dark')) { continue; }
+ if (row.has_class('colhead')) { continue; }
+ var relevantRow = row.has_class('group') ? row.nextElementSibling() : row;
+ if (allGroups || relevantRow.has_class('groupid_' + groupid)) {
+ if (row.has_class('group')) {
+ $('a.show_torrents_link', row).raw().title = (showing) ? 'Collapse this group' : 'Expand this group';
+ } else {
+ if (showing) {
+ // show the row depending on whether the edition it's in is collapsed or not
+ if (row.has_class('edition')) {
+ row.show();
+ showRow = ($('a', row.raw()).raw().innerHTML != '+');
+ } else {
+ if (showRow) {
+ row.show();
+ } else {
+ row.hide();
+ }
+ }
+ } else {
+ row.hide();
+ }
+ }
+ }
+ }
+ if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; }
+}
+
+function toggle_edition(groupid, editionid, lnk, event) {
+ var clickedRow = lnk;
+ while (clickedRow.nodeName != 'TR') {
+ clickedRow = clickedRow.parentNode;
+ }
+ //var showing = has_class(nextElementSibling(clickedRow), 'hidden');
+ var showing = $(clickedRow).nextElementSibling().has_class('hidden');
+ var allEditions = event.ctrlKey;
+ var group_rows = $('tr.groupid_' + groupid);
+ for (var i = 0; i < group_rows.results(); i++) {
+ var row = $(group_rows.raw(i));
+ if (row.has_class('edition') && (allEditions || row == clickedRow)) {
+ $('a', row.raw()).raw().innerHTML = (showing) ? '&minus;' : '+';
+ $('a', row.raw()).raw().title = (showing) ? 'Collapse this edition' : 'Expand this edition';
+ continue;
+ }
+ if (allEditions || row.has_class('edition_' + editionid)) {
+ if (showing && !row.has_class('torrentdetails')) {
+ row.show();
+ } else {
+ row.hide();
+ }
+ }
+ }
+ if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; }
+}
+
+// Bookmarks
+function Bookmark(groupid,newname) {
+ var lnk = $('#bookmarklink'+groupid).raw();
+ lnk.setAttribute('newname', lnk.innerHTML);
+ ajax.get("bookmarks.php?action=add&auth=" + authkey + "&groupid=" + groupid, function() {
+ lnk.onclick = function() { unbookmark(groupid,this.getAttribute('newname')); return false; };
+ lnk.innerHTML = newname;
+ });
+}
+
+function unbookmark(groupid,newname) {
+ if(window.location.pathname.indexOf('bookmarks.php') != -1) {
+ ajax.get("bookmarks.php?action=remove&auth=" + authkey + "&groupid=" + groupid,function() {
+ $('#group_' + groupid).remove();
+ $('.groupid_' + groupid).remove();
+ });
+ } else {
+ var lnk = $('#bookmarklink'+groupid).raw();
+ lnk.setAttribute('newname', lnk.innerHTML);
+ ajax.get("bookmarks.php?action=remove&auth=" + authkey + "&groupid=" + groupid, function() {
+ lnk.onclick = function() { Bookmark(groupid,this.getAttribute('newname')); return false; };
+ lnk.innerHTML = newname;
+ });
+ }
+}
+
+// For /sections/torrents/browse.php (not browse2.php)
+function Bitrate() {
+ $('#other_bitrate').raw().value = '';
+ if ($('#bitrate').raw().options[$('#bitrate').raw().selectedIndex].value == 'Other') {
+ $('#other_bitrate_span').show();
+ } else {
+ $('#other_bitrate_span').hide();
+ }
+}
+
+var ArtistFieldCount = 1;
+
+function AddArtistField() {
+ if (ArtistFieldCount >= 100) { return; }
+ var x = $('#AddArtists').raw();
+ x.appendChild(document.createElement("br"));
+ var ArtistField = document.createElement("input");
+ ArtistField.type = "text";
+ ArtistField.name = "aliasname[]";
+ ArtistField.size = "17";
+ x.appendChild(ArtistField);
+ x.appendChild(document.createTextNode(' '));
+ var Importance = document.createElement("select");
+ Importance.name = "importance[]";
+ Importance.innerHTML = '<option value="1">Main</option><option value="2">Guest</option><option value="3">Remixer</option>';
+ x.appendChild(Importance);
+ ArtistFieldCount++;
+}
+
+function ToggleEditionRows() {
+ $('#edition_title').toggle();
+ $('#edition_label').toggle();
+ $('#edition_catalogue').toggle();
+}
+
+
+function ToggleGroup(groupid) {
+ var show = $('#showimg_' + groupid).has_class('show_torrents')
+ if(show) {
+ $('.groupid_' + groupid).show();
+ $('#showimg_' + groupid).remove_class('show_torrents').add_class('hide_torrents');
+ } else {
+ $('.groupid_' + groupid).hide();
+ $('#showimg_' + groupid).remove_class('hide_torrents').add_class('show_torrents');
+ }
+}
diff --git a/static/functions/captcha.js b/static/functions/captcha.js
new file mode 100644
index 0000000..21758e8
--- /dev/null
+++ b/static/functions/captcha.js
@@ -0,0 +1,4 @@
+function refreshCaptcha() {
+ var time = new Date();
+ $('#captcha_img').src='captcha.php?t='+time.getTime();
+}
diff --git a/static/functions/class_ajax.js b/static/functions/class_ajax.js
new file mode 100644
index 0000000..e1d4611
--- /dev/null
+++ b/static/functions/class_ajax.js
@@ -0,0 +1,116 @@
+/*
+ TODO: Further optimize serialize function
+
+ UPDATE: We were forced to create an individual XHR for each request
+ to avoid race conditions on slower browsers where the request would
+ be overwritten before the callback triggered, and leave it hanging.
+ This only happened in FF3.0 that we tested.
+
+ Example usage 1:
+ ajax.handle = function () {
+ $('#preview' + postid).raw().innerHTML = ajax.response;
+ $('#editbox' + postid).hide();
+ }
+ ajax.post("ajax.php?action=preview","#form-id" + postid);
+
+ Example usage 2:
+ ajax.handle = function() {
+ $('#quickpost').raw().value = "[quote="+username+"]" + ajax.response + "[/quote]";
+ }
+ ajax.get("?action=get_post&post=" + postid);
+
+*/
+"use strict";
+var json = {
+ encode: function (object) {
+ try {
+ return JSON.stringify(object);
+ } catch (err) {
+ return '';
+ }
+ },
+ decode: function (string) {
+ if (window.JSON && JSON.parse) {
+ return JSON.parse(string);
+ } else {
+ return eval("(" + string + ")");
+ //return (new Function("return " + data))();
+ }
+ }
+};
+
+var ajax = {
+ get: function (url, callback) {
+ var req = (typeof(window.ActiveXObject) === 'undefined') ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
+ if (callback !== undefined) {
+ req.onreadystatechange = function () {
+ if (req.readyState !== 4 || req.status !== 200) {
+ return;
+ }
+ callback(req.responseText);
+ };
+ }
+ req.open("GET", url, true);
+ req.send(null);
+ },
+ post: function (url, data, callback) {
+ var req = isset(window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
+ var params = ajax.serialize(data);
+ if (callback !== undefined) {
+ req.onreadystatechange = function () {
+ if (req.readyState !== 4 || req.status !== 200) {
+ return;
+ }
+ callback(req.responseText);
+ };
+ }
+ req.open('POST', url, true);
+ req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ req.send(params);
+ },
+ serialize: function (data) {
+ var query = '',
+ elements;
+ if (is_array(data)) {
+ for (var key in data) {
+ query += key + '=' + encodeURIComponent(data[key]) + '&';
+ }
+ } else {
+ elements = document.getElementById(data).elements;
+ for (var i = 0, il = elements.length; i < il; i++) {
+ var element = elements[i];
+ if (!isset(element) || element.disabled || element.name === '') {
+ continue;
+ }
+ switch (element.type) {
+ case 'text':
+ case 'hidden':
+ case 'password':
+ case 'textarea':
+ case 'select-one':
+ query += element.name + '=' + encodeURIComponent(element.value) + '&';
+ break;
+ case 'select-multiple':
+ for (var j = 0, jl = element.options.length; j < jl; j++) {
+ var current = element.options[j];
+ if (current.selected) {
+ query += element.name + '=' + encodeURIComponent(current.value) + '&';
+ }
+ }
+ break;
+ case 'radio':
+ if (element.checked) {
+ query += element.name + '=' + encodeURIComponent(element.value) + '&';
+ }
+ break;
+ case 'checkbox':
+ if (element.checked) {
+ query += element.name + '=' + encodeURIComponent(element.value) + '&';
+ }
+ break;
+ }
+ }
+ }
+ return query.substr(0, query.length - 1);
+ }
+};
diff --git a/static/functions/class_cookie.js b/static/functions/class_cookie.js
new file mode 100644
index 0000000..15a33b0
--- /dev/null
+++ b/static/functions/class_cookie.js
@@ -0,0 +1,23 @@
+/*
+ TODO: Document.
+*/
+"use strict";
+var cookie = {
+ get: function (cookie_name) {
+ var value = document.cookie.match('(^|;)?' + cookie_name + '=([^;]*)(;|$)');
+ return (value) ? value[2] : null;
+ },
+ set: function (cookie_name, value, days) {
+ var date = new Date();
+
+ if (days === undefined) {
+ days = 365;
+ }
+
+ date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
+ document.cookie = cookie_name + "=" + value + "; expires=" + date.toGMTString() + "; path=/";
+ },
+ del: function (cookie_name) {
+ cookie.set(cookie_name, '', -1);
+ }
+};
diff --git a/static/functions/class_countdown.js b/static/functions/class_countdown.js
new file mode 100644
index 0000000..faea4c7
--- /dev/null
+++ b/static/functions/class_countdown.js
@@ -0,0 +1,39 @@
+/*
+ TODO: Move to more efficient structure used in class_ajax.
+
+ Example Usage:
+ <script type="text/javascript">
+ window.onload = freeleech;
+ function freeleech() {
+ count.end = 'The freeleech has ended!';
+ count.event = 'The freeleech will end in';
+ count.element = 'freeleech';
+ count.update(<?=(time(3,0,0,9,22)-time());?>);
+ }
+ </script>
+*/
+"use strict";
+var count = {
+ update: function (Offset) {
+ if (Offset < 0) {
+ document.getElementById(this.element).innerHTML = this.end;
+ } else {
+ var Seconds = Offset % 60;
+ if (Seconds < 10) {
+ Seconds = '0' + Seconds;
+ }
+ var Remainder = (Offset - Seconds) / 60;
+ var Minutes = Remainder % 60;
+ if (Minutes < 10) {
+ Minutes = '0' + Minutes;
+ }
+ Remainder = (Remainder - Minutes) / 60;
+ var Hours = Remainder % 24;
+ var Days = (Remainder - Hours) / 24;
+ $(this.element).raw().innerHTML = this.event + ' ' + (Days > 0 ? Days + 'd, ' : '') + (Hours > 0 ? Hours + 'h, ' : '') + Minutes + 'm, ' + Seconds + 's.';
+ setTimeout(function (object) {
+ object.update(Offset - 1);
+ }, 999, this);
+ }
+ }
+};
diff --git a/static/functions/class_hotkey.js b/static/functions/class_hotkey.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/static/functions/class_hotkey.js
diff --git a/static/functions/class_storage.js b/static/functions/class_storage.js
new file mode 100644
index 0000000..f3efcfe
--- /dev/null
+++ b/static/functions/class_storage.js
@@ -0,0 +1,70 @@
+/*
+ TODO: Document.
+*/
+"use strict";
+
+var cookie = {
+ get: function (key_name) {
+ var value = document.cookie.match('(^|;)?' + key_name + '=([^;]*)(;|$)');
+ return (value) ? value[2] : null;
+ },
+ set: function (key_name, value, days) {
+ var date = new Date();
+
+ if (days === undefined) {
+ days = 365;
+ }
+
+ date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
+ document.cookie = key_name + "=" + value + "; expires=" + date.toGMTString() + "; path=/";
+ },
+ del: function (key_name) {
+ cookie.set(key_name, '', -1);
+ },
+ flush: function () {
+ document.cookie = '';
+ }
+};
+
+/*
+var database = {
+ link: false,
+ database: 'what',
+ connect: function (db_name) {
+ if (db_name === undefined) {
+ db_name = this.database;
+ }
+ window.openDatabase(db_name);
+ }
+};
+*/
+
+var local = {
+ get: function (key_name) {
+ return localStorage.getItem(key_name);
+ },
+ set: function (key_name, value) {
+ localStorage.setItem(key_name, value);
+ },
+ del: function (key_name) {
+ localStorage.removeItem(key_name);
+ },
+ flush: function () {
+ localStorage.clear();
+ }
+};
+
+var session = {
+ get: function (key_name) {
+ sessionStorage.getItem(key_name);
+ },
+ set: function (key_name, value) {
+ sessionStorage.setItem(key_name, value);
+ },
+ del: function (key_name) {
+ sessionStorage.removeItem(key_name);
+ },
+ flush: function () {
+ sessionStorage.clear();
+ }
+};
diff --git a/static/functions/collage.js b/static/functions/collage.js
new file mode 100644
index 0000000..7863014
--- /dev/null
+++ b/static/functions/collage.js
@@ -0,0 +1,21 @@
+function Add(input) {
+ if(input.checked == false) {
+ Cancel();
+ } else {
+ if(document.getElementById("choices").raw().value == "") {
+ document.getElementById("choices").raw().value += input.name;
+ } else {
+ document.getElementById("choices").raw().value += "|" + input.name;
+ }
+ }
+}
+
+function Cancel() {
+ var e=document.getElementsByTagName("input");
+ for(i=0;i<e.length;i++){
+ if(e[i].type=="checkbox"){
+ e[i].checked=false;
+ }
+ }
+ document.getElementById("choices").raw().value = "";
+} \ No newline at end of file
diff --git a/static/functions/comments.js b/static/functions/comments.js
new file mode 100644
index 0000000..fb3b849
--- /dev/null
+++ b/static/functions/comments.js
@@ -0,0 +1,213 @@
+var username;
+var postid;
+
+function Quote(post, user) {
+ username = user;
+ postid = post;
+ ajax.get("?action=get_post&post=" + postid, function(response){
+ if ($('#quickpost').raw().value !== '') {
+ $('#quickpost').raw().value = $('#quickpost').raw().value + "\n\n";
+ }
+ $('#quickpost').raw().value = $('#quickpost').raw().value + "[quote="+username+"]" +
+ //response.replace(/(img|aud)(\]|=)/ig,'url$2').replace(/\[url\=(https?:\/\/[^\s\[\]<>"\'()]+?)\]\[url\](.+?)\[\/url\]\[\/url\]/gi, "[url]$1[/url]")
+ html_entity_decode(response)
+ + "[/quote]";
+ resize('quickpost');
+ });
+}
+
+function Edit_Form(post,key) {
+ postid = post;
+ if (location.href.match(/torrents\.php/)) {
+ boxWidth="50";
+ } else {
+ boxWidth="80";
+ }
+ $('#bar' + postid).raw().cancel = $('#content' + postid).raw().innerHTML;
+ $('#bar' + postid).raw().oldbar = $('#bar' + postid).raw().innerHTML;
+ $('#content' + postid).raw().innerHTML = "<div id=\"preview" + postid + "\"></div><form id=\"form" + postid + "\" method=\"post\"><input type=\"hidden\" name=\"auth\" value=\"" + authkey + "\" /><input type=\"hidden\" name=\"key\" value=\"" + key + "\" /><input type=\"hidden\" name=\"post\" value=\"" + postid + "\" /><textarea id=\"editbox" + postid + "\" onkeyup=\"resize('editbox" + postid + "');\" name=\"body\" cols=\""+boxWidth+"\" rows=\"10\"></textarea></form>";
+ $('#bar' + postid).raw().innerHTML = "<input type=\"button\" value=\"Preview\" onclick=\"Preview_Edit(" + postid + ");\" /><input type=\"button\" value=\"Post\" onclick=\"Save_Edit(" + postid + ")\" /><input type=\"button\" value=\"Cancel\" onclick=\"Cancel_Edit(" + postid + ");\" />";
+ ajax.get("?action=get_post&post=" + postid, function(response){
+ $('#editbox' + postid).raw().value = html_entity_decode(response);
+ resize('editbox' + postid);
+ });
+}
+
+function Cancel_Edit(postid) {
+ $('#bar' + postid).raw().innerHTML = $('#bar' + postid).raw().oldbar;
+ $('#content' + postid).raw().innerHTML = $('#bar' + postid).raw().cancel;
+}
+
+function Preview_Edit(postid) {
+ $('#bar' + postid).raw().innerHTML = "<input type=\"button\" value=\"Editor\" onclick=\"Cancel_Preview(" + postid + ");\" /><input type=\"button\" value=\"Post\" onclick=\"Save_Edit(" + postid + ")\" /><input type=\"button\" value=\"Cancel\" onclick=\"Cancel_Edit(" + postid + ");\" />";
+ ajax.post("ajax.php?action=preview","form" + postid, function(response){
+ $('#preview' + postid).raw().innerHTML = response;
+ $('#editbox' + postid).hide();
+ });
+}
+
+function Cancel_Preview(postid) {
+ $('#bar' + postid).raw().innerHTML = "<input type=\"button\" value=\"Preview\" onclick=\"Preview_Edit(" + postid + ");\" /><input type=\"button\" value=\"Post\" onclick=\"Save_Edit(" + postid + ")\" /><input type=\"button\" value=\"Cancel\" onclick=\"Cancel_Edit(" + postid + ");\" />";
+ $('#preview' + postid).raw().innerHTML = "";
+ $('#editbox' + postid).show();
+}
+
+function Save_Edit(postid) {
+ if (location.href.match(/forums\.php/)) {
+ ajax.post("forums.php?action=takeedit","form" + postid, function (response) {
+ $('#bar' + postid).raw().innerHTML = "";
+ $('#preview' + postid).raw().innerHTML = response;
+ $('#editbox' + postid).hide();
+ });
+ } else if (location.href.match(/collages?\.php/)) {
+ ajax.post("collages.php?action=takeedit_comment","form" + postid, function (response) {
+ $('#bar' + postid).raw().innerHTML = "";
+ $('#preview' + postid).raw().innerHTML = response;
+ $('#editbox' + postid).hide();
+ });
+ } else if (location.href.match(/requests\.php/)) {
+ ajax.post("requests.php?action=takeedit_comment","form" + postid, function (response) {
+ $('#bar' + postid).raw().innerHTML = "";
+ $('#preview' + postid).raw().innerHTML = response;
+ $('#editbox' + postid).hide();
+ });
+ } else {
+ ajax.post("torrents.php?action=takeedit_post","form" + postid, function (response) {
+ $('#bar' + postid).raw().innerHTML = "";
+ $('#preview' + postid).raw().innerHTML = response;
+ $('#editbox' + postid).hide();
+ });
+ }
+}
+
+function Delete(post) {
+ postid = post;
+ if (confirm('Are you sure you wish to delete this post?') == true) {
+ if (location.href.match(/forums\.php/)) {
+ ajax.get("forums.php?action=delete&auth=" + authkey + "&postid=" + postid, function () {
+ $('#post' + postid).hide();
+ });
+ } else if (location.href.match(/collage\.php/)) {
+ ajax.get("collage.php?action=delete_comment&auth=" + authkey + "&postid=" + postid, function () {
+ $('#post' + postid).hide();
+ });
+ } else if (location.href.match(/requests\.php/)) {
+ ajax.get("requests.php?action=delete_comment&auth=" + authkey + "&postid=" + postid, function () {
+ $('#post' + postid).hide();
+ });
+ } else {
+ ajax.get("torrents.php?action=delete_post&auth=" + authkey + "&postid=" + postid, function () {
+ $('#post' + postid).hide();
+ });
+ }
+ }
+}
+
+function Quick_Preview() {
+ var quickreplybuttons;
+ $('#post_preview').raw().value = "Make changes";
+ $('#post_preview').raw().preview = true;
+ ajax.post("ajax.php?action=preview","quickpostform", function(response){
+ $('#quickreplypreview').show();
+ $('#contentpreview').raw().innerHTML = response;
+ $('#quickreplytext').hide();
+ });
+}
+
+function Quick_Edit() {
+ var quickreplybuttons;
+ $('#post_preview').raw().value = "Preview";
+ $('#post_preview').raw().preview = false;
+ $('#quickreplypreview').hide();
+ $('#quickreplytext').show();
+}
+
+function Newthread_Preview(mode) {
+ $('#newthreadpreviewbutton').toggle();
+ $('#newthreadeditbutton').toggle();
+ if(mode) { // Preview
+ ajax.post("ajax.php?action=preview","newthreadform", function(response){
+ $('#contentpreview').raw().innerHTML = response;
+ });
+ $('#newthreadtitle').raw().innerHTML = $('#title').raw().value;
+ var pollanswers = $('#answer_block').raw();
+ if(pollanswers && pollanswers.children.length > 4) {
+ pollanswers = pollanswers.children;
+ $('#pollquestion').raw().innerHTML = $('#pollquestionfield').raw().value;
+ for(var i=0; i<pollanswers.length; i+=2) {
+ if(!pollanswers[i].value) { continue; }
+ var el = document.createElement('input');
+ el.id = 'answer_'+(i+1);
+ el.type = 'radio';
+ el.name = 'vote';
+ $('#pollanswers').raw().appendChild(el);
+ $('#pollanswers').raw().appendChild(document.createTextNode(' '));
+ el = document.createElement('label');
+ el.htmlFor = 'answer_'+(i+1);
+ el.innerHTML = pollanswers[i].value;
+ $('#pollanswers').raw().appendChild(el);
+ $('#pollanswers').raw().appendChild(document.createElement('br'));
+ }
+ if($('#pollanswers').raw().children.length > 4) {
+ $('#pollpreview').show();
+ }
+ }
+ } else { // Back to editor
+ $('#pollpreview').hide();
+ $('#newthreadtitle').raw().innerHTML = 'New Topic';
+ var pollanswers = $('#pollanswers').raw();
+ if(pollanswers) {
+ var el = document.createElement('div');
+ el.id = 'pollanswers';
+ pollanswers.parentNode.replaceChild(el, pollanswers);
+ }
+ }
+ $('#newthreadtext').toggle();
+ $('#newthreadpreview').toggle();
+ $('#subscribediv').toggle();
+}
+
+function LoadEdit(type, post, depth) {
+ ajax.get("forums.php?action=ajax_get_edit&postid=" + post + "&depth=" + depth + "&type=" + type, function(response) {
+ $('#content' + post).raw().innerHTML = response;
+ }
+ );
+}
+
+function AddPollOption(id) {
+ var list = $('#poll_options').raw();
+ var item = document.createElement("li");
+ var form = document.createElement("form");
+ form.method = "POST";
+ var auth = document.createElement("input");
+ auth.type = "hidden";
+ auth.name = "auth";
+ auth.value = authkey;
+ form.appendChild(auth);
+
+ var action = document.createElement("input");
+ action.type = "hidden";
+ action.name = "action";
+ action.value = "add_poll_option";
+ form.appendChild(action);
+
+ var threadid = document.createElement("input");
+ threadid.type = "hidden";
+ threadid.name = "threadid";
+ threadid.value = id;
+ form.appendChild(threadid);
+
+ var input = document.createElement("input");
+ input.type = "text";
+ input.name = "new_option";
+ input.size = "50";
+ form.appendChild(input);
+
+ var submit = document.createElement("input");
+ submit.type = "submit";
+ submit.id = "new_submit";
+ submit.value = "Add";
+ form.appendChild(submit);
+ item.appendChild(form);
+ list.appendChild(item);
+}
diff --git a/static/functions/delays.js b/static/functions/delays.js
new file mode 100644
index 0000000..64698da
--- /dev/null
+++ b/static/functions/delays.js
@@ -0,0 +1,60 @@
+//skipfile
+function SetDate() {
+ var amount = $('#amount').raw().value;
+ var denom = $('#denomination').raw().value;
+ switch(denom) {
+ case 'months' :
+ amount *= 4.33333;
+ case 'weeks' :
+ amount *= 7;
+ case 'days' :
+ amount *= 24;
+ case 'hours' :
+ amount *= 60;
+ case 'minutes' :
+ amount *= 60;
+ amount *= 1000; //millis
+ break;
+ }
+
+ var d = new Date;
+ d.setTime(d.getTime() + amount + (d.getTimezoneOffset() * 60 * 1000));
+
+ //YYYY-MM-DD HH:MM:SS
+ var out = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
+
+ $('#date').raw().value = out;
+}
+
+function AddOption() {
+ var list = document.createElement("li");
+ var effects = document.createElement("select");
+ effects.name = "delay_effect[]";
+
+ var enable = document.createElement("option");
+ enable.value = "1";
+ enable.innerHTML = "Enable";
+ effects.appendChild(enable);
+
+ var disable = document.createElement("option");
+ disable.value = "0";
+ disable.innerHTML = "Disable";
+ effects.appendChild(disable);
+ list.appendChild(effects);
+
+ list.innerHTML += " ";
+
+ var options = json.decode($('#delays_json').raw().value);
+ var delays = document.createElement("select");
+ delays.name = "delay[]";
+ for(var option in options) {
+ var delay = document.createElement("option");
+ delay.value = option;
+ delay.innerHTML = options[option][0].long;
+ delays.appendChild(delay);
+ }
+ list.appendChild(delays);
+
+
+ $('#delays_list').raw().appendChild(list);
+}
diff --git a/static/functions/global.js b/static/functions/global.js
new file mode 100644
index 0000000..fd44b4f
--- /dev/null
+++ b/static/functions/global.js
@@ -0,0 +1,94 @@
+function toggleChecks(formElem,masterElem) {
+ if (masterElem.checked) { checked=true; } else { checked=false; }
+ for(s=0; s<$('#'+formElem).raw().elements.length; s++) {
+ if ($('#'+formElem).raw().elements[s].type=="checkbox") {
+ $('#'+formElem).raw().elements[s].checked=checked;
+ }
+ }
+}
+
+//Lightbox stuff
+var lightbox = {
+ init: function (image, size) {
+ if (image.naturalWidth === undefined) {
+ var tmp = document.createElement('img');
+ tmp.style.visibility = 'hidden';
+ tmp.src = image.src;
+ image.naturalWidth = tmp.width;
+ delete tmp;
+ }
+ if (image.naturalWidth > size) {
+ lightbox.box(image);
+ }
+ },
+ box: function (image) {
+ if(image.parentNode.tagName.toUpperCase() != 'A') {
+ $('#lightbox').show().listen('click',lightbox.unbox).raw().innerHTML = '<img src="' + image.src + '" />';
+ $('#curtain').show().listen('click',lightbox.unbox);
+ }
+ },
+ unbox: function (data) {
+ $('#curtain').hide();
+ $('#lightbox').hide().raw().innerHTML = '';
+ }
+};
+
+/* Still some issues
+function caps_check(e) {
+ if (e === undefined) {
+ e = window.event;
+ }
+ if (e.which === undefined) {
+ e.which = e.keyCode;
+ }
+ if (e.which > 47 && e.which < 58) {
+ return;
+ }
+ if ((e.which > 64 && e.which < 91 && !e.shiftKey) || (e.which > 96 && e.which < 123 && e.shiftKey)) {
+ $('#capslock').show();
+ }
+}
+*/
+
+function hexify(str) {
+ str = str.replace(/rgb\(|\)/g, "").split(",");
+ str[0] = parseInt(str[0], 10).toString(16).toLowerCase();
+ str[1] = parseInt(str[1], 10).toString(16).toLowerCase();
+ str[2] = parseInt(str[2], 10).toString(16).toLowerCase();
+ str[0] = (str[0].length == 1) ? '0' + str[0] : str[0];
+ str[1] = (str[1].length == 1) ? '0' + str[1] : str[1];
+ str[2] = (str[2].length == 1) ? '0' + str[2] : str[2];
+ return (str.join(""));
+}
+
+function resize(id) {
+ var textarea = document.getElementById(id);
+ if (textarea.scrollHeight > textarea.clientHeight) {
+ textarea.style.overflowY = 'hidden';
+ textarea.style.height = textarea.scrollHeight + textarea.style.fontSize + 'px';
+ }
+}
+
+//ZIP downloader stuff
+function add_selection() {
+ var selected = $('#formats').raw().options[$('#formats').raw().selectedIndex];
+ if (selected.disabled === false) {
+ var listitem = document.createElement("li");
+ listitem.id = 'list' + selected.value;
+ listitem.innerHTML = ' <input type="hidden" name="list[]" value="'+selected.value+'" /> ' +
+' <span style="float:left;">'+selected.innerHTML+'</span>' +
+' <a href="#" onclick="remove_selection(\''+selected.value+'\');return false;" style="float:right;">[X]</a>' +
+' <br style="clear:all;" />';
+ $('#list').raw().appendChild(listitem);
+ $('#opt' + selected.value).raw().disabled = true;
+ }
+}
+
+function remove_selection(index) {
+ $('#list' + index).remove();
+ $('#opt' + index).raw().disabled='';
+}
+
+function Stats(stat) {
+ ajax.get("ajax.php?action=stats&stat=" + stat);
+}
diff --git a/static/functions/inbox.js b/static/functions/inbox.js
new file mode 100644
index 0000000..602b036
--- /dev/null
+++ b/static/functions/inbox.js
@@ -0,0 +1,16 @@
+//Using this instead of comments as comments has pertty damn strict requirements on the variable names required
+
+function Quick_Preview() {
+ $('#buttons').raw().innerHTML = "<input type='button' value='Editor' onclick='Quick_Edit();' /><input type='submit' value='Send Message!' />";
+ ajax.post("ajax.php?action=preview","messageform", function(response){
+ $('#quickpost').hide();
+ $('#preview').raw().innerHTML = response;
+ $('#preview').show();
+ });
+}
+
+function Quick_Edit() {
+ $('#buttons').raw().innerHTML = "<input type='button' value='Preview' onclick='Quick_Preview();' /><input type='submit' value='Send Message!' />";
+ $('#preview').hide();
+ $('#quickpost').show();
+}
diff --git a/static/functions/iphone.js b/static/functions/iphone.js
new file mode 100644
index 0000000..b19ff31
--- /dev/null
+++ b/static/functions/iphone.js
@@ -0,0 +1,187 @@
+// We had to sacrafice a bit of the beauty of this structure to accomodate OS 1.1
+// If/when we drop OS <2 just switch all onclick events to ontouchend events.
+
+var elements; // Shortcut to handle html elements
+var header = 0; // Used in swap_header
+var method; //The method we use, touchend or onclick
+var active_index;
+var active_url;
+
+// Get ourselves the method based on OS
+method = cookie.get('method');
+if (method === null) {
+ if (document.createTouch) {
+ method = 'touchend';
+ } else {
+ method = 'click';
+ }
+ cookie.set('method',method,365);
+}
+
+// Active
+active_index = 0;
+active_url = cookie.get('lastpage');
+if (active_url === null) {
+ active_url = 'start.php';
+}
+
+// Data sent in HTML comments
+var title = null;
+var back_url = null;
+var back_name = null;
+
+function main () {
+ // Basic html structure utilized for transitions
+ elements = {
+ buttons:[$('#first_button'),$('#second_button')],
+ titles:[$('#first_title'),$('#second_title')],
+ pages:[$('#first_page'),$('#second_page')]
+ };
+
+ // Transform on load
+ elements.pages[1].style.webkitTransform = 'translateX(100%)';
+
+ // Set event handlers
+ elements.titles[0].addEventListener(method, swap_header, false);
+ elements.titles[1].addEventListener(method, swap_header, false);
+
+ elements.buttons[0].addEventListener(method, go_back, false);
+ elements.buttons[1].addEventListener(method, go_back, false);
+
+ elements.pages[0].addEventListener('webkitTransitionEnd', transition_ended, false);
+ Transitions.DEFAULTS.duration = 0.35;
+
+ // Load the content
+ ajax.get(active_url, function (response) {
+ get_headers(response);
+ elements.titles[0].innerHTML = title;
+ elements.pages[0].innerHTML = response;
+ if(back_name){
+ elements.buttons[0].textContent = back_name;
+ }
+ });
+
+ // Hide the address bar
+ setTimeout(function(){window.scrollTo(0, 1);setTimeout(function(){window.scrollTo(0, 0);},0);},500);
+};
+
+// Tap header to swap for ratio
+function swap_header() {
+ //$('#search').style.display = 'block';
+}
+
+// Back button alias
+function go_back() {
+ load(back_url,false);
+}
+
+// Get data from comments
+function get_headers(response) {
+ title = response.match(/\<\!\-\-Title\:(.+?)\-\-\>/i)[1];
+ if(response.match(/\<\!\-\-Back\:(.+?)\:(.+?)\-\-\>/i)) {
+ back_name = response.match(/\<\!\-\-Back\:(.+?)\:(.+?)\-\-\>/i)[1];
+ back_url = response.match(/\<\!\-\-Back\:(.+?)\:(.+?)\-\-\>/i)[2];
+ } else {
+ back_name = null;
+ back_url = null;
+ }
+}
+
+// Load content
+function load(url,forward,formid) {
+ if(forward===undefined) { forward=true; }
+ if (transitions_in_progress && document.createTouch) { return; } //OS 2
+ if (moved_after_touch) { return; }
+ if(formid===undefined){
+ ajax.get(url, function (response) {
+ get_headers(response);
+ transition_to_new_element(response, forward);
+ });
+ cookie.set('lastpage',url,7);
+ } else {
+ ajax.post(url,formid);
+ }
+};
+
+// Moves
+var moved_after_touch = false;
+function touch_started () { moved_after_touch = false; };
+function touch_moved () { moved_after_touch = true; };
+
+// Transitions
+var transitions_in_progress = false;
+function transition_ended () { transitions_in_progress = false; };
+function transition_to_new_element (data, going_forward) {
+ transitions_in_progress = true;
+
+ var from_index = active_index;
+ var to_index = (active_index == 1) ? 0 : 1;
+
+ //Make other page visible
+ //elements.pages[to_index].style.height = '';
+
+ Transitions.DEFAULTS.properties = ['opacity', '-webkit-transform'];
+ var transitions = new Transitions();
+
+ transitions.add({
+ element: elements.titles[from_index],
+ duration: [0.5],
+ properties: ['opacity'],
+ from: [1],
+ to: [0]
+ });
+
+ transitions.add({
+ element : elements.titles[to_index],
+ duration: [0.5],
+ properties: ['opacity'],
+ from : [0],
+ to : [1]
+ });
+
+ transitions.add({
+ element: elements.buttons[from_index],
+ duration: [0.5],
+ properties: ['opacity'],
+ from: [1],
+ to: [0]
+ });
+
+ transitions.add({
+ element : elements.buttons[to_index],
+ duration: [0.5],
+ properties: ['opacity'],
+ from : [0],
+ to : [1]
+ });
+
+ // we only change the transform for the page transitions
+ Transitions.DEFAULTS.properties = ['-webkit-transform'];
+
+ transitions.add({
+ element : elements.pages[from_index],
+ from : ['translateX(0%)'],
+ to : ['translateX(' + ((going_forward) ? -150 : 150) + '%)']
+ });
+
+ transitions.add({
+ element : elements.pages[to_index],
+ from : ['translateX(' + ((going_forward) ? 150 : -150) + '%)'],
+ to : ['translateX(0%)']
+ });
+
+ elements.pages[to_index].textContent = '';
+ elements.pages[to_index].innerHTML = data;
+ elements.titles[to_index].textContent = title;
+ elements.buttons[to_index].textContent = back_name;
+
+ //Hide other page to avoid excess scroll at the bottom
+ //elements.pages[from_index].style.height = '0px';
+
+ active_index = to_index;
+
+ transitions.apply();
+};
+
+// Initate main function
+window.addEventListener('load', main, false);
diff --git a/static/functions/notifications.js b/static/functions/notifications.js
new file mode 100644
index 0000000..df3e4b1
--- /dev/null
+++ b/static/functions/notifications.js
@@ -0,0 +1,5 @@
+function Clear(torrentid) {
+ ajax.get("?action=notify_clearitem&torrentid=" + torrentid + "&auth=" + authkey, function() {
+ $("#torrent" + torrentid).remove();
+ });
+} \ No newline at end of file
diff --git a/static/functions/reportsv2.js b/static/functions/reportsv2.js
new file mode 100644
index 0000000..7226b36
--- /dev/null
+++ b/static/functions/reportsv2.js
@@ -0,0 +1,251 @@
+function ChangeReportType() {
+ ajax.post("reportsv2.php?action=ajax_report","report_table", function (response) {
+ $('#dynamic_form').raw().innerHTML = response;
+ });
+}
+
+function ChangeResolve(reportid) {
+ ajax.get('reportsv2.php?action=ajax_change_resolve&id=' + reportid + '&type=' + $('#resolve_type' + reportid).raw().value + '&categoryid=' + $('#categoryid' + reportid).raw().value, function (response) {
+ var x = json.decode(response);
+ $('#delete' + reportid).raw().checked = (x[0] == '1' ? true : false);
+ if($('#uploaderid' + reportid).raw().value == $('#reporterid' + reportid).raw().value) {
+ $('#warning' + reportid).raw().selectedIndex = 0;
+ $('#upload' + reportid).raw().checked = false;
+ } else {
+ $('#upload' + reportid).raw().checked = (x[1] == '1' ? true : false);
+ $('#warning' + reportid).raw().selectedIndex = x[2];
+ }
+ $('#update_resolve' + reportid).raw().disabled = false;
+ }
+ );
+}
+
+function Load(reportid) {
+ var t = $('#type' + reportid).raw().value;
+ for (var i = 0; i<$('#resolve_type' + reportid).raw().options.length; i++) {
+ if($('#resolve_type' + reportid).raw().options[i].value == t) {
+ $('#resolve_type' + reportid).raw().selectedIndex = i;
+ break;
+ }
+ }
+ //Can't use ChangeResolve() because we need it to block to do the uploader==reporter part
+ ajax.get('reportsv2.php?action=ajax_change_resolve&id=' + reportid + '&type=' + $('#resolve_type' + reportid).raw().value + '&categoryid=' + $('#categoryid' + reportid).raw().value, function (response) {
+ var x = json.decode(response);
+ $('#delete' + reportid).raw().checked = (x[0] == '1' ? true : false);
+ if($('#uploaderid' + reportid).raw().value == $('#reporterid' + reportid).raw().value) {
+ $('#warning' + reportid).raw().selectedIndex = 0;
+ $('#upload' + reportid).raw().checked = false;
+ } else {
+ $('#upload' + reportid).raw().checked = (x[1] == '1' ? true : false);
+ $('#warning' + reportid).raw().selectedIndex = x[2];
+ }
+ $('#update_resolve' + reportid).raw().disabled = false;
+ }
+ );
+}
+
+function ErrorBox(reportid, message) {
+ var div = document.createElement("div");
+ div.id = "#error_box";
+ div.innerHTML = "<table><tr><td class='center'>Message from report " + reportid + ": " + message + "\n <input type='button' value='Hide Errors' onclick='HideErrors();' /></td></tr></table>";
+ $('#all_reports').raw().insertBefore(div, $('#all_reports').raw().firstChild);
+}
+
+function HideErrors() {
+ if($('#error_box')) {
+ $('#error_box').remove();
+ }
+}
+
+function TakeResolve(reportid) {
+ $('#submit_' + reportid).disable();
+ ajax.post("reportsv2.php?action=takeresolve","report_form" + reportid, function (response) {
+ if(response) {
+ ErrorBox(reportid, response);
+ } else {
+ if($('#from_delete' + reportid).results()) {
+ window.location = location.protocol + '//' + location.host + location.pathname + "?id=" + $('#from_delete' + reportid).raw().value;
+ } else {
+ $('#report' + reportid).remove();
+ if($('#dynamic').raw().checked) {
+ NewReport(1);
+ }
+ }
+ }
+ });
+}
+
+function NewReport(q, view, id) {
+ for(var i = 0; i < q; i++) {
+ var url = "reportsv2.php?action=ajax_new_report";
+ if(view) {
+ url += "&view=" + view;
+ }
+ if(id) {
+ url += "&id=" + id;
+ }
+
+ ajax.get(url, function (response) {
+ if(response) {
+ var div = document.createElement("div");
+ div.id = "report";
+ div.innerHTML = response;
+ $('#all_reports').raw().appendChild(div);
+ var id = $('#newreportid').raw().value;
+ Load(id);
+ $('#newreportid').remove();
+ if($('#no_reports').results()) {
+ $('#all_reports').raw().removeChild($('#no_reports').raw());
+ }
+ } else {
+ //No new reports at this time
+ if(!$('#report').results() && !$('#no_reports').results()) {
+ var div = document.createElement("div");
+ div.id = "no_reports";
+ div.innerHTML = "<table><tr><td class='center'><strong>No new reports! \\o/</strong></td></tr></table>";
+ $('#all_reports').raw().appendChild(div);
+ }
+ }
+ });
+ }
+}
+
+function AddMore(view, id) {
+ //Function will add the amount of reports in the input box unless that will take it over 50
+ var x = 10;
+ var a = $('#repop_amount').raw().value;
+ if(a) {
+ if(!isNaN(a) && a <= 50) {
+ x = a;
+ }
+ }
+
+ if(document.getElementsByName("reportid").length + x <= 50) {
+ NewReport(x, view, id);
+ } else {
+ NewReport(50 - document.getElementsByName("reportid").length, view, id);
+ }
+}
+
+function SendPM(reportid) {
+ ajax.post("reportsv2.php?action=ajax_take_pm", "report_form" + reportid, function (response) {
+ if(response) {
+ $('#uploader_pm' + reportid).raw().value = response;
+ } else {
+ $('#uploader_pm' + reportid).raw().value = "";
+ }
+ });
+}
+
+function UpdateComment(reportid) {
+ ajax.post("reportsv2.php?action=ajax_update_comment", 'report_form' + reportid, function (response) {
+ if(response) {
+ alert(response);
+ }
+ });
+}
+
+function GiveBack(id) {
+ if(!id) {
+ var x = document.getElementsByName("reportid");
+ for(i = 0; i < x.length; i++) {
+ /*ajax.get("ajax.php?action=giveback_report&id=" + x[i].value, function (response) {
+ if(response) {
+ alert(response);
+ }
+ });*/
+ $('#report' + x[i].value).remove();
+ }
+ } else {
+ ajax.get("ajax.php?action=giveback_report&id=" + id, function (response) {
+ if(response) {
+ alert(response);
+ }
+ });
+ $('#report' + id).remove();
+ }
+}
+
+function ManualResolve(reportid) {
+ var option = document.createElement("OPTION");
+ option.value = "manual";
+ option.text = "Manual Resolve";
+ $('#resolve_type' + reportid).raw().options.add(option);
+ $('#resolve_type' + reportid).raw().selectedIndex = $('#resolve_type' + reportid).raw().options.length - 1;
+ TakeResolve(reportid);
+}
+
+function Dismiss(reportid) {
+ var option = document.createElement("OPTION");
+ option.value = "dismiss";
+ option.text = "Invalid Report";
+ $('#resolve_type' + reportid).raw().options.add(option);
+ $('#resolve_type' + reportid).raw().selectedIndex = $('#resolve_type' + reportid).raw().options.length - 1;
+ TakeResolve(reportid);
+}
+
+function ClearReport(reportid) {
+ $('#report' + reportid).remove();
+}
+
+function Grab(reportid) {
+ if(reportid) {
+ ajax.get("reportsv2.php?action=ajax_grab_report&id=" + reportid, function (response) {
+ if(response == '1') {
+ $('#grab' + reportid).raw().disabled = true;
+ } else {
+ alert('Grab failed for some reason :/');
+ }
+ });
+ } else {
+ var x = document.getElementsByName("reportid");
+ for(i = 0; i < x.length; i++) {
+ ajax.get("reportsv2.php?action=ajax_grab_report&id=" + x[i].value, function (response) {
+ if(response != '1') {
+ alert("One of those grabs failed, sorry I can't be more useful :P");
+ }
+ });
+ $('#grab' + x[i].value).raw().disabled = true;
+ }
+ }
+}
+
+function MultiResolve() {
+ var multi = document.getElementsByName('multi');
+ for (var j = 0; j < multi.length; j++) {
+ if (multi[j].checked) {
+ TakeResolve(multi[j].id.substring(5));
+ }
+ }
+
+}
+
+function UpdateResolve(reportid) {
+ var newresolve = $('#resolve_type' + reportid).raw().options[$('#resolve_type' + reportid).raw().selectedIndex].value;
+ ajax.get("reportsv2.php?action=ajax_update_resolve&reportid=" + reportid + "&newresolve=" + newresolve + "&categoryid=" + $('#categoryid' + reportid).raw().value, function (response) {
+ $('#update_resolve' + reportid).raw().disabled = true;
+ });
+}
+
+
+function Switch(reportid, torrentid, otherid) {
+ //We want to switch positions of the reported torrent
+ //This entails invalidating the current report and creating a new with the correct preset.
+ Dismiss(reportid);
+
+ var report = new Array();
+ report['auth'] = authkey;
+ report['torrentid'] = otherid
+ report['type'] = $('#type' + reportid).raw().value;
+ report['otherid'] = torrentid
+
+ ajax.post('reportsv2.php?action=ajax_create_report', report, function (response) {
+ //Returns new report ID.
+ if(isNaN(response)) {
+ alert(response);
+ } else {
+ window.location = 'reportsv2.php?view=report&id=' + response;
+ }
+ }
+ );
+}
diff --git a/static/functions/requests.js b/static/functions/requests.js
new file mode 100644
index 0000000..81547ef
--- /dev/null
+++ b/static/functions/requests.js
@@ -0,0 +1,182 @@
+
+function Vote(amount, requestid) {
+ if(typeof amount == 'undefined') {
+ amount = parseInt($('#amount').raw().value);
+ }
+ if(amount == 0) {
+ amount = 20 * 1024 * 1024;
+ }
+
+ var index;
+ var votecount;
+ if(!requestid) {
+ requestid = $('#requestid').raw().value;
+ votecount = $('#votecount').raw();
+ index = false;
+ } else {
+ votecount = $('#vote_count_' + requestid).raw();
+ index = true;
+ }
+
+ ajax.get('requests.php?action=takevote&id=' + requestid + '&auth=' + $('#auth').raw().value + '&amount=' + amount, function (response) {
+ if(response == 'bankrupt') {
+ error_message("You do not have sufficient upload credit to add " + get_size(amount) + " to this request");
+ return;
+ }
+ if(response == 'dupe') {
+ //No increment
+ } else {
+
+ votecount.innerHTML = (parseInt(votecount.innerHTML)) + 1;
+ }
+
+ if(!index) {
+ totalBounty = parseInt($('#total_bounty').raw().value);
+ totalBounty += (amount * (1 - $('#request_tax').raw().value));
+ $('#total_bounty').raw().value = totalBounty;
+ $('#formatted_bounty').raw().innerHTML = get_size(totalBounty);
+
+ save_message("Your vote of " + get_size(amount) + ", adding a " + get_size(amount * (1 - $('#request_tax').raw().value)) + " bounty, has been added");
+ $('#button').raw().disabled = true;
+ } else {
+ save_message("Your vote of " + get_size(amount) + " has been added");
+ }
+ }
+ );
+}
+
+function Calculate() {
+ var mul = (($('#unit').raw().options[$('#unit').raw().selectedIndex].value == 'mb') ? (1024*1024) : (1024*1024*1024));
+ if(($('#amount_box').raw().value * mul) > $('#current_uploaded').raw().value) {
+ $('#new_uploaded').raw().innerHTML = "You can't afford that request!";
+ $('#new_bounty').raw().innerHTML = "0.00 MB";
+ $('#button').raw().disabled = true;
+ } else if(isNaN($('#amount_box').raw().value)
+ || (window.location.search.indexOf('action=new') != -1 && $('#amount_box').raw().value*mul < 100*1024*1024)
+ || (window.location.search.indexOf('action=view') != -1 && $('#amount_box').raw().value*mul < 10*1024*1024)) {
+ $('#new_uploaded').raw().innerHTML = get_size(($('#current_uploaded').raw().value));
+ $('#new_bounty').raw().innerHTML = "0.00 MB";
+ $('#button').raw().disabled = true;
+ } else {
+ $('#button').raw().disabled = false;
+ $('#amount').raw().value = $('#amount_box').raw().value * mul;
+ $('#new_uploaded').raw().innerHTML = get_size(($('#current_uploaded').raw().value) - (mul * $('#amount_box').raw().value));
+ $('#new_ratio').raw().innerHTML = ratio($('#current_uploaded').raw().value - (mul * $('#amount_box').raw().value), $('#current_downloaded').raw().value);
+ $('#new_bounty').raw().innerHTML = get_size(mul * $('#amount_box').raw().value);
+ }
+}
+
+function AddArtistField() {
+ var ArtistCount = document.getElementsByName("artists[]").length;
+ if (ArtistCount >= 100) { return; }
+ var ArtistField = document.createElement("input");
+ ArtistField.type = "text";
+ ArtistField.id = "artist";
+ ArtistField.name = "artists[]";
+ ArtistField.size = 45;
+
+ var ImportanceField = document.createElement("select");
+ ImportanceField.id = "importance";
+ ImportanceField.name = "importance[]";
+ ImportanceField.options[0] = new Option("Main", "1");
+ ImportanceField.options[1] = new Option("Guest", "2");
+ ImportanceField.options[2] = new Option("Remixer", "3");
+
+ var x = $('#artistfields').raw();
+ x.appendChild(document.createElement("br"));
+ x.appendChild(ArtistField);
+ x.appendChild(ImportanceField);
+ ArtistCount++;
+}
+
+function RemoveArtistField() {
+ var ArtistCount = document.getElementsByName("artists[]").length;
+ if (ArtistCount == 1) { return; }
+ var x = $('#artistfields').raw();
+
+ while(x.lastChild.tagName != "INPUT") {
+ x.removeChild(x.lastChild);
+ }
+ x.removeChild(x.lastChild);
+ ArtistCount--;
+}
+
+function Categories() {
+ var cat = $('#categories').raw().options[$('#categories').raw().selectedIndex].value;
+ if(cat == "Music") {
+ $('#artist_tr').show();
+ $('#releasetypes_tr').show();
+ $('#formats_tr').show();
+ $('#bitrates_tr').show();
+ $('#media_tr').show();
+ ToggleLogCue();
+ $('#year_tr').show();
+ $('#cataloguenumber_tr').show();
+ } else if(cat == "Audiobooks" || cat == "Comedy") {
+ $('#year_tr').show();
+ $('#artist_tr').hide();
+ $('#releasetypes_tr').hide();
+ $('#formats_tr').hide();
+ $('#bitrates_tr').hide();
+ $('#media_tr').hide();
+ $('#logcue_tr').hide();
+ $('#cataloguenumber_tr').hide();
+ } else {
+ $('#artist_tr').hide();
+ $('#releasetypes_tr').hide();
+ $('#formats_tr').hide();
+ $('#bitrates_tr').hide();
+ $('#media_tr').hide();
+ $('#logcue_tr').hide();
+ $('#year_tr').hide();
+ $('#cataloguenumber_tr').hide();
+ }
+}
+
+function add_tag() {
+ if ($('#tags').raw().value == "") {
+ $('#tags').raw().value = $('#genre_tags').raw().options[$('#genre_tags').raw().selectedIndex].value;
+ } else if ($('#genre_tags').raw().options[$('#genre_tags').raw().selectedIndex].value == "---") {
+ } else {
+ $('#tags').raw().value = $('#tags').raw().value + ", " + $('#genre_tags').raw().options[$('#genre_tags').raw().selectedIndex].value;
+ }
+}
+
+function Toggle(id, disable) {
+ var arr = document.getElementsByName(id + '[]');
+ var master = $('#toggle_' + id).raw().checked;
+ for (var x in arr) {
+ arr[x].checked = master;
+ if(disable == 1) {
+ arr[x].disabled = master;
+ }
+ }
+
+ if(id == "formats") {
+ ToggleLogCue();
+ }
+}
+
+function ToggleLogCue() {
+ var formats = document.getElementsByName('formats[]');
+ var flac = false;
+
+ if(formats[1].checked) {
+ flac = true;
+ }
+
+ if(flac) {
+ $('#logcue_tr').show();
+ } else {
+ $('#logcue_tr').hide();
+ }
+ ToggleLogScore();
+}
+
+function ToggleLogScore() {
+ if($('#needlog').raw().checked) {
+ $('#minlogscore_span').show();
+ } else {
+ $('#minlogscore_span').hide();
+ }
+}
diff --git a/static/functions/rippy.js b/static/functions/rippy.js
new file mode 100644
index 0000000..cb6c90f
--- /dev/null
+++ b/static/functions/rippy.js
@@ -0,0 +1,15 @@
+function say() {
+ ajax.get("ajax.php?action=rippy", function (message) {
+ if(message) {
+ $('#rippy-says').raw().innerHTML = message;
+ $('#bubble').raw().style.display = "block";
+ } else {
+ $('#bubble').raw().style.display = "none";
+ }
+ }
+ );
+}
+
+function rippyclick() {
+ $('.rippywrap').remove();
+}
diff --git a/static/functions/script_start.js b/static/functions/script_start.js
new file mode 100644
index 0000000..fbc8133
--- /dev/null
+++ b/static/functions/script_start.js
@@ -0,0 +1,285 @@
+"use strict";
+
+/* Prototypes */
+String.prototype.trim = function () {
+ return this.replace(/^\s+|\s+$/g, '');
+};
+
+var listener = {
+ set: function (el,type,callback) {
+ if (document.addEventListener) {
+ el.addEventListener(type, callback, false);
+ } else {
+ // IE hack courtesy of http://blog.stchur.com/2006/10/12/fixing-ies-attachevent-failures
+ var f = function() {
+ callback.call(el);
+ };
+ el.attachEvent('on'+type, f);
+ }
+ }
+};
+
+/* Site wide functions */
+
+// http://www.thefutureoftheweb.com/blog/adddomloadevent
+// retrieved 2010-08-12
+var addDOMLoadEvent=(function(){var e=[],t,s,n,i,o,d=document,w=window,r='readyState',c='onreadystatechange',x=function(){n=1;clearInterval(t);while(i=e.shift())i();if(s)s[c]=''};return function(f){if(n)return f();if(!e[0]){d.addEventListener&&d.addEventListener("DOMContentLoaded",x,false);/*@cc_on@*//*@if(@_win32)d.write("<script id=__ie_onload defer src=//0><\/scr"+"ipt>");s=d.getElementById("__ie_onload");s[c]=function(){s[r]=="complete"&&x()};/*@end@*/if(/WebKit/i.test(navigator.userAgent))t=setInterval(function(){/loaded|complete/.test(d[r])&&x()},10);o=w.onload;w.onload=function(){x();o&&o()}}e.push(f)}})();
+
+//PHP ports
+function isset(variable) {
+ return (typeof(variable) === 'undefined') ? false : true;
+}
+
+function is_array(input) {
+ return typeof(input) === 'object' && input instanceof Array;
+}
+
+function function_exists(function_name) {
+ return (typeof this.window[function_name] === 'function');
+}
+
+function html_entity_decode(str) {
+ var el = document.createElement("div");
+ el.innerHTML = str;
+ for(var i = 0, ret = ''; i < el.childNodes.length; i++) {
+ ret += el.childNodes[i].nodeValue;
+ }
+ return ret;
+}
+
+function get_size(size) {
+ var steps = 0;
+ while(size>=1024) {
+ steps++;
+ size=size/1024;
+ }
+ var ext;
+ switch(steps) {
+ case 1: ext = ' B';
+ break;
+ case 1: ext = ' KB';
+ break;
+ case 2: ext = ' MB';
+ break;
+ case 3: ext = ' GB';
+ break;
+ case 4: ext = ' TB';
+ break;
+ case 5: ext = ' PB';
+ break;
+ case 6: ext = ' EB';
+ break;
+ case 7: ext = ' ZB';
+ break;
+ case 8: ext = ' EB';
+ break;
+ default: "0.00 MB";
+ }
+ return (size.toFixed(2) + ext);
+}
+
+function get_ratio_color(ratio) {
+ if (ratio < 0.1) { return 'r00'; }
+ if (ratio < 0.2) { return 'r01'; }
+ if (ratio < 0.3) { return 'r02'; }
+ if (ratio < 0.4) { return 'r03'; }
+ if (ratio < 0.5) { return 'r04'; }
+ if (ratio < 0.6) { return 'r05'; }
+ if (ratio < 0.7) { return 'r06'; }
+ if (ratio < 0.8) { return 'r07'; }
+ if (ratio < 0.9) { return 'r08'; }
+ if (ratio < 1) { return 'r09'; }
+ if (ratio < 2) { return 'r10'; }
+ if (ratio < 5) { return 'r20'; }
+ return 'r50';
+}
+
+function ratio(dividend, divisor, color) {
+ if(!color) {
+ color = true;
+ }
+ if(divisor == 0 && dividend == 0) {
+ return '--';
+ } else if(divisor == 0) {
+ return '<span class="r99">∞</span>';
+ } else if(dividend == 0 && divisor > 0) {
+ return '<span class="r00">-∞</span>';
+ }
+ var rat = ((dividend/divisor)-0.005).toFixed(2); //Subtract .005 to floor to 2 decimals
+ if(color) {
+ var col = get_ratio_color(rat);
+ if(col) {
+ rat = '<span class="'+col+'">'+rat+'</span>';
+ }
+ }
+ return rat;
+}
+
+
+function save_message(message) {
+ var messageDiv = document.createElement("div");
+ messageDiv.className = "save_message";
+ messageDiv.innerHTML = message;
+ $("#content").raw().insertBefore(messageDiv,$("#content").raw().firstChild);
+}
+
+function error_message(message) {
+ var messageDiv = document.createElement("div");
+ messageDiv.className = "error_message";
+ messageDiv.innerHTML = message;
+ $("#content").raw().insertBefore(messageDiv,$("#content").raw().firstChild);
+}
+
+//returns key if true, and false if false better than the php funciton
+function in_array(needle, haystack, strict) {
+ if (strict === undefined) {
+ strict = false;
+ }
+ for (var key in haystack) {
+ if ((haystack[key] == needle && strict === false) || haystack[key] === needle) {
+ return true;
+ }
+ }
+ return false;
+}
+
+function array_search(needle, haystack, strict) {
+ if (strict === undefined) {
+ strict = false;
+ }
+ for (var key in haystack) {
+ if ((strict === false && haystack[key] == needle) || haystack[key] === needle) {
+ return key;
+ }
+ }
+ return false;
+}
+
+var util = function (selector, context) {
+ return new util.fn.init(selector, context);
+}
+
+
+util.fn = util.prototype = {
+ objects: new Array(),
+ init: function (selector, context) {
+ if(typeof(selector) == 'object') {
+ this.objects[0] = selector;
+ } else {
+ this.objects = Sizzle(selector, context);
+ }
+ return this;
+ },
+ results: function () {
+ return this.objects.length;
+ },
+ show: function () {
+ return this.remove_class('hidden');
+ },
+ hide: function () {
+ return this.add_class('hidden');
+ },
+ toggle: function () {
+ //Should we interate and invert all entries, or just go by the first?
+ if (!in_array('hidden', this.objects[0].className.split(' '))) {
+ this.add_class('hidden');
+ } else {
+ this.remove_class('hidden');
+ }
+ return this;
+ },
+ listen: function (event, callback) {
+ for (var i=0,il=this.objects.length;i<il;i++) {
+ var object = this.objects[i];
+ if (document.addEventListener) {
+ object.addEventListener(event, callback, false);
+ } else {
+ object.attachEvent('on' + event, callback);
+ }
+ }
+ return this;
+ },
+ remove: function () {
+ for (var i=0,il=this.objects.length;i<il;i++) {
+ var object = this.objects[i];
+ object.parentNode.removeChild(object);
+ }
+ return this;
+ },
+ add_class: function (class_name) {
+ for (var i=0,il=this.objects.length;i<il;i++) {
+ var object = this.objects[i];
+ if (object.className === '') {
+ object.className = class_name;
+ } else if (!in_array(class_name, object.className.split(' '))) {
+ object.className = object.className + ' ' + class_name;
+ }
+ }
+ return this;
+ },
+ remove_class: function (class_name) {
+ for (var i=0,il=this.objects.length;i<il;i++) {
+ var object = this.objects[i];
+ var classes = object.className.split(' ');
+ var result = array_search(class_name, classes)
+ if (result === false) {
+ //return this;
+ }
+ delete classes[result];
+ object.className = classes.join(' ');
+ }
+ return this;
+ },
+ has_class: function(class_name) {
+ for (var i=0,il=this.objects.length;i<il;i++) {
+ var object = this.objects[i];
+ var classes = object.className.split(' ');
+ if(array_search(class_name, classes)) {
+ return true;
+ }
+ }
+ return false;
+ },
+ disable : function () {
+ for (var i=0,il=this.objects.length;i<il;i++) {
+ this.objects[i].disabled = true;
+ }
+ return this;
+ },
+ html : function (html) {
+ for (var i=0,il=this.objects.length;i<il;i++) {
+ this.objects[i].innerHTML = html;
+ }
+ return this;
+ },
+ raw: function (number) {
+ if (number === undefined) {
+ number = 0;
+ }
+ return this.objects[number];
+ },
+ nextElementSibling: function () {
+ here = this.objects[0];
+ if (here.nextElementSibling) {
+ return $(here.nextElementSibling);
+ }
+ do {
+ here = here.nextSibling;
+ } while (here.nodeType != 1);
+ return $(here);
+ },
+ previousElementSibling: function () {
+ here = this.objects[0];
+ if (here.previousElementSibling) {
+ return $(here.previousElementSibling);
+ }
+ do {
+ here = here.nextSibling;
+ } while (here.nodeType != 1);
+ return $(here);
+ }
+}
+
+
+util.fn.init.prototype = util.fn;
+var $ = util;
diff --git a/static/functions/sizzle.js b/static/functions/sizzle.js
new file mode 100644
index 0000000..38f208d
--- /dev/null
+++ b/static/functions/sizzle.js
@@ -0,0 +1,7 @@
+/*
+ * Sizzle CSS Selector Engine - v1.0
+ * Copyright 2009, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ * More information: http://sizzlejs.com/
+ */
+(function(){var q=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,i=0,d=Object.prototype.toString,o=false;var b=function(E,u,B,w){B=B||[];var e=u=u||document;if(u.nodeType!==1&&u.nodeType!==9){return[]}if(!E||typeof E!=="string"){return B}var C=[],D,z,H,G,A,t,s=true,x=p(u);q.lastIndex=0;while((D=q.exec(E))!==null){C.push(D[1]);if(D[2]){t=RegExp.rightContext;break}}if(C.length>1&&j.exec(E)){if(C.length===2&&f.relative[C[0]]){z=g(C[0]+C[1],u)}else{z=f.relative[C[0]]?[u]:b(C.shift(),u);while(C.length){E=C.shift();if(f.relative[E]){E+=C.shift()}z=g(E,z)}}}else{if(!w&&C.length>1&&u.nodeType===9&&!x&&f.match.ID.test(C[0])&&!f.match.ID.test(C[C.length-1])){var I=b.find(C.shift(),u,x);u=I.expr?b.filter(I.expr,I.set)[0]:I.set[0]}if(u){var I=w?{expr:C.pop(),set:a(w)}:b.find(C.pop(),C.length===1&&(C[0]==="~"||C[0]==="+")&&u.parentNode?u.parentNode:u,x);z=I.expr?b.filter(I.expr,I.set):I.set;if(C.length>0){H=a(z)}else{s=false}while(C.length){var v=C.pop(),y=v;if(!f.relative[v]){v=""}else{y=C.pop()}if(y==null){y=u}f.relative[v](H,y,x)}}else{H=C=[]}}if(!H){H=z}if(!H){throw"Syntax error, unrecognized expression: "+(v||E)}if(d.call(H)==="[object Array]"){if(!s){B.push.apply(B,H)}else{if(u&&u.nodeType===1){for(var F=0;H[F]!=null;F++){if(H[F]&&(H[F]===true||H[F].nodeType===1&&h(u,H[F]))){B.push(z[F])}}}else{for(var F=0;H[F]!=null;F++){if(H[F]&&H[F].nodeType===1){B.push(z[F])}}}}}else{a(H,B)}if(t){b(t,e,B,w);b.uniqueSort(B)}return B};b.uniqueSort=function(s){if(c){o=false;s.sort(c);if(o){for(var e=1;e<s.length;e++){if(s[e]===s[e-1]){s.splice(e--,1)}}}}};b.matches=function(e,s){return b(e,null,null,s)};b.find=function(y,e,z){var x,v;if(!y){return[]}for(var u=0,t=f.order.length;u<t;u++){var w=f.order[u],v;if((v=f.match[w].exec(y))){var s=RegExp.leftContext;if(s.substr(s.length-1)!=="\\"){v[1]=(v[1]||"").replace(/\\/g,"");x=f.find[w](v,e,z);if(x!=null){y=y.replace(f.match[w],"");break}}}}if(!x){x=e.getElementsByTagName("*")}return{set:x,expr:y}};b.filter=function(B,A,E,u){var t=B,G=[],y=A,w,e,x=A&&A[0]&&p(A[0]);while(B&&A.length){for(var z in f.filter){if((w=f.match[z].exec(B))!=null){var s=f.filter[z],F,D;e=false;if(y==G){G=[]}if(f.preFilter[z]){w=f.preFilter[z](w,y,E,G,u,x);if(!w){e=F=true}else{if(w===true){continue}}}if(w){for(var v=0;(D=y[v])!=null;v++){if(D){F=s(D,w,v,y);var C=u^!!F;if(E&&F!=null){if(C){e=true}else{y[v]=false}}else{if(C){G.push(D);e=true}}}}}if(F!==undefined){if(!E){y=G}B=B.replace(f.match[z],"");if(!e){return[]}break}}}if(B==t){if(e==null){throw"Syntax error, unrecognized expression: "+B}else{break}}t=B}return y};var f=b.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(e){return e.getAttribute("href")}},relative:{"+":function(y,e,x){var v=typeof e==="string",z=v&&!/\W/.test(e),w=v&&!z;if(z&&!x){e=e.toUpperCase()}for(var u=0,t=y.length,s;u<t;u++){if((s=y[u])){while((s=s.previousSibling)&&s.nodeType!==1){}y[u]=w||s&&s.nodeName===e?s||false:s===e}}if(w){b.filter(e,y,true)}},">":function(x,s,y){var v=typeof s==="string";if(v&&!/\W/.test(s)){s=y?s:s.toUpperCase();for(var t=0,e=x.length;t<e;t++){var w=x[t];if(w){var u=w.parentNode;x[t]=u.nodeName===s?u:false}}}else{for(var t=0,e=x.length;t<e;t++){var w=x[t];if(w){x[t]=v?w.parentNode:w.parentNode===s}}if(v){b.filter(s,x,true)}}},"":function(u,s,w){var t=i++,e=r;if(!/\W/.test(s)){var v=s=w?s:s.toUpperCase();e=n}e("parentNode",s,t,u,v,w)},"~":function(u,s,w){var t=i++,e=r;if(typeof s==="string"&&!/\W/.test(s)){var v=s=w?s:s.toUpperCase();e=n}e("previousSibling",s,t,u,v,w)}},find:{ID:function(s,t,u){if(typeof t.getElementById!=="undefined"&&!u){var e=t.getElementById(s[1]);return e?[e]:[]}},NAME:function(t,w,x){if(typeof w.getElementsByName!=="undefined"){var s=[],v=w.getElementsByName(t[1]);for(var u=0,e=v.length;u<e;u++){if(v[u].getAttribute("name")===t[1]){s.push(v[u])}}return s.length===0?null:s}},TAG:function(e,s){return s.getElementsByTagName(e[1])}},preFilter:{CLASS:function(u,s,t,e,x,y){u=" "+u[1].replace(/\\/g,"")+" ";if(y){return u}for(var v=0,w;(w=s[v])!=null;v++){if(w){if(x^(w.className&&(" "+w.className+" ").indexOf(u)>=0)){if(!t){e.push(w)}}else{if(t){s[v]=false}}}}return false},ID:function(e){return e[1].replace(/\\/g,"")},TAG:function(s,e){for(var t=0;e[t]===false;t++){}return e[t]&&p(e[t])?s[1]:s[1].toUpperCase()},CHILD:function(e){if(e[1]=="nth"){var s=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(e[2]=="even"&&"2n"||e[2]=="odd"&&"2n+1"||!/\D/.test(e[2])&&"0n+"+e[2]||e[2]);e[2]=(s[1]+(s[2]||1))-0;e[3]=s[3]-0}e[0]=i++;return e},ATTR:function(v,s,t,e,w,x){var u=v[1].replace(/\\/g,"");if(!x&&f.attrMap[u]){v[1]=f.attrMap[u]}if(v[2]==="~="){v[4]=" "+v[4]+" "}return v},PSEUDO:function(v,s,t,e,w){if(v[1]==="not"){if(q.exec(v[3]).length>1||/^\w/.test(v[3])){v[3]=b(v[3],null,null,s)}else{var u=b.filter(v[3],s,t,true^w);if(!t){e.push.apply(e,u)}return false}}else{if(f.match.POS.test(v[0])||f.match.CHILD.test(v[0])){return true}}return v},POS:function(e){e.unshift(true);return e}},filters:{enabled:function(e){return e.disabled===false&&e.type!=="hidden"},disabled:function(e){return e.disabled===true},checked:function(e){return e.checked===true},selected:function(e){e.parentNode.selectedIndex;return e.selected===true},parent:function(e){return !!e.firstChild},empty:function(e){return !e.firstChild},has:function(t,s,e){return !!b(e[3],t).length},header:function(e){return/h\d/i.test(e.nodeName)},text:function(e){return"text"===e.type},radio:function(e){return"radio"===e.type},checkbox:function(e){return"checkbox"===e.type},file:function(e){return"file"===e.type},password:function(e){return"password"===e.type},submit:function(e){return"submit"===e.type},image:function(e){return"image"===e.type},reset:function(e){return"reset"===e.type},button:function(e){return"button"===e.type||e.nodeName.toUpperCase()==="BUTTON"},input:function(e){return/input|select|textarea|button/i.test(e.nodeName)}},setFilters:{first:function(s,e){return e===0},last:function(t,s,e,u){return s===u.length-1},even:function(s,e){return e%2===0},odd:function(s,e){return e%2===1},lt:function(t,s,e){return s<e[3]-0},gt:function(t,s,e){return s>e[3]-0},nth:function(t,s,e){return e[3]-0==s},eq:function(t,s,e){return e[3]-0==s}},filter:{PSEUDO:function(w,s,t,x){var e=s[1],u=f.filters[e];if(u){return u(w,t,s,x)}else{if(e==="contains"){return(w.textContent||w.innerText||"").indexOf(s[3])>=0}else{if(e==="not"){var v=s[3];for(t=0,l=v.length;t<l;t++){if(v[t]===w){return false}}return true}}}},CHILD:function(e,u){var x=u[1],s=e;switch(x){case"only":case"first":while((s=s.previousSibling)){if(s.nodeType===1){return false}}if(x=="first"){return true}s=e;case"last":while((s=s.nextSibling)){if(s.nodeType===1){return false}}return true;case"nth":var t=u[2],A=u[3];if(t==1&&A==0){return true}var w=u[0],z=e.parentNode;if(z&&(z.sizcache!==w||!e.nodeIndex)){var v=0;for(s=z.firstChild;s;s=s.nextSibling){if(s.nodeType===1){s.nodeIndex=++v}}z.sizcache=w}var y=e.nodeIndex-A;if(t==0){return y==0}else{return(y%t==0&&y/t>=0)}}},ID:function(s,e){return s.nodeType===1&&s.getAttribute("id")===e},TAG:function(s,e){return(e==="*"&&s.nodeType===1)||s.nodeName===e},CLASS:function(s,e){return(" "+(s.className||s.getAttribute("class"))+" ").indexOf(e)>-1},ATTR:function(w,u){var t=u[1],e=f.attrHandle[t]?f.attrHandle[t](w):w[t]!=null?w[t]:w.getAttribute(t),x=e+"",v=u[2],s=u[4];return e==null?v==="!=":v==="="?x===s:v==="*="?x.indexOf(s)>=0:v==="~="?(" "+x+" ").indexOf(s)>=0:!s?x&&e!==false:v==="!="?x!=s:v==="^="?x.indexOf(s)===0:v==="$="?x.substr(x.length-s.length)===s:v==="|="?x===s||x.substr(0,s.length+1)===s+"-":false},POS:function(v,s,t,w){var e=s[2],u=f.setFilters[e];if(u){return u(v,t,s,w)}}}};var j=f.match.POS;for(var m in f.match){f.match[m]=new RegExp(f.match[m].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var a=function(s,e){s=Array.prototype.slice.call(s,0);if(e){e.push.apply(e,s);return e}return s};try{Array.prototype.slice.call(document.documentElement.childNodes,0)}catch(k){a=function(v,u){var s=u||[];if(d.call(v)==="[object Array]"){Array.prototype.push.apply(s,v)}else{if(typeof v.length==="number"){for(var t=0,e=v.length;t<e;t++){s.push(v[t])}}else{for(var t=0;v[t];t++){s.push(v[t])}}}return s}}var c;if(document.documentElement.compareDocumentPosition){c=function(s,e){var t=s.compareDocumentPosition(e)&4?-1:s===e?0:1;if(t===0){o=true}return t}}else{if("sourceIndex" in document.documentElement){c=function(s,e){var t=s.sourceIndex-e.sourceIndex;if(t===0){o=true}return t}}else{if(document.createRange){c=function(u,s){var t=u.ownerDocument.createRange(),e=s.ownerDocument.createRange();t.selectNode(u);t.collapse(true);e.selectNode(s);e.collapse(true);var v=t.compareBoundaryPoints(Range.START_TO_END,e);if(v===0){o=true}return v}}}}(function(){var s=document.createElement("div"),t="script"+(new Date).getTime();s.innerHTML="<a name='"+t+"'/>";var e=document.documentElement;e.insertBefore(s,e.firstChild);if(!!document.getElementById(t)){f.find.ID=function(v,w,x){if(typeof w.getElementById!=="undefined"&&!x){var u=w.getElementById(v[1]);return u?u.id===v[1]||typeof u.getAttributeNode!=="undefined"&&u.getAttributeNode("id").nodeValue===v[1]?[u]:undefined:[]}};f.filter.ID=function(w,u){var v=typeof w.getAttributeNode!=="undefined"&&w.getAttributeNode("id");return w.nodeType===1&&v&&v.nodeValue===u}}e.removeChild(s);e=s=null})();(function(){var e=document.createElement("div");e.appendChild(document.createComment(""));if(e.getElementsByTagName("*").length>0){f.find.TAG=function(s,w){var v=w.getElementsByTagName(s[1]);if(s[1]==="*"){var u=[];for(var t=0;v[t];t++){if(v[t].nodeType===1){u.push(v[t])}}v=u}return v}}e.innerHTML="<a href='#'></a>";if(e.firstChild&&typeof e.firstChild.getAttribute!=="undefined"&&e.firstChild.getAttribute("href")!=="#"){f.attrHandle.href=function(s){return s.getAttribute("href",2)}}e=null})();if(document.querySelectorAll){(function(){var e=b,t=document.createElement("div");t.innerHTML="<p class='TEST'></p>";if(t.querySelectorAll&&t.querySelectorAll(".TEST").length===0){return}b=function(x,w,u,v){w=w||document;if(!v&&w.nodeType===9&&!p(w)){try{return a(w.querySelectorAll(x),u)}catch(y){}}return e(x,w,u,v)};for(var s in e){b[s]=e[s]}t=null})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var e=document.createElement("div");e.innerHTML="<div class='test e'></div><div class='test'></div>";if(e.getElementsByClassName("e").length===0){return}e.lastChild.className="e";if(e.getElementsByClassName("e").length===1){return}f.order.splice(1,0,"CLASS");f.find.CLASS=function(s,t,u){if(typeof t.getElementsByClassName!=="undefined"&&!u){return t.getElementsByClassName(s[1])}};e=null})()}function n(s,x,w,B,y,A){var z=s=="previousSibling"&&!A;for(var u=0,t=B.length;u<t;u++){var e=B[u];if(e){if(z&&e.nodeType===1){e.sizcache=w;e.sizset=u}e=e[s];var v=false;while(e){if(e.sizcache===w){v=B[e.sizset];break}if(e.nodeType===1&&!A){e.sizcache=w;e.sizset=u}if(e.nodeName===x){v=e;break}e=e[s]}B[u]=v}}}function r(s,x,w,B,y,A){var z=s=="previousSibling"&&!A;for(var u=0,t=B.length;u<t;u++){var e=B[u];if(e){if(z&&e.nodeType===1){e.sizcache=w;e.sizset=u}e=e[s];var v=false;while(e){if(e.sizcache===w){v=B[e.sizset];break}if(e.nodeType===1){if(!A){e.sizcache=w;e.sizset=u}if(typeof x!=="string"){if(e===x){v=true;break}}else{if(b.filter(x,[e]).length>0){v=e;break}}}e=e[s]}B[u]=v}}}var h=document.compareDocumentPosition?function(s,e){return s.compareDocumentPosition(e)&16}:function(s,e){return s!==e&&(s.contains?s.contains(e):true)};var p=function(e){return e.nodeType===9&&e.documentElement.nodeName!=="HTML"||!!e.ownerDocument&&e.ownerDocument.documentElement.nodeName!=="HTML"};var g=function(e,y){var u=[],v="",w,t=y.nodeType?[y]:y;while((w=f.match.PSEUDO.exec(e))){v+=w[0];e=e.replace(f.match.PSEUDO,"")}e=f.relative[e]?e+"*":e;for(var x=0,s=t.length;x<s;x++){b(e,t[x],u)}return b.filter(v,u)};window.Sizzle=b})();
diff --git a/static/functions/staffpm.js b/static/functions/staffpm.js
new file mode 100644
index 0000000..185b24b
--- /dev/null
+++ b/static/functions/staffpm.js
@@ -0,0 +1,110 @@
+function SetMessage() {
+ var id = document.getElementById('common_answers_select').value;
+
+ ajax.get("?action=get_response&plain=1&id=" + id, function (data) {
+ $('#quickpost').raw().value = data;
+ $('#common_answers').hide();
+ });
+}
+
+function UpdateMessage() {
+ var id = document.getElementById('common_answers_select').value;
+
+ ajax.get("?action=get_response&plain=0&id=" + id, function (data) {
+ $('#common_answers_body').raw().innerHTML = data;
+ $('#first_common_response').remove()
+ });
+}
+
+function SaveMessage(id) {
+ var ajax_message = 'ajax_message_' + id;
+ var ToPost = [];
+
+ ToPost['id'] = id;
+ ToPost['name'] = document.getElementById('response_name_' + id).value;
+ ToPost['message'] = document.getElementById('response_message_' + id).value;
+
+ ajax.post("?action=edit_response", ToPost, function (data) {
+ if (data == '1') {
+ document.getElementById(ajax_message).textContent = 'Response successfully created.';
+ } else if (data == '2') {
+ document.getElementById(ajax_message).textContent = 'Response successfully edited.';
+ } else {
+ document.getElementById(ajax_message).textContent = 'Something went wrong.';
+ }
+ $('#' + ajax_message).show();
+ var t = setTimeout("$('#" + ajax_message + "').hide()", 2000);
+ }
+ );
+}
+
+function DeleteMessage(id) {
+ var div = '#response_' + id;
+ var ajax_message = 'ajax_message_' + id;
+
+ var ToPost = [];
+ ToPost['id'] = id;
+
+ ajax.post("?action=delete_response", ToPost, function (data) {
+ $(div).hide();
+ if (data == '1') {
+ document.getElementById(ajax_message).textContent = 'Response successfully deleted.';
+ } else {
+ document.getElementById(ajax_message).textContent = 'Something went wrong.';
+ }
+ $('#'+ajax_message).show();
+ var t = setTimeout("$('#" + ajax_message + "').hide()", 2000);
+ });
+}
+
+function Assign() {
+ var ToPost = [];
+ ToPost['assign'] = document.getElementById('assign_to').value;
+ ToPost['convid'] = document.getElementById('convid').value;
+
+ ajax.post("?action=assign", ToPost, function (data) {
+ if (data == '1') {
+ document.getElementById('ajax_message').textContent = 'Conversation successfully assigned.';
+ } else {
+ document.getElementById('ajax_message').textContent = 'Something went wrong.';
+ }
+ $('#ajax_message').show();
+ var t = setTimeout("$('#ajax_message').hide()", 2000);
+ });
+}
+
+function PreviewResponse(id) {
+ var div = '#response_div_'+id;
+ if ($(div).has_class('hidden')) {
+ var ToPost = [];
+ ToPost['message'] = document.getElementById('response_message_'+id).value;
+ ajax.post('?action=preview', ToPost, function (data) {
+ document.getElementById('response_div_'+id).innerHTML = data;
+ $(div).toggle();
+ $('#response_message_'+id).toggle();
+ });
+ } else {
+ $(div).toggle();
+ $('#response_message_'+id).toggle();
+ }
+}
+
+function PreviewMessage() {
+ if ($('#preview').has_class('hidden')) {
+ var ToPost = [];
+ ToPost['message'] = document.getElementById('quickpost').value;
+ ajax.post('?action=preview', ToPost, function (data) {
+ document.getElementById('preview').innerHTML = data;
+ $('#preview').toggle();
+ $('#quickpost').toggle();
+ });
+ } else {
+ $('#preview').toggle();
+ $('#quickpost').toggle();
+ }
+}
+
+
+
+
+
diff --git a/static/functions/subscriptions.js b/static/functions/subscriptions.js
new file mode 100644
index 0000000..b39bdf0
--- /dev/null
+++ b/static/functions/subscriptions.js
@@ -0,0 +1,21 @@
+function Subscribe(topicid) {
+ ajax.get("userhistory.php?action=thread_subscribe&topicid=" + topicid + "&auth=" + authkey, function() {
+ if($("#subscribelink" + topicid).raw().firstChild.nodeValue.substr(1,1) == 'U') {
+ $("#subscribelink" + topicid).raw().firstChild.nodeValue = "[Subscribe]";
+ } else {
+ $("#subscribelink" + topicid).raw().firstChild.nodeValue = "[Unsubscribe]";
+ }
+ });
+}
+
+function Collapse() {
+ var hide = ($('#collapselink').raw().innerHTML.substr(0,1) == 'H' ? 1 : 0);
+ if($('.row').results() > 0) {
+ $('.row').toggle();
+ }
+ if(hide) {
+ $('#collapselink').raw().innerHTML = 'Show post bodies';
+ } else {
+ $('#collapselink').raw().innerHTML = 'Hide post bodies';
+ }
+}
diff --git a/static/functions/torrent.js b/static/functions/torrent.js
new file mode 100644
index 0000000..0ca15f4
--- /dev/null
+++ b/static/functions/torrent.js
@@ -0,0 +1,172 @@
+function ChangeCategory(catid) {
+ if(catid == 1) {
+ $('#split_releasetype').show();
+ $('#split_artist').show();
+ $('#split_year').show();
+ } else if(catid == 4 || catid == 6) {
+ $('#split_releasetype').hide();
+ $('#split_year').show();
+ $('#split_artist').hide();
+ } else {
+ $('#split_releasetype').hide();
+ $('#split_artist').hide();
+ $('#split_year').hide();
+ }
+}
+
+function ArtistManager() {
+ var GroupID = window.location.search.match(/[?&]id=(\d+)/);
+ if(typeof GroupID == 'undefined') {
+ return;
+ } else {
+ GroupID = GroupID[1];
+ }
+ var ArtistList;
+ if(!(ArtistList = $('#artist_list').raw())) {
+ return false;
+ } else if($('#artistmanager').raw()) {
+ $('#artistmanager').toggle();
+ $('#artist_list').toggle();
+ } else {
+ MainArtistCount = 0;
+ var elArtistManager = document.createElement('div');
+ elArtistManager.id = 'artistmanager';
+
+ var elArtistList = ArtistList.cloneNode(true);
+ elArtistList.id = 'artistmanager_list';
+ for(var i=0, importance = 1; i<elArtistList.children.length; i++) {
+ if(elArtistList.children[i].children[0].tagName.toUpperCase() == 'A') {
+ var ArtistID = elArtistList.children[i].children[0].href.match(/[?&]id=(\d+)/)[1];
+ var elBox = document.createElement('input');
+ elBox.type = 'checkbox';
+ elBox.id = 'artistmanager_box'+(i-importance+1);
+ elBox.name = 'artistmanager_box';
+ elBox.value = importance+','+ArtistID;
+ elBox.onclick = function(e) { SelectArtist(e,this); };
+ elArtistList.children[i].insertBefore(elBox, elArtistList.children[i].children[0]);
+ if(importance == 1) {
+ MainArtistCount++;
+ }
+ } else {
+ importance++;
+ }
+ }
+ elArtistManager.appendChild(elArtistList);
+
+ var elArtistForm = document.createElement('form');
+ elArtistForm.id = 'artistmanager_form';
+ elArtistForm.method = 'post';
+ var elGroupID = document.createElement('input');
+ elGroupID.type = 'hidden';
+ elGroupID.name = 'groupid';
+ elGroupID.value = GroupID;
+ elArtistForm.appendChild(elGroupID);
+ var elAction = document.createElement('input');
+ elAction.type = 'hidden';
+ elAction.name = 'manager_action';
+ elAction.id = 'manager_action';
+ elAction.value = 'manage';
+ elArtistForm.appendChild(elAction);
+ var elAction = document.createElement('input');
+ elAction.type = 'hidden';
+ elAction.name = 'action';
+ elAction.value = 'manage_artists';
+ elArtistForm.appendChild(elAction);
+ var elAuth = document.createElement('input');
+ elAuth.type = 'hidden';
+ elAuth.name = 'auth';
+ elAuth.value = authkey;
+ elArtistForm.appendChild(elAuth);
+ var elSelection = document.createElement('input');
+ elSelection.type = 'hidden';
+ elSelection.id = 'artists_selection';
+ elSelection.name = 'artists';
+ elArtistForm.appendChild(elSelection);
+
+ var elSubmitDiv = document.createElement('div');
+ var elImportance = document.createElement('select');
+ elImportance.name = 'importance';
+ elImportance.id = 'artists_importance';
+ var elOpt = document.createElement('option');
+ elOpt.value = 1;
+ elOpt.innerHTML = 'Main artist';
+ elImportance.appendChild(elOpt);
+ elOpt = document.createElement('option');
+ elOpt.value = 2;
+ elOpt.innerHTML = 'Guest artist';
+ elImportance.appendChild(elOpt);
+ elOpt = document.createElement('option');
+ elOpt.value = 3;
+ elOpt.innerHTML = 'Remixer';
+ elImportance.appendChild(elOpt);
+ elSubmitDiv.appendChild(elImportance);
+ elSubmitDiv.appendChild(document.createTextNode(' '));
+
+ elSubmitDiv.className = 'body';
+ var elSubmit = document.createElement('input');
+ elSubmit.type = 'button';
+ elSubmit.value = 'Update';
+ elSubmit.onclick = ArtistManagerSubmit;
+ elSubmitDiv.appendChild(elSubmit);
+ elSubmitDiv.appendChild(document.createTextNode(' '));
+
+ var elDelButton = document.createElement('input');
+ elDelButton.type = 'button';
+ elDelButton.value = 'Delete';
+ elDelButton.onclick = ArtistManagerDelete;
+ elSubmitDiv.appendChild(elDelButton);
+
+ elArtistForm.appendChild(elSubmitDiv);
+ elArtistManager.appendChild(elArtistForm);
+ ArtistList.parentNode.appendChild(elArtistManager);
+ $('#artist_list').hide();
+ }
+}
+
+function SelectArtist(e,obj) {
+ if(window.event) {
+ e = window.event;
+ }
+ EndBox = Number(obj.id.substr(17));
+ if(!e.shiftKey || typeof StartBox == 'undefined') {
+ StartBox = Number(obj.id.substr(17));
+ }
+ Dir = (EndBox > StartBox ? 1 : -1);
+ var checked = obj.checked;
+ for(var i = StartBox; i != EndBox; i += Dir) {
+ var key, importance = obj.value.substr(0,1), id = obj.value.substr(2);
+ $('#artistmanager_box'+i).raw().checked = checked;
+ }
+ StartBox = Number(obj.id.substr(17));
+}
+
+function ArtistManagerSubmit() {
+ var Selection = new Array();
+ var MainSelectionCount = 0;
+ for(var i = 0, boxes = $('[name="artistmanager_box"]'); boxes.raw(i); i++) {
+ if(boxes.raw(i).checked) {
+ Selection.push(boxes.raw(i).value.substr(2));
+ if(boxes.raw(i).value.substr(0,1) == '1') {
+ MainSelectionCount++;
+ }
+ }
+ }
+ if(Selection.length == 0 || ($('#manager_action').raw().value == 'delete' && !confirm('Are you sure you want to delete '+Selection.length+' artists from this group?'))) {
+ return;
+ }
+ $('#artists_selection').raw().value = Selection.join(',');
+ if(($('#artists_importance').raw().value != 1 || $('#manager_action').raw().value == 'delete') && MainSelectionCount == MainArtistCount) {
+ if(!$('.error_message').raw()) {
+ error_message('All groups need to have at least one main artist.');
+ }
+ $('.error_message').raw().scrollIntoView();
+ return;
+ }
+ $('#artistmanager_form').raw().submit();
+}
+
+function ArtistManagerDelete() {
+ $('#manager_action').raw().value = 'delete';
+ ArtistManagerSubmit();
+ $('#manager_action').raw().value = 'manage';
+}
diff --git a/static/functions/transitions.js b/static/functions/transitions.js
new file mode 100644
index 0000000..31f7326
--- /dev/null
+++ b/static/functions/transitions.js
@@ -0,0 +1,98 @@
+//Copyright (C) 2008 Apple Inc. All Rights Reserved.
+
+function Transitions () {
+ // callback for the first batch of operation, where we set the default properties
+ // for the transition (transition-property and transition-duration) as well as
+ // the "from" property value if explicitely passed as a param to .add()
+ this.instantOperations = new Function ();
+ // callback for the second batch of operation, where we set the "to" property value
+ this.deferredOperations = new Function ();
+};
+
+// Core defaults for the transitions, you can update these members so that all
+// calls to .add() from that point on use this duration and set of properties
+Transitions.DEFAULTS = {
+ duration : 1, // default to 1 second
+ properties : []
+};
+
+
+/*
+ Adds a CSS transition, parameters are :
+
+ element: target element for transition
+ duration: duration for all transitions in seconds
+ properties: the properties that are transitioned (will be fed to '-webkit-transition-property')
+ from: optional list of initial property values to match properties passed as .properties
+ to: list of final property values to match properties passed as .properties
+
+ The .duration and .properties parameters are optional and can be defined once for
+ all upcoming transitions by over-riding the Transition.DEFAULTS properties
+
+ Some operations need to be deferred so that the styles are currently set for the from state
+ of from / to operations
+
+ */
+
+Transitions.prototype.add = function (params) {
+ var style = params.element.style;
+ // set up properties
+ var properties = (params.properties) ? params.properties : Transitions.DEFAULTS.properties;
+ // set up durations
+ var duration = ((params.duration) ? params.duration : Transitions.DEFAULTS.duration) + 's';
+ var durations = [];
+ for (var i = 0; i < properties.length; i++) {
+ durations.push(duration);
+ }
+ // from/to animation
+ if (params.from) {
+ this.addInstantOperation(function () {
+ style.webkitTransitionProperty = 'none';
+ for (var i = 0; i < properties.length; i++) {
+ style.setProperty(properties[i], params.from[i], '');
+ }
+ });
+ this.addDeferredOperation(function () {
+ style.webkitTransitionProperty = properties.join(', ');
+ style.webkitTransitionDuration = durations.join(', ');
+ for (var i = 0; i < properties.length; i++) {
+ style.setProperty(properties[i], params.to[i], '');
+ }
+ });
+ }
+ // to-only animation
+ else {
+ this.addDeferredOperation(function () {
+ style.webkitTransitionProperty = properties.join(', ');
+ style.webkitTransitionDuration = durations.join(', ');
+ for (var i = 0; i < properties.length; i++) {
+ style.setProperty(properties[i], params.to[i], '');
+ }
+ });
+ }
+};
+
+// adds a new operation to the set of instant operations
+Transitions.prototype.addInstantOperation = function (new_operation) {
+ var previousInstantOperations = this.instantOperations;
+ this.instantOperations = function () {
+ previousInstantOperations();
+ new_operation();
+ };
+};
+
+// adds a new operation to the set of deferred operations
+Transitions.prototype.addDeferredOperation = function (new_operation) {
+ var previousDeferredOperations = this.deferredOperations;
+ this.deferredOperations = function () {
+ previousDeferredOperations();
+ new_operation();
+ };
+};
+
+// called in order to launch the current group of transitions
+Transitions.prototype.apply = function () {
+ this.instantOperations();
+ var _this = this;
+ setTimeout(_this.deferredOperations, 0);
+};
diff --git a/static/functions/upload.js b/static/functions/upload.js
new file mode 100644
index 0000000..6d68fab
--- /dev/null
+++ b/static/functions/upload.js
@@ -0,0 +1,272 @@
+function Categories() {
+ ajax.get('ajax.php?action=upload_section&categoryid=' + $('#categories').raw().value, function (response) {
+ $('#dynamic_form').raw().innerHTML = response;
+ });
+}
+
+function Remaster() {
+ $('#remaster_true').toggle();
+}
+
+function Format() {
+ if($('#format').raw().options[$('#format').raw().selectedIndex].value == 'FLAC') {
+ for (var i = 0; i<$('#bitrate').raw().options.length; i++) {
+ if($('#bitrate').raw().options[i].value == 'Lossless') {
+ $('#bitrate').raw()[i].selected = true;
+ }
+ }
+ $('#upload_logs').show();
+ $('#other_bitrate_span').hide();
+ } else {
+ $('#bitrate').raw()[0].selected = true;
+ $('#upload_logs').hide();
+ }
+}
+
+function Bitrate() {
+ $('#other_bitrate').raw().value = '';
+ if($('#bitrate').raw().options[$('#bitrate').raw().selectedIndex].value == 'Other') {
+ $('#other_bitrate_span').show();
+ } else {
+ $('#other_bitrate_span').hide();
+ }
+}
+
+function AltBitrate() {
+ if($('#other_bitrate').raw().value >= 320) {
+ $('#vbr').raw().disabled = true;
+ $('#vbr').raw().checked = false;
+ } else {
+ $('#vbr').raw().disabled = false;
+ }
+}
+
+function add_tag() {
+ if($('#tags').raw().value == "") {
+ $('#tags').raw().value = $('#genre_tags').raw().options[$('#genre_tags').raw().selectedIndex].value;
+ } else if($('#genre_tags').raw().options[$('#genre_tags').raw().selectedIndex].value == '---') {
+ } else {
+ $('#tags').raw().value = $('#tags').raw().value + ', ' + $('#genre_tags').raw().options[$('#genre_tags').raw().selectedIndex].value;
+ }
+}
+
+var LogCount = 1;
+
+function AddLogField() {
+ if(LogCount >= 200) { return; }
+ var LogField = document.createElement("input");
+ LogField.type = "file";
+ LogField.id = "file";
+ LogField.name = "logfiles[]";
+ LogField.size = 50;
+ var x = $('#logfields').raw();
+ x.appendChild(document.createElement("br"));
+ x.appendChild(LogField);
+ LogCount++;
+}
+
+function RemoveLogField() {
+ if(LogCount == 1) { return; }
+ var x = $('#logfields').raw();
+ for (i=0; i<2; i++) { x.removeChild(x.lastChild); }
+ LogCount--;
+}
+
+var FormatCount = 0;
+
+function AddFormat() {
+ if(FormatCount >= 10) { return; }
+ FormatCount++;
+ $('#extras').raw().value = FormatCount;
+
+ var NewRow = document.createElement("tr");
+ NewRow.id = "new_torrent_row"+FormatCount;
+ NewRow.setAttribute("style","border-top-width: 5px; border-left-width: 5px; border-right-width: 5px;");
+
+ var NewCell1 = document.createElement("td");
+ NewCell1.setAttribute("class","label");
+ NewCell1.innerHTML = "Extra Torrent File";
+
+ var NewCell2 = document.createElement("td");
+ var TorrentField = document.createElement("input");
+ TorrentField.type = "file";
+ TorrentField.id = "extra_torrent_file"+FormatCount;
+ TorrentField.name = "extra_torrent_files[]";
+ TorrentField.size = 50;
+ NewCell2.appendChild(TorrentField);
+
+ NewRow.appendChild(NewCell1);
+ NewRow.appendChild(NewCell2);
+
+ var x = $('#tags_row').raw();
+ x.parentNode.insertBefore(NewRow, x);
+
+ NewRow = document.createElement("tr");
+ NewRow.id = "new_format_row"+FormatCount;
+ NewRow.setAttribute("style","border-left-width: 5px; border-right-width: 5px;");
+ NewCell1 = document.createElement("td");
+ NewCell1.setAttribute("class","label");
+ NewCell1.innerHTML = "Extra Format / Bitrate";
+
+ NewCell2 = document.createElement("td");
+ tmp = '<select id="releasetype" name="extra_formats[]"><option value="">---</option>';
+
+ for(var i in formats) {
+ tmp += "<option value='"+formats[i]+"'>"+formats[i]+"</option>\n";
+ }
+ tmp += "</select>";
+
+ tmp += '<select id="releasetype" name="extra_bitrates[]"><option value="">---</option>';
+ for(var i in bitrates) {
+ tmp += "<option value='"+bitrates[i]+"'>"+bitrates[i]+"</option>\n";
+ }
+ tmp += "</select>";
+
+ NewCell2.innerHTML = tmp;
+ NewRow.appendChild(NewCell1);
+ NewRow.appendChild(NewCell2);
+
+ x = $('#tags_row').raw();
+ x.parentNode.insertBefore(NewRow, x);
+
+ NewRow = document.createElement("tr");
+ NewRow.id = "new_description_row"+FormatCount;
+ NewRow.setAttribute("style","border-bottom-width: 5px; border-left-width: 5px; border-right-width: 5px;");
+ NewCell1 = document.createElement("td");
+ NewCell1.setAttribute("class","label");
+ NewCell1.innerHTML = "Extra Release Description";
+
+ NewCell2 = document.createElement("td");
+ NewCell2.innerHTML = '<textarea name="extra_release_desc[]" id="release_desc" cols="60" rows="4"></textarea>';
+
+ NewRow.appendChild(NewCell1);
+ NewRow.appendChild(NewCell2);
+
+ x = $('#tags_row').raw();
+ x.parentNode.insertBefore(NewRow, x);
+}
+
+function RemoveFormat() {
+ if(FormatCount == 0) { return; }
+ $('#extras').raw().value = FormatCount;
+
+ var x = $('#new_torrent_row'+FormatCount).raw();
+ x.parentNode.removeChild(x);
+
+ x = $('#new_format_row'+FormatCount).raw();
+ x.parentNode.removeChild(x);
+
+ x = $('#new_description_row'+FormatCount).raw();
+ x.parentNode.removeChild(x);
+
+ FormatCount--;
+
+}
+
+function Media() {
+ if($('#media').raw().options[$('#media').raw().selectedIndex].text == 'Cassette') {
+ $('#cassette_true').show();
+ } else {
+ $('#cassette_true').hide();
+ }
+}
+
+
+var ArtistCount = 1;
+
+function AddArtistField() {
+ if(ArtistCount >= 100) { return; }
+ var ArtistField = document.createElement("input");
+ ArtistField.type = "text";
+ ArtistField.id = "artist";
+ ArtistField.name = "artists[]";
+ ArtistField.size = 45;
+
+ var ImportanceField = document.createElement("select");
+ ImportanceField.id = "importance";
+ ImportanceField.name = "importance[]";
+ ImportanceField.options[0] = new Option("Main", "1");
+ ImportanceField.options[1] = new Option("Guest", "2");
+ ImportanceField.options[2] = new Option("Remixer", "3");
+
+ var x = $('#artistfields').raw();
+ x.appendChild(document.createElement("br"));
+ x.appendChild(ArtistField);
+ x.appendChild(ImportanceField);
+ ArtistCount++;
+}
+
+function RemoveArtistField() {
+ if(ArtistCount == 1) { return; }
+ var x = $('#artistfields').raw();
+ for (i=0; i<3; i++) { x.removeChild(x.lastChild); }
+ ArtistCount--;
+}
+
+function CheckVA() {
+ var x = $('#artist').raw();
+ if(x.value.toLowerCase() == 'various artists' || x.value.toLowerCase() == 'va' || x.value.toLowerCase() == 'various') {
+ $('#vawarning').show();
+ } else {
+ $('#vawarning').hide();
+ }
+}
+
+function CheckYear() {
+ var media = $('#media').raw().options[$('#media').raw().selectedIndex].text;
+ if(media == "Vinyl" || media == "Soundboard" || media == "Cassette") {
+ media = "old";
+ }
+ var x = $('#year').raw();
+ if(x.value < 1982 && x.value != '' && media != "old" && !$('#unknown').raw().checked) {
+ $('#yearwarning').show();
+ $('#remaster').raw().checked = true;
+ $('#remaster_true').show();
+ } else if($('#unknown').raw().checked) {
+ $('#remaster').raw().checked = true;
+ $('#yearwarning').hide();
+ $('#remaster_true').show();
+ } else {
+ $('#yearwarning').hide();
+ }
+}
+
+function ToggleUnknown() {
+ if($('#unknown').raw().checked) {
+ $('#remaster_year').raw().value = "";
+ $('#remaster_title').raw().value = "";
+ $('#remaster_record_label').raw().value = "";
+ $('#remaster_catalogue_number').raw().value = "";
+
+ if($('#groupremasters').raw()) {
+ $('#groupremasters').raw().selectedIndex = 0;
+ $('#groupremasters').raw().disabled = true;
+ }
+
+ $('#remaster_year').raw().disabled = true;
+ $('#remaster_title').raw().disabled = true;
+ $('#remaster_record_label').raw().disabled = true;
+ $('#remaster_catalogue_number').raw().disabled = true;
+ } else {
+ $('#remaster_year').raw().disabled = false;
+ $('#remaster_title').raw().disabled = false;
+ $('#remaster_record_label').raw().disabled = false;
+ $('#remaster_catalogue_number').raw().disabled = false;
+
+ if($('#groupremasters').raw()) {
+ $('#groupremasters').raw().disabled = false;
+ }
+ }
+}
+
+function GroupRemaster() {
+ var remasters = json.decode($('#json_remasters').raw().value);
+
+ var index = $('#groupremasters').raw().options[$('#groupremasters').raw().selectedIndex].value;
+ if(index != "") {
+ $('#remaster_year').raw().value = remasters[index][1];
+ $('#remaster_title').raw().value = remasters[index][2];
+ $('#remaster_record_label').raw().value = remasters[index][3];
+ $('#remaster_catalogue_number').raw().value = remasters[index][4];
+ }
+}
diff --git a/static/functions/user.js b/static/functions/user.js
new file mode 100644
index 0000000..90252e6
--- /dev/null
+++ b/static/functions/user.js
@@ -0,0 +1,137 @@
+function ChangeTo(to) {
+ if(to == "text") {
+ $('#admincommentlinks').hide();
+ $('#admincomment').show();
+ resize('admincomment');
+ var buttons = document.getElementsByName('admincommentbutton');
+ for(var i = 0; i < buttons.length; i++) {
+ buttons[i].setAttribute('onclick',"ChangeTo('links'); return false;");
+ }
+ } else if(to == "links") {
+ ajax.post("ajax.php?action=preview","form", function(response){
+ $('#admincommentlinks').raw().innerHTML = response;
+ $('#admincomment').hide();
+ $('#admincommentlinks').show();
+ var buttons = document.getElementsByName('admincommentbutton');
+ for(var i = 0; i < buttons.length; i++) {
+ buttons[i].setAttribute('onclick',"ChangeTo('text'); return false;");
+ }
+ })
+ }
+}
+
+function UncheckIfDisabled(checkbox) {
+ if (checkbox.disabled) {
+ checkbox.checked = false;
+ }
+}
+
+function AlterParanoia() {
+ // Required Ratio is almost deducible from downloaded, the count of seeding and the count of snatched
+ // we will "warn" the user by automatically checking the required ratio box when they are
+ // revealing that information elsewhere
+ if(!$('input[name=p_ratio]').raw()) {
+ return;
+ }
+ var showDownload = $('input[name=p_downloaded]').raw().checked || ($('input[name=p_uploaded]').raw().checked && $('input[name=p_ratio]').raw().checked);
+ if (($('input[name=p_seeding_c]').raw().checked) && ($('input[name=p_snatched_c]').raw().checked) && showDownload) {
+ $('input[type=checkbox][name=p_requiredratio]').raw().checked = true;
+ $('input[type=checkbox][name=p_requiredratio]').raw().disabled = true;
+ } else {
+ $('input[type=checkbox][name=p_requiredratio]').raw().disabled = false;
+ }
+ $('input[name=p_torrentcomments_l]').raw().disabled = !$('input[name=p_torrentcomments_c]').raw().checked;
+ $('input[name=p_collagecontribs_l]').raw().disabled = !$('input[name=p_collagecontribs_c]').raw().checked;
+ $('input[name=p_requestsfilled_list]').raw().disabled = !($('input[name=p_requestsfilled_count]').raw().checked && $('input[name=p_requestsfilled_bounty]').raw().checked);
+ $('input[name=p_requestsvoted_list]').raw().disabled = !($('input[name=p_requestsvoted_count]').raw().checked && $('input[name=p_requestsvoted_bounty]').raw().checked);
+ $('input[name=p_uploads_l]').raw().disabled = !$('input[name=p_uploads_c]').raw().checked;
+ $('input[name=p_uniquegroups_l]').raw().disabled = !$('input[name=p_uniquegroups_c]').raw().checked;
+ $('input[name=p_perfectflacs_l]').raw().disabled = !$('input[name=p_perfectflacs_c]').raw().checked;
+ $('input[name=p_seeding_l]').raw().disabled = !$('input[name=p_seeding_c]').raw().checked;
+ $('input[name=p_leeching_l]').raw().disabled = !$('input[name=p_leeching_c]').raw().checked;
+ $('input[name=p_snatched_l]').raw().disabled = !$('input[name=p_snatched_c]').raw().checked;
+ UncheckIfDisabled($('input[name=p_torrentcomments_l]').raw());
+ UncheckIfDisabled($('input[name=p_collagecontribs_l]').raw());
+ UncheckIfDisabled($('input[name=p_requestsfilled_list]').raw());
+ UncheckIfDisabled($('input[name=p_requestsvoted_list]').raw());
+ UncheckIfDisabled($('input[name=p_uploads_l]').raw());
+ UncheckIfDisabled($('input[name=p_uniquegroups_l]').raw());
+ UncheckIfDisabled($('input[name=p_perfectflacs_l]').raw());
+ UncheckIfDisabled($('input[name=p_seeding_l]').raw());
+ UncheckIfDisabled($('input[name=p_leeching_l]').raw());
+ UncheckIfDisabled($('input[name=p_snatched_l]').raw());
+
+ // unique groups, "Perfect" FLACs and artists added are deducible from the list of uploads
+ if ($('input[name=p_uploads_l]').raw().checked) {
+ $('input[name=p_uniquegroups_c]').raw().checked = true;
+ $('input[name=p_uniquegroups_l]').raw().checked = true;
+ $('input[name=p_uniquegroups_c]').raw().disabled = true;
+ $('input[name=p_uniquegroups_l]').raw().disabled = true;
+ $('input[name=p_perfectflacs_c]').raw().checked = true;
+ $('input[name=p_perfectflacs_l]').raw().checked = true;
+ $('input[name=p_perfectflacs_c]').raw().disabled = true;
+ $('input[name=p_perfectflacs_l]').raw().disabled = true;
+ $('input[type=checkbox][name=p_artistsadded]').raw().checked = true;
+ $('input[type=checkbox][name=p_artistsadded]').raw().disabled = true;
+ } else {
+ $('input[name=p_uniquegroups_c]').raw().disabled = false;
+ $('input[name=p_uniquegroups_l]').raw().checked = false;
+ $('input[name=p_uniquegroups_l]').raw().disabled = true;
+ $('input[name=p_perfectflacs_c]').raw().disabled = false;
+ $('input[type=checkbox][name=p_artistsadded]').raw().disabled = false;
+ }
+ if ($('input[name=p_collagecontribs_l]').raw().checked) {
+ $('input[name=p_collages_c]').raw().disabled = true;
+ $('input[name=p_collages_l]').raw().disabled = true;
+ $('input[name=p_collages_c]').raw().checked = true;
+ $('input[name=p_collages_l]').raw().checked = true;
+ } else {
+ $('input[name=p_collages_c]').raw().disabled = false;
+ $('input[name=p_collages_l]').raw().disabled = !$('input[name=p_collages_c]').raw().checked;
+ UncheckIfDisabled($('input[name=p_collages_l]').raw());
+ }
+}
+
+function ParanoiaReset(checkbox, drops) {
+ var selects = $('select');
+ for (var i = 0; i < selects.results(); i++) {
+ if (selects.raw(i).name.match(/^p_/)) {
+ if(drops == 0) {
+ selects.raw(i).selectedIndex = 0;
+ } else if(drops == 1) {
+ selects.raw(i).selectedIndex = selects.raw(i).options.length - 2;
+ } else if(drops == 2) {
+ selects.raw(i).selectedIndex = selects.raw(i).options.length - 1;
+ }
+ AlterParanoia();
+ }
+ }
+ var checkboxes = $(':checkbox');
+ for (var i = 0; i < checkboxes.results(); i++) {
+ if (checkboxes.raw(i).name.match(/^p_/) && (checkboxes.raw(i).name != 'p_lastseen')) {
+ if (checkbox == 3) {
+ checkboxes.raw(i).checked = !(checkboxes.raw(i).name.match(/_list$/) || checkboxes.raw(i).name.match(/_l$/));
+ } else {
+ checkboxes.raw(i).checked = checkbox;
+ }
+ AlterParanoia();
+ }
+ }
+}
+
+function ParanoiaResetOff() {
+ ParanoiaReset(true, 0);
+}
+
+function ParanoiaResetStats() {
+ ParanoiaReset(3, 0);
+ $('input[name=p_collages_l]').raw().checked = false;
+}
+
+function ParanoiaResetOn() {
+ ParanoiaReset(false, 0);
+ $('input[name=p_collages_c]').raw().checked = false;
+ $('input[name=p_collages_l]').raw().checked = false;
+}
+
+addDOMLoadEvent(AlterParanoia);
diff --git a/static/functions/validate.js b/static/functions/validate.js
new file mode 100644
index 0000000..9a126fd
--- /dev/null
+++ b/static/functions/validate.js
@@ -0,0 +1,106 @@
+var elemStyles=Array();
+var errorElems=Array();
+
+function validEmail(str) {
+ if (str.match(/^[_a-z0-9-]+([.+][_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/i)) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+function validLink(str) {
+ if (str.match(/^(https?):\/\/([a-z0-9\-\_]+\.)+([a-z]{1,5}[^\.])(\/[^<>]+)*$/i)) {
+ return true;
+ } else { return false; }
+}
+
+function isNumeric(str,usePeriod) {
+ matchStr='/[^0-9';
+ if (usePeriod) {
+ matchStr+='\.';
+ }
+ matchStr=']/';
+
+ if (str.match(matchStr)) { return false; }
+ return true;
+}
+
+function validDate(theDate) {
+ days=0;
+
+ theDate=theDate.split("/");
+ month=theDate[0];
+ day=theDate[1];
+ year=theDate[2];
+
+ if (!isNumeric(month) || !isNumeric(day) || !isNumeric(year)) { return false; }
+
+ if (month==1) { days=31; }
+ else if (month==2) { if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) { days=29; } else { days=28; }}
+ else if (month==3) { days=31; }
+ else if (month==4) { days=30; }
+ else if (month==5) { days=31; }
+ else if (month==6) { days=30; }
+ else if (month==7) { days=31; }
+ else if (month==8) { days=31; }
+ else if (month==9) { days=30; }
+ else if (month==10) { days=31; }
+ else if (month==11) { days=30; }
+ else if (month==12) { days=31; }
+
+ if (day>days || day==undefined || days==undefined || month==undefined || year==undefined || year.length<4) { return false; } else { return true; }
+}
+
+function showError(fields,alertStr) {
+ var tField=Array();
+
+ if (typeof(fields)=='object') { tField[0]=fields; } else { tField=fields.split(','); }
+ for(s=0; s<=tField.length-1; s++) {
+ if ($('#'+tField[s])) {
+ $('#'+tField[s]).className=$('#'+tField[s]).className+" elem_error";
+ if (s==0) {
+ $('#'+tField[s]).focus();
+ try { $('#'+tField[s]).select(); } catch (error) { }
+ }
+
+ errorElems[errorElems.length]=tField[s];
+ if ($('#'+tField[s]).type!="select-one") {
+ $('#'+tField[s]).onkeypress=function() { clearElemError(); };
+ } else {
+ $('#'+tField[s]).onchange=function() { clearElemError(); };
+ }
+ }
+ }
+
+ if (alertStr!="") { alert(alertStr); }
+ return false;
+}
+
+function clearErrors(theForm) {
+ elementList=document.forms[theForm].elements;
+ for(x=0; x<=elementList.length-1; x++) {
+ if (elementList[x].type!="submit" && elementList[x].type!="button") {
+ if (!elemStyles[elementList[x].id]) {
+ elemStyles[elementList[x].id]=elementList[x].className;
+ }
+
+ try {
+ elementList[x].className=elemStyles[elementList[x].id];
+ } catch (error) { }
+ }
+ }
+}
+
+function clearElemError(evt) {
+ for(x=0; x<=errorElems.length-1; x++) {
+ elem=$('#'+errorElems[x]);
+ if ($('#'+elem).type!="select-one") {
+ $('#'+elem).onkeypress="";
+ } else {
+ $('#'+elem).onchange="";
+ }
+ elem.className=elemStyles[elem.id];
+ }
+ errorElems=Array();
+}
diff --git a/static/functions/wiki.js b/static/functions/wiki.js
new file mode 100644
index 0000000..456fde0
--- /dev/null
+++ b/static/functions/wiki.js
@@ -0,0 +1,5 @@
+function Remove_Alias(alias) {
+ ajax.get("wiki.php?action=delete_alias&auth=" + authkey + "&alias=" + alias, function(response){
+ $('#alias_' + alias).hide();
+ });
+} \ No newline at end of file