58ce19b76656fc98df5b66ef72a59a1e6ea2e4ab
[squasher.git] / templates / index.tpl
1 {extends file='layout.tpl'}
2
3
4 {block extra_head}
5 <script>
6         {literal}
7         function toggle_id(hideshow){
8                 if(document.getElementById(hideshow).style.visibility == 'visible') {
9                         document.getElementById(hideshow).style.visibility = 'hidden';
10                 }else{
11                         document.getElementById(hideshow).style.visibility = 'visible';
12                 }
13         }
14         function selectAllList() {
15                 var aSelect = document.deletetool["h[]"];
16                 var aSelectLen = aSelect.length;
17                 for(i = 0; i < aSelectLen; i++) {
18                         aSelect.options[i].selected = true;
19                 }
20         }
21         function deleteFolder(foldername) {
22                 if (!confirm('Are you sure you want to delete folder '+foldername+' ?'))
23                         return;
24                 document.rmdir.submit();
25         }
26         function deleteFolderNotEmpty(foldername) {
27                 alert(foldername+' in not empty. Please empty it first');
28         }
29         function createFolder() {
30                 var folder = prompt("New folder name");
31                 if (folder == null)
32                         return; // canceled
33                 if (folder.indexOf('/')>=0 || folder=='.' || folder=='..') {
34                         // detect the most common errors
35                         alert('Invalid name');
36                         return;
37                 }
38                 document.mkdir.newname.value = folder;
39                 document.mkdir.submit();
40         }
41         {/literal}
42 </script>
43 {/block}
44
45
46 {block menu}
47 <div class="menu">
48         <div class="menuhead">current folder</div>
49         {foreach item=crumb key=cookie from=$base}<a href="?path={$cookie|escape:'url'}">{$crumb|escape}</a>{/foreach}
50         {if $user_level > 99 AND count($base)>1 }
51                 <form name=rmdir method=post>
52                 <input type=hidden name=tools value=rmdir>
53                 <a href="javascript:deleteFolder{if count($squashed)>0 || count($subfolders)>0}NotEmpty{/if}('{$currentfolder|escape:'javascript'|escape}');" class=tool>delete this folder</a>
54                 </form>
55         {/if}
56 </div>
57 <div class="menu">
58         <div class="menuhead">subfolders</div>
59         {foreach item=folder key=folderpath from=$subfolders}<a href="?path={$folderpath|escape:'url'}">{$folder|escape}</a>{/foreach}
60         {if $user_level > 99}
61                 <form name=mkdir method=post>
62                 <input type=hidden name=tools value=mkdir>
63                 <input type=hidden name=newname>
64                 <a href="javascript:createFolder();" class=tool>new subfolder</a>
65                 </form>
66         {/if}
67 </div>
68 {/block}
69
70 {block content}
71
72 {function nicesize size=0 totalsize=0}
73 {if $size==$totalsize || !$totalsize}
74         {if $size > 1024*1024}
75         {math equation="x/1024/1024" x=$size format="%.2f"} MiB
76         {elseif $size > 1024}
77         {math equation="x/1024" x=$size format="%.2f"} KiB
78         {else}
79         {$size|escape} B
80         {/if}
81 {else}
82         {if $totalsize > 1024*1024}
83         {math equation="x/1024/1024" x=$size format="%.2f"} / {math equation="x/1024/1024" x=$totalsize format="%.2f"} MiB
84         {elseif $size > 1024}
85         {math equation="x/1024" x=$size format="%.2f"} / {math equation="x/1024" x=$totalsize format="%.2f"} KiB
86         {else}
87         {$size|escape} / {$totalsize|escape} B
88         {/if}
89         ({math equation="pct*100" pct=$size/$totalsize format="%.0f"}%)
90 {/if}
91 {/function}
92
93 {assign var=mass_delete_size value=count($squashed)}
94 {foreach item=item key=id from=$squashed}
95 {if $item.squashed}{*These items are in chunks / uploaded by the squasher tool*}
96
97 {if $item.hidden eq false OR $user_level > 99 }
98 <div class={if $item.finished==true}"status3"{elseif $item.finished!=true && $item.embedable==true}"status2"{elseif $item.finished!=true && $item.embedable!=true}"status1"{else}"item"{/if}>
99
100         <div class="name">{$item.name|escape} {if $user_level > 99}{if $item.hidden}<font color=red>|<a href='?tools=unhide&amp;h={$id|escape:'url'}'>publish</a>|</font>{else}<font color=green>|<a href='?tools=hide&amp;h={$id|escape:'url'}'>hide</a>|</font>{/if}{if $user_level > 100}<font color=red>|<a href='?tools=delete&amp;h={$id|escape:'url'}' onClick="javascript:return confirm('Are you sure you want to permanently delete {$item.name|escape:'quotes'}?')">delete</a>|</font>{/if}{/if}</div>
101
102         <div class="status">status: {$item.status|escape}</div>
103
104         <div class="clear"></div>
105
106         <div class="added">added: {$item.date|escape}</div>
107
108         <div class="size">size: {nicesize size=$item.size*$item.chunks_finished/$item.chunks totalsize=$item.size}</div>
109
110         <div class="clear"></div>
111
112         <div class="updated">last updated: {$item.lastchange|escape}</div>
113
114
115 {if $item.finished==true}
116         <div class="download"><a href='?f={$id|escape:'url'}'>download</a></div>
117 {/if}
118 {if $item.embedable eq true and $item.finished eq false}
119         {if $item.mime=='video/mpeg'}
120         <div class="stream"><a href='?f={$id|escape:'url'}'>download ({math equation="(y / x) * 100" x=$item.chunks y=$item.chunks_partial format="%.0f"}%)</a></div>
121         {/if}
122 {/if}
123
124         <div class="clear"></div>
125 </div>
126         
127 <div class="clear"></div>
128 {/if}
129
130 {else}{*These items are plain files / uploaded manually by the user via ftp*}
131
132 {if $item.hidden eq false OR $user_level > 99 }
133 <div class={if $item.finished==true}"status3"{elseif $item.finished!=true && $item.embedable==true}"status2"{elseif $item.finished!=true && $item.embedable!=true}"status1"{else}"item"{/if}>
134
135         <div class="name">{$item.name|escape} {if $user_level > 99}{if $item.hidden}<font color=red>|<a href='?tools=unhide&amp;h={$id|escape:'url'}'>publish</a>|</font>{else}<font color=green>|<a href='?tools=hide&amp;h={$id|escape:'url'}'>hide</a>|</font>{/if}{if $user_level > 199}<font color=red>|<a href='?tools=delete&amp;h={$id|escape:'url'}' onClick="javascript:return confirm('Are you sure you want to permanently delete {$item.name|escape:'quotes'}?')">delete</a>|</font>{/if}{/if}</div>
136
137         <div class="status">status: {$item.status|escape}</div>
138
139         <div class="clear"></div>
140
141         <div class="added">added: {$item.date|escape}</div>
142
143         <div class="size">size: {nicesize size=$item.size}</div>
144
145         <div class="clear"></div>
146
147         <div class="updated">last updated: {$item.lastchange|escape}</div>
148
149
150 {if $item.finished==true}
151         <div class="download"><a href='?f={$id|escape:'url'}'>download</a></div>
152 {/if}
153 {if $item.embedable eq true and $item.finished eq false}
154         {if $item.mime=='video/mpeg'}
155         <div class="stream"><a href='?f={$id|escape:'url'}'>download (partial)</a></div>
156         {/if}
157 {/if}
158
159         <div class="clear"></div>
160 </div>
161         
162 <div class="clear"></div>
163 {/if}
164 {/if}
165 {/foreach}
166 {/block}
167
168
169 {block filler}
170 <div class="filler">
171 {if $user_level > 100 and $mass_delete_size > 1}
172         <div class="massdelete"><br>
173                 <div class="deletebox" id="deletebox">
174                         <form name="deletetool" action="?tools=delete&amp;h=multiple" method="post" onSubmit='return confirm("Are you sure you want to delete the selected files? \nThis page may take a while to reload while the files are removed.");'>
175                                 <select multiple="" size="{$mass_delete_size|escape}" id="h" name="h[]" width="300px">
176                                         {foreach item=item key=id from=$squashed}
177                                         <option value="{$id|escape}" title="{$item.name|escape}">{$item.name|truncate:39|escape}</option>
178                                         {/foreach}
179                                 </select>
180                                 <input type="button" value="Select All" OnClick="selectAllList();" ><input type="reset" value="Clear"><input type="submit" value="Delete Selected Items">
181                         </form>
182                 </div>
183         </div>
184 {/if}
185 </div>
186 {/block}
187
188
189 {* vim: set syntax=smarty ts=4 sw=4 sts=4 sr noet: *}