diff options
Diffstat (limited to 'module')
| -rw-r--r-- | module/web/ajax/urls.py | 1 | ||||
| -rw-r--r-- | module/web/ajax/views.py | 20 | ||||
| -rw-r--r-- | module/web/pyload/views.py | 2 | ||||
| -rw-r--r-- | module/web/templates/default/base.html | 15 | ||||
| -rw-r--r-- | module/web/templates/default/home.html | 38 | ||||
| -rw-r--r-- | module/web/templates/default/window.html | 5 | 
6 files changed, 59 insertions, 22 deletions
| diff --git a/module/web/ajax/urls.py b/module/web/ajax/urls.py index 2a7e109c3..4decc27b1 100644 --- a/module/web/ajax/urls.py +++ b/module/web/ajax/urls.py @@ -12,6 +12,7 @@ urlpatterns = patterns('ajax',                         # Uncomment the next line to enable the admin:                          (r'^add_package$', 'views.add_package'), +                        (r'^remove_link/(\d+)$', 'views.remove_link'),                          (r'^status$', 'views.status'),                          (r'^links$', 'views.links'), #currently active links                         (r'^queue$', 'views.queue'), diff --git a/module/web/ajax/views.py b/module/web/ajax/views.py index 08d87c30e..ea092745f 100644 --- a/module/web/ajax/views.py +++ b/module/web/ajax/views.py @@ -30,7 +30,7 @@ class JsonResponse(HttpResponse):                                     object, indent=2, cls=json.DjangoJSONEncoder,                                     ensure_ascii=False)          super(JsonResponse, self).__init__( -                                           content)#, content_type='application/json') #@TODO uncomment +                                           content, content_type='application/json') #@TODO uncomment          self['Cache-Control'] = 'no-cache, must-revalidate' @@ -38,14 +38,17 @@ class JsonResponse(HttpResponse):  def add_package(request):      name = request.POST['add_name'] +          if name == None or name == "":          return HttpResponseServerError() -    links = request.POST['add_links'].split("\n") +    links = request.POST['add_links'].replace(" ","\n").split("\n")      try:          f = request.FILES['add_file'] +        print f          fpath = join(settings.DL_ROOT, f.name) +        print fpath          destination = open(fpath, 'wb')          for chunk in f.chunks():              destination.write(chunk) @@ -54,12 +57,19 @@ def add_package(request):      except:          pass -    links = filter(lambda x: x is not "", links) -      -    settings.PYLOAD.add_package(name, links) +    links = filter(lambda x: x != "", links) +    settings.PYLOAD.add_package(name, links) +              return JsonResponse("success") +@permission('pyload.can_add_dl') +def remove_link(request, id): +    try: +        settings.PYLOAD.del_links([int(id)]) +        return JsonResponse("sucess") +    except: +        return HttpResponseServerError()  @permission('pyload.can_see_dl')      def status(request): diff --git a/module/web/pyload/views.py b/module/web/pyload/views.py index 55887d711..994075001 100644 --- a/module/web/pyload/views.py +++ b/module/web/pyload/views.py @@ -77,7 +77,7 @@ def queue(request):      for pack in queue:          children = []          for child in settings.PYLOAD.get_package_files(pack["id"]): -            children.append(settings.PYLOAD.get_file_info()) +            children.append(settings.PYLOAD.get_file_info(child))          pack["children"] = children      return render_to_response(join(settings.TEMPLATE, 'queue.html'), RequestContext(request, {'content': queue}, [status_proc])) diff --git a/module/web/templates/default/base.html b/module/web/templates/default/base.html index e4d11ce34..0cebeb5d8 100644 --- a/module/web/templates/default/base.html +++ b/module/web/templates/default/base.html @@ -25,10 +25,11 @@ document.addEvent("domready", function(){  	add_bg = new Fx.Tween($('add_bg'));
  	add_box = new Fx.Tween($('add_box'));
 -
 -	new Form.Request("add_form", $('none_existent'), { onSuccess: function(){
 +	
 +	$('add_form').onsubmit=function() {
 +		$('add_form').target = 'upload_target'; //'upload_target' is the name of the iframe
  		out();
 -		}});
 +	}
  	$('add_reset').addEvent('click', function(){
  		out();
 @@ -37,6 +38,8 @@ document.addEvent("domready", function(){  	var jsonStatus = new Request.JSON({
  		url: "json/status",
  		onSuccess: LoadJsonToContent,
 +		secure: false,
 +                async: true,
  		initialDelay: 0,
  		delay: 4000,
  		limit: 30000
 @@ -54,9 +57,9 @@ document.addEvent("domready", function(){  function LoadJsonToContent(data)
  {
 -	$("speed").textContent = Math.round(data.speed*100)/100;
 -	$("aktiv").textContent = data.queue;
 -	$("queue").textContent = data.total;
 +	$("speed").set('text', Math.round(data.speed*100)/100);
 +	$("aktiv").set('text', data.queue);
 +	$("queue").set('text', data.total);
  }
  function show(){
  	add_bg.set('opacity', 0);
 diff --git a/module/web/templates/default/home.html b/module/web/templates/default/home.html index 02681a23d..4d499f6fe 100644 --- a/module/web/templates/default/home.html +++ b/module/web/templates/default/home.html @@ -19,6 +19,8 @@ var EntryManager = new Class({      initialize: function(){
          this.json = new Request.JSON({
  		url: "json/links",
 +                secure: false,
 +                async: true,
  		onSuccess: this.update.bind(this),
  		initialDelay: 0,
  		delay: 2500,
 @@ -59,8 +61,8 @@ var EntryManager = new Class({          },data).each(function(id){
              index = this.ids.indexOf(id);
              this.entries[index].remove();
 -            this.entries = this.entries.remove(index);
 -            this.ids = this.ids.remove(index);
 +            this.entries = this.entries.filter(function(item){return item.id != this},id);
 +            this.ids = this.ids.erase(id)
              }, this);
          data.links.each(function(link, i){
 @@ -97,6 +99,7 @@ var LinkEntry = new Class({                  info: $("link_{id}_info".substitute({id: this.id})),
                  kbleft: $("link_{id}_kbleft".substitute({id: this.id})),
                  percent: $("link_{id}_percent".substitute({id: this.id})),
 +                remove: $("link_{id}_remove".substitute({id: this.id})),
                  pgbTr: $("link_{id}_pgb_tr".substitute({id: this.id})),
                  pgb: $("link_{id}_pgb".substitute({id: this.id}))
              }
 @@ -104,7 +107,7 @@ var LinkEntry = new Class({          },
          insert: function(item){
              try{
 -            info = SecToRightTime(item.eta)+' @ '+Math.round(item.speed*100)/100+' kb/s' ;
 +            info = SecToRightTime(item.eta) +' @ '+ Math.round(item.speed*100)/100+' kb/s' ;
              this.elements = {
                  tr: new Element('tr', {
 @@ -125,9 +128,20 @@ var LinkEntry = new Class({                  kbleft: new Element('td', {
                  'html': HumanFileSize(item.size)
                  }),
 -                percent: new Element('td', {
 +                percent: new Element('font', {
                  'html': item.percent+ '% / '+ HumanFileSize(item.size-item.kbleft)
                  }),
 +                remove: new Element('img',{
 +                'html': '',
 +                'src': 'media/default/img/control_cancel.png',
 +                'styles':{
 +                    'vertical-align': 'middle',
 +                    'margin-right': '-20px',
 +                    'margin-left': '5px',
 +                    'margin-top': '-2px',
 +                    'cursor': 'pointer'
 +                }
 +                }),
                  pgbTr: new Element('tr', {
                  'html':''
                  }),
 @@ -136,12 +150,12 @@ 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,this.elements.percent);
 +            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));
              this.initEffects();
              }catch(e){
 @@ -149,9 +163,14 @@ var LinkEntry = new Class({              }
          },
          initEffects: function(){
 -            this.bar = new Fx.Morph(this.elements.pgb, {unit: '%', duration: 3000, link: 'chain', fps:30});
 +            this.bar = new Fx.Morph(this.elements.pgb, {unit: '%', duration: 5000, link: 'link', fps:30});
              this.fade = new Fx.Tween(this.elements.tr);
              this.fadeBar = new Fx.Tween(this.elements.pgbTr);
 +            
 +            this.elements.remove.addEvent('click', function(){
 +                new Request({method: 'get', url: 'json/remove_link/'+this.id}).send();
 +            }.bind(this));
 +            
          },
          update: function(item){
                  this.elements.name.set('text', item.name);
 @@ -197,7 +216,10 @@ Active Downloads      <td id="link_{{ link.id }}_status">{{ link.status }}</td>
      <td id="link_{{ link.id }}_info">{{ link.info }}</td>
      <td id="link_{{ link.id }}_kbleft">{{ link.size }}</td>
 -    <td id="link_{{ link.id }}_percent"><font id="link_{{ link.id }}_aktiv_percent">{{ link.percent }}</font>% / <font id="link_{{ link.id }}_aktiv_percent">{{ link.kbleft }}</font></td>
 +    <td>
 +        <font id="link_{{ link.id }}_percent">{{ link.percent }}% /{{ link.kbleft }}</font>
 +        <img id="link_{{ link.id }}_remove" style="vertical-align: middle; margin-right: -20px; margin-left: 5px; margin-top: -2px; cursor:pointer;" src="media/default/img/control_cancel.png"/>
 +    </td>
    </tr>
    <tr id="link_{{ link.id }}_pgb_tr">
      <td span="5">
 diff --git a/module/web/templates/default/window.html b/module/web/templates/default/window.html index daf305892..5f2dc594a 100644 --- a/module/web/templates/default/window.html +++ b/module/web/templates/default/window.html @@ -1,9 +1,10 @@ +<iframe id="upload_target" name="upload_target" src="" style="display: none; width:0;height:0"></iframe>
  <div id="add_bg" style="filter:alpha(opacity:80);KHTMLOpacity:0.80;MozOpacity:0.80;opacity:0.80; background:#000; width:100%; height: 100%; position:absolute; top:0px; left:0px; display:none;"> </div>
  <!--<div id="add_box" style="left:50%; top:200px; margin-left: -450px; width: 900px; position: absolute; background: #FFF; padding: 10px 10px 10px 10px; display:none;">-->
    <!--<div style="width: 900px; text-align: right;"><b onclick="AddBox();">[Close]</b></div>-->
  <div id="add_box" class="myform">
 -<form id="add_form" action="json/add_package" method="post">
 +<form id="add_form" action="json/add_package" method="POST" enctype="multipart/form-data">
  <h1>Add Package</h1>
  <p>Paste your links or upload a container.</p>
  <label>Name
 @@ -19,7 +20,7 @@  <label>File
  <span class="small">Upload a container.</span>
  </label>
 -<input type="file" name="add_file" id="add_file"  />
 +<input type="file" name="add_file" id="add_file"/>
  <button type="submit">Add Package</button>
  <button id="add_reset" style="margin-left:0px;" type="reset">Reset</button>
 | 
