summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-08-20 15:55:48 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-08-20 15:55:48 +0200
commitd257c974a8acea9d7309b63c829fefcbfb47d831 (patch)
treee953bce501c941e7a6c0dbb63b97e5c94c267aad
parentnetload fix (diff)
downloadpyload-d257c974a8acea9d7309b63c829fefcbfb47d831.tar.xz
dynamic status bar
-rw-r--r--module/file_list.py2
-rw-r--r--module/web/WebServer.py36
-rw-r--r--module/web/static/default/home.js2
-rw-r--r--module/web/static/default/status.js93
-rw-r--r--module/web/templates/default.tpl14
-rw-r--r--module/web/templates/window.tpl2
6 files changed, 109 insertions, 40 deletions
diff --git a/module/file_list.py b/module/file_list.py
index 35bec757f..e3c3f68ae 100644
--- a/module/file_list.py
+++ b/module/file_list.py
@@ -45,7 +45,7 @@ class File_List(object):
def append(self, url):
if not url:
return False
-
+ #@TODO: filter non existence and invalid links
new_file = self.new_pyfile(url)
self.files.append(new_file)
self.data[new_file.id] = Data(url)
diff --git a/module/web/WebServer.py b/module/web/WebServer.py
index 5885ab2de..074ab4242 100644
--- a/module/web/WebServer.py
+++ b/module/web/WebServer.py
@@ -146,8 +146,6 @@ def get_links():
downloads = core.get_downloads()
-
-
for dl in downloads:
json += '{'
json += '"id": "%s", "name": "%s", "speed": "%s", "eta": "%s", "kbleft": "%s", "size": "%s", "percent": "%s", "wait": "%s", "status": "%s"'\
@@ -160,6 +158,40 @@ def get_links():
json += "] }"
return json
+@route('/json/status')
+def get_status():
+ response.header['Cache-Control'] = 'no-cache, must-revalidate'
+ response.content_type = 'application/json'
+
+ if not check_auth(request):
+ abort(404, "No Access")
+
+ data = core.server_status()
+
+ if data['pause']:
+ status = "paused"
+ else:
+ status = "running"
+
+ json = '{ "status": "%s", "speed": "%s", "queue": "%s" }' % (status, str(int(data['speed'])), str(data['queue']))
+
+ return json
+
+@route('/json/addlinks', method='POST')
+def add_links():
+ response.header['Cache-Control'] = 'no-cache, must-revalidate'
+ response.content_type = 'application/json'
+
+ if not check_auth(request):
+ abort(404, "No Access")
+
+ links = request.POST['links'].split('\n')
+
+ core.add_links(links)
+
+ return "{}"
+
+
@route('/favicon.ico')
def favicon():
diff --git a/module/web/static/default/home.js b/module/web/static/default/home.js
index 9f8902458..065a6d6eb 100644
--- a/module/web/static/default/home.js
+++ b/module/web/static/default/home.js
@@ -88,7 +88,7 @@ pb = new dwProgressBar({
});
*/
-req.startTimer();
+ req.startTimer();
});
diff --git a/module/web/static/default/status.js b/module/web/static/default/status.js
index c211fc669..f3d521e45 100644
--- a/module/web/static/default/status.js
+++ b/module/web/static/default/status.js
@@ -1,51 +1,84 @@
/* hover! */
Element.implement({
- 'hover': function(fn1,fn2) {
- return this.addEvents({
- 'mouseenter': function(e) {
- fn1.attempt(e,this);
- },
- 'mouseleave': function(e) {
- fn2.attempt(e,this);
- }
- })
- }
+ 'hover': function(fn1,fn2) {
+ return this.addEvents({
+ 'mouseenter': function(e) {
+ fn1.attempt(e,this);
+ },
+ 'mouseleave': function(e) {
+ fn2.attempt(e,this);
+ }
+ })
+ }
});
+function updateStatus(data){
+
+ document.id("status").textContent = "Status: "+ data.status;
+ document.id("speed").textContent = "Speed: "+ data.speed +" kb/s";
+ document.id("queue").textContent = "Files in queue: "+ data.queue;
+
+}
+
+
+status_req = new Request.JSON({
+ onSuccess: updateStatus,
+ method: 'get',
+ url: '/json/status',
+ initialDelay: 0,
+ delay: 2000,
+ limit: 20000
+});
window.addEvent('domready', function(){
-$$('.statusbutton').each(function(item){
+ status_req.startTimer();
- item.hover(function(e){
- this.tween('opacity',1)
- },function(e){
- this.tween('opacity',0.01)
- }
-)
-})
-fx_reveal = new Fx.Reveal($('addlinks'));
-//fx_reveal.dissolve()
+ document.id("btAdd").addEvent("click", function(e){
+ new Request({
+ method: 'post',
+ url: '/json/addlinks',
+ onSuccess: function(){
+ document.id('linkarea').value = ""
+ }
+ }).send('links='+document.id('linkarea').value)
-$$('#addlinks .closeSticky').each(function(el){
-el.addEvent('click',function(e){
+ })
-fx_reveal.dissolve();
+ $$('.statusbutton').each(function(item){
-});
+ item.hover(function(e){
+ this.tween('opacity',1)
+ },function(e){
+ this.tween('opacity',0.01)
+ }
+ )
+ })
-});
+ fx_reveal = new Fx.Reveal($('addlinks'));
+ //fx_reveal.dissolve()
-$$('.statusbutton')[2].addEvent('click',function(e){
-$('addlinks').setStyle('top', e.page.y + 5)
-$('addlinks').setStyle('left', e.page.x + 5)
+ $$('#addlinks .closeSticky').each(function(el){
-fx_reveal.reveal()
+ el.addEvent('click',function(e){
-});
+ fx_reveal.dissolve();
+
+ });
+
+ });
+
+ $$('.statusbutton')[2].addEvent('click',function(e){
+
+ $('addlinks').setStyle('top', e.page.y + 5)
+ $('addlinks').setStyle('left', e.page.x + 5)
+
+ fx_reveal.reveal()
+
+ });
}); \ No newline at end of file
diff --git a/module/web/templates/default.tpl b/module/web/templates/default.tpl
index fe617bfe6..2508455cb 100644
--- a/module/web/templates/default.tpl
+++ b/module/web/templates/default.tpl
@@ -11,7 +11,7 @@
%include header title=header, use_js=js, use_css=['default.css','window.css'], redirect=red
-%include window id="addlinks", width=400, caption="Add links", body="<textarea rows=10 style='width: 345px;'></textarea>", button="Add"
+%include window id="addlinks", width=400, caption="Add links", body="<textarea rows=10 style='width: 345px;' id='linkarea'></textarea>", button="Add"
<a class="anchor" name="top" id="top"></a>
@@ -76,11 +76,15 @@
%if page != "loggedin" and page != "login":
<div id="statusbar">
- <div style="float: left;padding: 8px;">
-Status: running
+ <div id="status" style="float: left;padding: 8px;">
+Status:
</div>
- <div style="float: left;padding: 8px">
-Speed: 500 kb/s  
+ <div id="speed" style="float: left;padding: 8px">
+Speed: 
+</div>
+
+ <div id="queue" style="float: left;padding: 8px">
+Files in queue: 
</div>
<div style="padding-top:2px">
diff --git a/module/web/templates/window.tpl b/module/web/templates/window.tpl
index fce3cb86f..f756c4352 100644
--- a/module/web/templates/window.tpl
+++ b/module/web/templates/window.tpl
@@ -12,7 +12,7 @@
<div class="closeBody">
<div class="closeButtons">
-<a class="closeSticky button">{{button}}</a><a class="closeSticky button">Close</a>
+<a class="closeSticky button" id="bt{{button}}">{{button}}</a><a class="closeSticky button">Close</a>
</div>
</div>