From ace0d590b4ec284bc7f5798a678effc25a96808c Mon Sep 17 00:00:00 2001 From: RaNaN Date: Tue, 14 Sep 2010 18:07:50 +0200 Subject: packages editable --- module/web/templates/default/base.html | 202 +++++++++++++------------ module/web/templates/default/captcha.html | 1 - module/web/templates/default/collector.html | 15 +- module/web/templates/default/edit_package.html | 41 +++++ module/web/templates/default/home.html | 4 +- module/web/templates/default/package_ui.js | 76 +++++++++- module/web/templates/default/queue.html | 15 +- module/web/templates/default/window.html | 8 +- 8 files changed, 238 insertions(+), 124 deletions(-) create mode 100644 module/web/templates/default/edit_package.html (limited to 'module/web/templates') diff --git a/module/web/templates/default/base.html b/module/web/templates/default/base.html index 2ed21d1fc..7e0f0e2b4 100644 --- a/module/web/templates/default/base.html +++ b/module/web/templates/default/base.html @@ -22,7 +22,12 @@ document.addEvent("domready", function(){ add_bg = new Fx.Tween($('add_bg')); add_box = new Fx.Tween($('add_box')); - cap_box = new Fx.Tween($('cap_box')) + cap_box = new Fx.Tween($('cap_box')); + + add_bg.set("opacity", 0); + add_box.set("opacity", 0); + cap_box.set("opacity", 0); + $('add_form').onsubmit=function() { $('add_form').target = 'upload_target'; @@ -32,7 +37,7 @@ document.addEvent("domready", function(){ }else{ out(); } - } + }; $('add_reset').addEvent('click', function(){ out(); @@ -46,7 +51,7 @@ document.addEvent("domready", function(){ initialDelay: 0, delay: 4000, limit: 30000 - }) + }); $('action_play').addEvent('click', function(){ new Request({method: 'get', url: '/json/unpause'}).send(); @@ -58,135 +63,132 @@ document.addEvent("domready", function(){ }); - $('action_stop').addEvent('click', function(){ - new Request({method: 'get', url: '/json/pause'}).send(); - }); + $('action_stop').addEvent('click', function(){ + new Request({method: 'get', url: '/json/pause'}).send(); + }); - $('cap_info').addEvent('click', function(){ - load_cap("get", ""); - show_cap(); - }); + $('cap_info').addEvent('click', function(){ + load_cap("get", ""); + show_cap(); + }); - $('cap_reset').addEvent('click', function(){ - hide_cap() - }); + $('cap_reset').addEvent('click', function(){ + hide_cap() + }); - $('cap_form').addEvent('submit', function(e){ - submit_cap(); - e.stop() - }); + $('cap_form').addEvent('submit', function(e){ + submit_cap(); + e.stop() + }); + + jsonStatus.startTimer(); - jsonStatus.startTimer(); - }); function LoadJsonToContent(data) { - $("speed").set('text', Math.round(data.speed*100)/100); - $("aktiv").set('text', data.activ); - $("aktiv_from").set('text', data.queue); - - if (data.captcha){ - $("cap_info").setStyle('display', 'inline'); - }else{ - $("cap_info").setStyle('display', 'none'); - } + $("speed").set('text', Math.round(data.speed*100)/100); + $("aktiv").set('text', data.activ); + $("aktiv_from").set('text', data.queue); + + if (data.captcha){ + $("cap_info").setStyle('display', 'inline'); + }else{ + $("cap_info").setStyle('display', 'none'); + } - if (data.download) { - $("time").set('text', " {% trans "on" %}"); - $("time").setStyle('background-color', "#8ffc25"); - - }else{ - $("time").set('text', " {% trans "off" %}"); - $("time").setStyle('background-color', "#fc6e26"); - } - - if (data.reconnect){ - $("reconnect").set('text', " {% trans "on" %}"); - $("reconnect").setStyle('background-color', "#8ffc25"); - } - else{ - $("reconnect").set('text', " {% trans "off" %}"); - $("reconnect").setStyle('background-color', "#fc6e26"); - } + if (data.download) { + $("time").set('text', " {% trans "on" %}"); + $("time").setStyle('background-color', "#8ffc25"); + + }else{ + $("time").set('text', " {% trans "off" %}"); + $("time").setStyle('background-color', "#fc6e26"); + } + + if (data.reconnect){ + $("reconnect").set('text', " {% trans "on" %}"); + $("reconnect").setStyle('background-color', "#8ffc25"); + } + else{ + $("reconnect").set('text', " {% trans "off" %}"); + $("reconnect").setStyle('background-color', "#fc6e26"); + } } function bg_show(){ - add_bg.set('opacity', 0); - $("add_bg").setStyle('display', 'block'); - add_bg.start('opacity',0.8); + $("add_bg").setStyle('display', 'block'); + add_bg.start('opacity',0.8); } function bg_hide(){ - add_bg.start('opacity',0).chain(function(){ - $('add_bg').setStyle('display', 'none'); - }); + add_bg.start('opacity',0).chain(function(){ + $('add_bg').setStyle('display', 'none'); + }); } function show(){ - bg_show() - add_box.set('opacity', 0) - $("add_box").setStyle('display', 'block'); - add_box.start('opacity',1) + bg_show(); + $("add_box").setStyle('display', 'block'); + add_box.start('opacity',1) } function out(){ - bg_hide() - add_box.start('opacity',0).chain(function(){ - $('add_box').setStyle('display', 'none'); - }); + bg_hide(); + add_box.start('opacity',0).chain(function(){ + $('add_box').setStyle('display', 'none'); + }); } function show_cap(){ - bg_show() - cap_box.set('opacity', 0) - $("cap_box").setStyle('display', 'block'); - cap_box.start('opacity',1) + bg_show(); + $("cap_box").setStyle('display', 'block'); + cap_box.start('opacity',1) } function hide_cap(){ - bg_hide() - cap_box.start('opacity',0).chain(function(){ - $('cap_box').setStyle('display', 'none'); - }); + bg_hide(); + cap_box.start('opacity',0).chain(function(){ + $('cap_box').setStyle('display', 'none'); + }); } function load_cap(method, post){ - new Request.JSON({ - url: "/json/set_captcha", - onSuccess: function(data){ - if (data.captcha){ - $('cap_img').set('src', data.src); - $('cap_span').setStyle('display', 'block'); - $$('#cap_form p')[0].set('text', '{% trans "Please read the text on the captcha." %}'); - $('cap_id').set('value', data.id); - } else{ - $('cap_img').set('src', ''); - $('cap_span').setStyle('display', 'none'); - $$('#cap_form p')[0].set('text', '{% trans "No Captchas to read." %}'); - } - }, - secure: false, - async: true, - method: method - }).send(post); + new Request.JSON({ + url: "/json/set_captcha", + onSuccess: function(data){ + if (data.captcha){ + $('cap_img').set('src', data.src); + $('cap_span').setStyle('display', 'block'); + $$('#cap_form p')[0].set('text', '{% trans "Please read the text on the captcha." %}'); + $('cap_id').set('value', data.id); + } else{ + $('cap_img').set('src', ''); + $('cap_span').setStyle('display', 'none'); + $$('#cap_form p')[0].set('text', '{% trans "No Captchas to read." %}'); + } + }, + secure: false, + async: true, + method: method + }).send(post); } function submit_cap(){ - load_cap("post", "cap_id="+ $('cap_id').get('value') +"&cap_text=" + $('cap_text').get('value') ); - $('cap_text').set('value', ''); - return false; + load_cap("post", "cap_id="+ $('cap_id').get('value') +"&cap_text=" + $('cap_text').get('value') ); + $('cap_text').set('value', ''); + return false; } function AddBox() { - if ($("add_box").getStyle("display") == "hidden" || $("add_box").getStyle("display") == "none" || $("add_box").getStyle("opacity" == 0)) - { - show(); - } - else - { - out(); - } + if ($("add_box").getStyle("display") == "hidden" || $("add_box").getStyle("display") == "none" || $("add_box").getStyle("opacity" == 0)) + { + show(); + } + else + { + out(); + } } @@ -194,18 +196,18 @@ function AddBox() {% block head %} {% endblock %} - +
-
+
-{% if user.is_authenticated %} + {% if user.is_authenticated %} Captcha: -{% trans "Captcha waiting" %} +{% trans "Captcha waiting" %} User:{{user.username}} diff --git a/module/web/templates/default/captcha.html b/module/web/templates/default/captcha.html index aa30e365c..fe7b04fc9 100644 --- a/module/web/templates/default/captcha.html +++ b/module/web/templates/default/captcha.html @@ -1,6 +1,5 @@ {% load i18n %} - diff --git a/module/web/templates/default/collector.html b/module/web/templates/default/collector.html index 630eddc51..e207ba99a 100644 --- a/module/web/templates/default/collector.html +++ b/module/web/templates/default/collector.html @@ -8,7 +8,6 @@ @@ -49,19 +48,22 @@ document.addEvent("domready", function(){
-
- {{ package.name }} +
+ + {{package.name}}    - +       + +   
@@ -69,4 +71,7 @@ document.addEvent("domready", function(){ {% endfor %} + +{% include "default/edit_package.html" %} + {% endblock %} \ No newline at end of file diff --git a/module/web/templates/default/edit_package.html b/module/web/templates/default/edit_package.html new file mode 100644 index 000000000..9938eb17b --- /dev/null +++ b/module/web/templates/default/edit_package.html @@ -0,0 +1,41 @@ +{% load i18n %} +
+
+

{% trans "Edit Package" %}

+

{% trans "Edit the package detais below." %}

+ + + + + + + + + + + + + + + +
+ +
+ +
\ No newline at end of file diff --git a/module/web/templates/default/home.html b/module/web/templates/default/home.html index bbc196fe1..41ced20a7 100644 --- a/module/web/templates/default/home.html +++ b/module/web/templates/default/home.html @@ -145,10 +145,10 @@ var LinkEntry = new Class({ 'styles':{ 'height': '4px', 'width': item.percent+'%', - 'background-color': '#ddd', + 'background-color': '#ddd' } }) - } + }; this.elements.tr.adopt(this.elements.name,this.elements.status,this.elements.info,this.elements.kbleft,new Element('td').adopt(this.elements.percent,this.elements.remove)); this.elements.pgbTr.adopt(new Element('td',{'colspan':5}).adopt(this.elements.pgb)); diff --git a/module/web/templates/default/package_ui.js b/module/web/templates/default/package_ui.js index 5f39710c1..759412621 100644 --- a/module/web/templates/default/package_ui.js +++ b/module/web/templates/default/package_ui.js @@ -1,5 +1,13 @@ //{% load i18n %} -var load; // populate later +var load, pack_box; + +document.addEvent("domready", function(){ + load = new Fx.Tween($("load-indicator"), {link: "cancel"}); + pack_box = new Fx.Tween($('pack_box')); + $('pack_reset').addEvent('click', function(){ + hide_pack() + }); +}); function indicateLoad() { //$("load-indicator").reveal(); @@ -10,6 +18,19 @@ function indicateFinish() { load.start("opacity", 0) } +function show_pack(){ + bg_show(); + $("pack_box").setStyle('display', 'block'); + pack_box.start('opacity',1) +} + +function hide_pack(){ + bg_hide(); + pack_box.start('opacity',0).chain(function(){ + $('pack_box').setStyle('display', 'none'); + }); +} + var PackageUI = new Class({ initialize: function(url, type) { this.url = url; @@ -22,7 +43,7 @@ var PackageUI = new Class({ clone: true, revert: true, opacity: 0.4, - handle: ".packagename", + handle: ".package_drag", onStart: this.startSort, onComplete: this.saveSort.bind(this) }); @@ -102,11 +123,18 @@ var Package = new Class({ parseElement: function() { var imgs = this.ele.getElements('img'); - imgs[0].addEvent('click', this.deletePackage.bind(this)); + this.name = this.ele.getElements('.name')[0]; + this.folder = this.ele.getElements('.folder')[0]; + this.password = this.ele.getElements('.password')[0]; + this.prio = this.ele.getElements('.prio')[0]; - imgs[1].addEvent('click', this.restartPackage.bind(this)); + imgs[1].addEvent('click', this.deletePackage.bind(this)); - imgs[2].addEvent('click', this.movePackage.bind(this)); + imgs[2].addEvent('click', this.restartPackage.bind(this)); + + imgs[3].addEvent('click', this.editPackage.bind(this)); + + imgs[4].addEvent('click', this.movePackage.bind(this)); this.ele.getElement('.packagename').addEvent('click', this.toggle.bind(this)); @@ -137,8 +165,8 @@ var Package = new Class({ html += "{statusmsg}{error} ".substitute({"statusmsg": link.statusmsg, "error":link.error}); html += "{format_size}".substitute({"format_size": link.format_size}); html += "{plugin}  ".substitute({"plugin": link.plugin}); - html += "  " - html += "
" + html += "  "; + html += "
"; var div = new Element("div",{ "id": "file_"+link.id, @@ -251,6 +279,40 @@ var Package = new Class({ event.stop(); }, + + editPackage: function(event){ + $("pack_form").removeEvents("submit"); + $("pack_form").addEvent("submit", this.savePackage.bind(this)); + + $("pack_id").set("value", this.id); + $("pack_name").set("value", this.name.get("text")); + $("pack_folder").set("value", this.folder.get("text")); + $("pack_pws").set("value", this.password.get("text")); + + var prio = 3; + $("pack_prio").getChildren("option").each(function(item, index){ + item.erase("selected"); + if (prio.toString() == this.prio.get("text")){ + item.set("selected","selected"); + } + prio--; + }.bind(this)); + + + show_pack(); + event.stop(); + }, + + savePackage: function(event){ + $("pack_form").send(); + this.name.set("text", $("pack_name").get("value")); + this.folder.set("text", $("pack_folder").get("value")); + this.password.set("text", $("pack_pws").get("value")); + this.prio.set("text", $("pack_prio").get("value")); + hide_pack(); + event.stop(); + }, + saveSort: function(ele, copy) { var order = []; this.sorts.serialize(function(ele,pos){ diff --git a/module/web/templates/default/queue.html b/module/web/templates/default/queue.html index 2e8bf4b96..e69edd2ad 100644 --- a/module/web/templates/default/queue.html +++ b/module/web/templates/default/queue.html @@ -8,7 +8,6 @@ @@ -51,19 +50,22 @@ document.addEvent("domready", function(){
-
- {{ package.name }} +
+ + {{package.name}}    - +       + +   
@@ -71,4 +73,7 @@ document.addEvent("domready", function(){ {% endfor %} + +{% include "default/edit_package.html" %} + {% endblock %} \ No newline at end of file diff --git a/module/web/templates/default/window.html b/module/web/templates/default/window.html index 01218965e..d40edbb9e 100644 --- a/module/web/templates/default/window.html +++ b/module/web/templates/default/window.html @@ -8,12 +8,12 @@

{% trans "Add Package" %}

{% trans "Paste your links or upload a container." %}

-