From f0507d635c5b792feeedc09fe349e0fd4916817c Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Thu, 19 Jan 2012 01:22:34 +0000 Subject: [PATCH] Update JS to use sihnon-js-library --- externals/sihnon-js-lib | 2 +- public/scripts/main.js | 495 ++++++++++------------ source/webui/templates/admin/settings.tpl | 4 - source/webui/templates/index.tpl | 1 + 4 files changed, 225 insertions(+), 277 deletions(-) diff --git a/externals/sihnon-js-lib b/externals/sihnon-js-lib index 821c9bc..0499e7e 160000 --- a/externals/sihnon-js-lib +++ b/externals/sihnon-js-lib @@ -1 +1 @@ -Subproject commit 821c9bc32c5b0e39806c53bb821ee223a2078cf3 +Subproject commit 0499e7ecaa888d72c624ccec2a84c0a55b505d7c diff --git a/public/scripts/main.js b/public/scripts/main.js index 717d1b0..b100fd0 100644 --- a/public/scripts/main.js +++ b/public/scripts/main.js @@ -1,281 +1,178 @@ +/** + * Ripping Cluster Webui + * + * Written by Ben Roberts + * Homepage: https://benroberts.net/projects/ripping-cluster/ + * Code: https://github.com/optiz0r/ripping-cluster-webui/ + * + * Dependencies: + * - Bootstrap + * - JQuery + * - JQueryUI + * - JQuery Progressbar + * + * Released under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License + * http://creativecommons.org/licenses/by-nc-sa/3.0/ + */ + +/** + * Ripping Cluster object + * + * Entry point for all ripping cluster webui code + */ var rc = { + /** + * Initialises the webui code + */ init: function() { - rc.ajax.init(); - rc.dialog.init(); rc.page.init(); - }, - - ajax: { - - init: function() { - - }, - - get: function(url) { - $.ajax({ - url: url, - type: "GET", - dataType: "json", - success: rc.ajax.success, - error: rc.ajax.failure - }); - }, - - post: function(url, data) { - $.ajax({ - url: url, - type: "POST", - dataType: "json", - data: data, - success: rc.ajax.success, - error: rc.ajax.failure - }); - }, - - success: function(d, s, x) { - rc.page.update(d); - rc.dialog.prepare(d); - rc.trigger_all(d); - }, - - failure: function(x, s, e) { - console.log("Ajax Failure: " + s, e); - console.log(x.responseText); - } - }, - - dialog: { - - init: function() { - $("#dialog-header-close").click(rc.dialog.close); - }, - - prepare: function(d) { - if (d.dialog && d.dialog.show) { - - if (d.dialog.buttons) { - switch (d.dialog.buttons.type) { - case 'ok': - $("#dialog-footer-ok-ok").click( - function() { - rc.trigger(d.dialog.buttons.actions.ok, d.dialog.buttons.params); - } - ); - $("#dialog-footer-ok").show(); - break; - case 'okcancel': - $("#dialog-footer-okcancel-ok").click(function() { - rc.trigger(d.dialog.buttons.actions.ok, d.dialog.buttons.params); - }); - $("#dialog-footer-okcancel-cancel").click(function() { - rc.trigger(d.dialog.buttons.actions.cancel, d.dialog.buttons.params); - }); - $("#dialog-footer-okcancel").show(); - break; - case 'yesno': - $("#dialog-footer-yesno-yes").click( - function() { - rc.trigger(d.dialog.buttons.actions.yes, d.dialog.buttons.params); - } - ); - $("#dialog-footer-yesno-no").click( - function() { - rc.trigger(d.dialog.buttons.actions.no, d.dialog.buttons.params); - } - ); - $("#dialog-footer-yesno").show(); - break; - } - } - - if (d.dialog.title) { - $('#dialog-header-title').html(d.dialog.title); - } - - if (d.dialog.content) { - $('#dialog-body').html(d.dialog.content); - } - - $("#dialog").modal({ - show: true, - backdrop: true, - keyboard: true, - }); - } - }, - - close: function() { - // Hide the dialog - $("#dialog").modal({ - show: false, - }); - - // Remove the dialog content - $("#dialog-body").html(); - - // Hide all buttons - $(".dialog-footer-buttonset").hide(); - // Strip all event handlers - $(".dialog-footer-buttonset input[type='button']").unbind('click'); - }, - - error: function(title, content, messages) { - var formatted_content = $('
').append($('

').text('content')); - if (messages) { - var formatted_messages = $('