[3569] | 1 | |
---|
| 2 | var Xtools = null; |
---|
| 3 | |
---|
| 4 | function load(path,el) |
---|
| 5 | { |
---|
[3019] | 6 | currentPath = path; |
---|
| 7 | contentFolders = document.getElementById('content_folders'); |
---|
| 8 | for (i=0; i < contentFolders.childNodes.length; i++) |
---|
| 9 | if (contentFolders.childNodes[i].className == "sl") |
---|
| 10 | contentFolders.childNodes[i].className = "l"; |
---|
| 11 | el.className = "sl"; |
---|
| 12 | current_folder = currentPath; |
---|
| 13 | if(last_folder != current_folder){ |
---|
| 14 | lastPage = 1; |
---|
| 15 | current_page = 1; |
---|
| 16 | last_folder = current_folder; |
---|
| 17 | offset = 0; |
---|
| 18 | } |
---|
| 19 | toolbar.control('reload'); |
---|
| 20 | } |
---|
| 21 | |
---|
[3610] | 22 | function loadXtools() |
---|
| 23 | { |
---|
| 24 | if( Xtools == null ) |
---|
| 25 | Xtools = new xtools( path_filemanager + "tp/expressowindow/" ); |
---|
| 26 | } |
---|
| 27 | |
---|
[3569] | 28 | function check(element) |
---|
| 29 | { |
---|
[3019] | 30 | element.firstChild.firstChild.checked = true; |
---|
| 31 | } |
---|
| 32 | |
---|
[3913] | 33 | function configEvents(pObj, pEvent, pHandler) |
---|
| 34 | { |
---|
| 35 | if ( typeof pObj == 'object' ) |
---|
| 36 | { |
---|
| 37 | if ( pEvent.substring(0, 2) == 'on' ) |
---|
| 38 | pEvent = pEvent.substring(2, pEvent.length ); |
---|
| 39 | |
---|
| 40 | if ( arguments.length == 3 ) |
---|
| 41 | { |
---|
| 42 | if ( pObj.addEventListener ) |
---|
| 43 | pObj.addEventListener(pEvent, pHandler, false ); |
---|
| 44 | else if ( pObj.attachEvent ) |
---|
| 45 | pObj.attachEvent( 'on' + pEvent, pHandler ); |
---|
| 46 | } |
---|
| 47 | else if ( arguments.length == 4 ) |
---|
| 48 | { |
---|
| 49 | if ( pObj.removeEventListener ) |
---|
| 50 | pObj.removeEventListener( pEvent, pHandler, false ); |
---|
| 51 | else if ( pObj.detachEvent ) |
---|
| 52 | pObj.detachEvent( 'on' + pEvent, pHandler ); |
---|
| 53 | } |
---|
| 54 | } |
---|
| 55 | } |
---|
| 56 | |
---|
[3888] | 57 | function maxFileSize() |
---|
| 58 | { |
---|
| 59 | if( arguments.length > 0 ) |
---|
| 60 | { |
---|
| 61 | var _document = arguments[0]; |
---|
| 62 | var _maxFileSize = ""; |
---|
| 63 | |
---|
| 64 | for(var i = 0 ; i < _document.forms[0].elements.length ; i++ ) |
---|
| 65 | { |
---|
| 66 | if( _document.forms[0].elements[i].type == "text" ) |
---|
| 67 | { |
---|
| 68 | var _name = (_document.forms[0].elements[i].name).toLowerCase(); |
---|
| 69 | |
---|
| 70 | if( _name.indexOf('filemanager_max_file_size') > - 1 ) |
---|
| 71 | _maxFileSize = trim(_document.forms[0].elements[i].value); |
---|
| 72 | } |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | var handlerSubmit = function(data) |
---|
| 76 | { |
---|
| 77 | _document.forms[0].submit.click(); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | if( _maxFileSize != '' ) |
---|
| 81 | { |
---|
| 82 | cExecute_( './index.php?menuaction=filemanager.uifilemanager.setFileMaxSize', handlerSubmit,'maxFileSize=' + _maxFileSize ); |
---|
| 83 | } |
---|
| 84 | else |
---|
| 85 | { |
---|
| 86 | alert('É necessário informar um valor !'); |
---|
| 87 | return false; |
---|
| 88 | } |
---|
| 89 | } |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | function trim(inputString) |
---|
| 93 | { |
---|
| 94 | if ( typeof inputString != "string" ) |
---|
| 95 | return inputString; |
---|
| 96 | |
---|
| 97 | var retValue = inputString; |
---|
| 98 | var ch = retValue.substring(0, 1); |
---|
| 99 | |
---|
| 100 | while (ch == " ") |
---|
| 101 | { |
---|
| 102 | retValue = retValue.substring(1, retValue.length); |
---|
| 103 | ch = retValue.substring(0, 1); |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | ch = retValue.substring(retValue.length-1, retValue.length); |
---|
| 107 | |
---|
| 108 | while (ch == " ") |
---|
| 109 | { |
---|
| 110 | retValue = retValue.substring(0, retValue.length-1); |
---|
| 111 | ch = retValue.substring(retValue.length-1, retValue.length); |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | while (retValue.indexOf(" ") != -1) |
---|
| 115 | { |
---|
| 116 | retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | return retValue; |
---|
| 120 | } |
---|
| 121 | |
---|
[3569] | 122 | function validateFileExtension(fileName) |
---|
| 123 | { |
---|
[3019] | 124 | var error_flag = false; |
---|
| 125 | var fileExtension = fileName.split("."); |
---|
| 126 | fileExtension = fileExtension[(fileExtension.length-1)]; |
---|
| 127 | for(var i=0; i<denyFileExtensions.length; i++) |
---|
| 128 | { |
---|
| 129 | if(denyFileExtensions[i] == fileExtension) |
---|
| 130 | { |
---|
| 131 | error_flag = true; |
---|
| 132 | break; |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | if ( error_flag == true ) |
---|
| 138 | { |
---|
| 139 | write_error(get_lang('File extension forbidden or invalid file') + '.'); |
---|
| 140 | return false; |
---|
| 141 | } |
---|
| 142 | return true; |
---|
| 143 | } |
---|
| 144 | |
---|
[3569] | 145 | function get_lang(_key) |
---|
| 146 | { |
---|
[3019] | 147 | var key = _key.toLowerCase(); |
---|
| 148 | if(array_lang[key]) |
---|
| 149 | var _value = array_lang[key]; |
---|
| 150 | else |
---|
| 151 | var _value = _key+"*"; |
---|
| 152 | |
---|
| 153 | if(arguments.length > 1) |
---|
| 154 | for(j = 1; typeof(arguments[j]) != 'undefined'; j++) |
---|
| 155 | _value = _value.replace("%"+j,arguments[j]); |
---|
| 156 | return _value; |
---|
| 157 | |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | |
---|
[3569] | 161 | function newEmptyFile() |
---|
| 162 | { |
---|
[3019] | 163 | var name = prompt(get_lang('Enter with the name of new file/directory'), ''); |
---|
| 164 | var input_text = document.getElementById('newfile_or_dir'); |
---|
| 165 | if (name != null && name != '' && validateFileExtension(name)) |
---|
| 166 | { |
---|
| 167 | var fileExtension = name.split("."); |
---|
| 168 | fileExtension = fileExtension[1]; |
---|
| 169 | if (typeof(fileExtension) == 'undefined') |
---|
| 170 | input_text.value = name+".html"; |
---|
| 171 | else |
---|
| 172 | input_text.value = name; |
---|
| 173 | address = document.location.toString(); |
---|
| 174 | address = address.split("&"); |
---|
| 175 | document.location = address[0]+"&newfile.x=1&newfile_or_dir="+input_text.value; |
---|
| 176 | |
---|
| 177 | } |
---|
| 178 | } |
---|
[3569] | 179 | |
---|
[3610] | 180 | function newUpload( ) |
---|
[3569] | 181 | { |
---|
[3673] | 182 | if( document.getElementById("dwindownewUpload__parent") == null ) |
---|
[3019] | 183 | { |
---|
[3673] | 184 | var _newUpload = function(data) |
---|
| 185 | { |
---|
| 186 | loadXtools(); |
---|
| 187 | |
---|
| 188 | var pArgs = unserialize(data); |
---|
| 189 | pArgs.lang_click_here = get_lang("Click here"); |
---|
| 190 | pArgs.lang_more_files = get_lang("More files"); |
---|
| 191 | pArgs.lang_send_email = get_lang("Send email"); |
---|
| 192 | pArgs.height = 210; |
---|
| 193 | pArgs.path_filemanager = path_filemanager; |
---|
[3879] | 194 | pArgs.width = 500; |
---|
[3610] | 195 | |
---|
[3673] | 196 | var _html = Xtools.parse( Xtools.xml("upload_files"), "upload.xsl", pArgs ); |
---|
| 197 | |
---|
[3913] | 198 | draw_window( _html, 550, 350, get_lang("upload files"), "newUpload" ); |
---|
[3610] | 199 | |
---|
[3673] | 200 | if( pArgs.emails_to != null ) |
---|
| 201 | sendNotification( pArgs.emails_to ); |
---|
| 202 | } |
---|
| 203 | |
---|
| 204 | address = document.location.toString(); |
---|
| 205 | address = address.split("?"); |
---|
| 206 | var url = address[0]+"?menuaction=filemanager.uifilemanager.showUploadboxes&path="+base64_encode(currentPath); |
---|
| 207 | cExecute_( url, _newUpload ); |
---|
[3019] | 208 | } |
---|
| 209 | } |
---|
[3569] | 210 | |
---|
| 211 | function newAdvancedUpload() |
---|
| 212 | { |
---|
[3610] | 213 | for ( var i = 0 ; i < navigator.plugins.length; i++ ) |
---|
[3569] | 214 | { |
---|
[4983] | 215 | if ( navigator.plugins[i][0].type.match('java') ) |
---|
[3569] | 216 | { |
---|
[3673] | 217 | _winBuild( "dwindownewUpload" , "remove" ); |
---|
[3610] | 218 | |
---|
| 219 | loadXtools(); |
---|
| 220 | |
---|
| 221 | var pArgs = |
---|
| 222 | { |
---|
| 223 | 'iframe_width' : 515, |
---|
| 224 | 'iframe_height' : 320, |
---|
| 225 | 'iframe_src' : path_filemanager + "inc/uploadApp.php?id="+parseInt(Math.random()*Math.pow(10,15)) |
---|
| 226 | }; |
---|
| 227 | |
---|
| 228 | var _html = Xtools.parse( Xtools.xml("upload_files_advanced"), "uploadAdvanced.xsl", pArgs); |
---|
| 229 | |
---|
| 230 | draw_window( _html, 530, 345, get_lang("Advanced Upload") ); |
---|
| 231 | |
---|
[3408] | 232 | return; |
---|
| 233 | } |
---|
[3569] | 234 | } |
---|
| 235 | |
---|
[3672] | 236 | alert( get_lang("You do not have Java installed, plugin not loaded") + "!" ); |
---|
[3367] | 237 | } |
---|
[3019] | 238 | |
---|
[3367] | 239 | |
---|
[3019] | 240 | (function( ) |
---|
| 241 | { |
---|
| 242 | // TODO: use DES, RSA, PGP, or something strong |
---|
| 243 | var sec_key = null; |
---|
| 244 | function encode( data ) |
---|
| 245 | { |
---|
| 246 | if (data == null) |
---|
| 247 | return null; |
---|
| 248 | ret = ""; |
---|
| 249 | for ( var i=0;(i < data.length && data.charCodeAt(i) > 31); i++ ) |
---|
| 250 | { |
---|
| 251 | ret += String.fromCharCode(data.charCodeAt(i) ^ sec_key.charCodeAt(i)); |
---|
| 252 | } |
---|
| 253 | return ret; |
---|
| 254 | } |
---|
| 255 | |
---|
| 256 | function crypt( input ) |
---|
| 257 | { |
---|
| 258 | sec_key = input; |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | crypt.prototype.encode = encode; |
---|
| 262 | window.crypt = crypt; |
---|
| 263 | })( ); |
---|
| 264 | |
---|
| 265 | /* |
---|
| 266 | * base64.js - Base64 encoding and decoding functions |
---|
| 267 | * |
---|
| 268 | * Copyright (c) 2007, David Lindquist <david.lindquist@gmail.com> |
---|
| 269 | * Released under the MIT license |
---|
| 270 | */ |
---|
| 271 | |
---|
| 272 | function base64_encode(str) { |
---|
| 273 | var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; |
---|
| 274 | var encoded = []; |
---|
| 275 | var c = 0; |
---|
| 276 | try { var slen = str.length; } catch (e) { write_error(get_lang('you do not have access to %1',currentPath)); return; }; |
---|
| 277 | while (c < slen) { |
---|
| 278 | var b0 = str.charCodeAt(c++); |
---|
| 279 | var b1 = str.charCodeAt(c++); |
---|
| 280 | var b2 = str.charCodeAt(c++); |
---|
| 281 | var buf = (b0 << 16) + ((b1 || 0) << 8) + (b2 || 0); |
---|
| 282 | var i0 = (buf & (63 << 18)) >> 18; |
---|
| 283 | var i1 = (buf & (63 << 12)) >> 12; |
---|
| 284 | var i2 = isNaN(b1) ? 64 : (buf & (63 << 6)) >> 6; |
---|
| 285 | var i3 = isNaN(b2) ? 64 : (buf & 63); |
---|
| 286 | encoded[encoded.length] = chars.charAt(i0); |
---|
| 287 | encoded[encoded.length] = chars.charAt(i1); |
---|
| 288 | encoded[encoded.length] = chars.charAt(i2); |
---|
| 289 | encoded[encoded.length] = chars.charAt(i3); |
---|
| 290 | } |
---|
| 291 | var retBuff = escape(encoded.join('')); |
---|
| 292 | return retBuff.replace(/\+/g,"%2B"); |
---|
| 293 | } |
---|
| 294 | |
---|
| 295 | function base64_decode(str) { |
---|
| 296 | var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; |
---|
| 297 | var invalid = { |
---|
| 298 | strlen: (str.length % 4 != 0), |
---|
| 299 | chars: new RegExp('[^' + chars + ']').test(str), |
---|
| 300 | equals: (/=/.test(str) && (/=[^=]/.test(str) || /={3}/.test(str))) |
---|
| 301 | }; |
---|
| 302 | if (invalid.strlen || invalid.chars || invalid.equals) |
---|
| 303 | throw new Error('Invalid base64 data'); |
---|
| 304 | var decoded = []; |
---|
| 305 | var c = 0; |
---|
| 306 | while (c < str.length) { |
---|
| 307 | var i0 = chars.indexOf(str.charAt(c++)); |
---|
| 308 | var i1 = chars.indexOf(str.charAt(c++)); |
---|
| 309 | var i2 = chars.indexOf(str.charAt(c++)); |
---|
| 310 | var i3 = chars.indexOf(str.charAt(c++)); |
---|
| 311 | var buf = (i0 << 18) + (i1 << 12) + ((i2 & 63) << 6) + (i3 & 63); |
---|
| 312 | var b0 = (buf & (255 << 16)) >> 16; |
---|
| 313 | var b1 = (i2 == 64) ? -1 : (buf & (255 << 8)) >> 8; |
---|
| 314 | var b2 = (i3 == 64) ? -1 : (buf & 255); |
---|
| 315 | decoded[decoded.length] = String.fromCharCode(b0); |
---|
| 316 | if (b1 >= 0) decoded[decoded.length] = String.fromCharCode(b1); |
---|
| 317 | if (b2 >= 0) decoded[decoded.length] = String.fromCharCode(b2); |
---|
| 318 | } |
---|
| 319 | return decoded.join(''); |
---|
| 320 | } |
---|
| 321 | |
---|
| 322 | |
---|
[3879] | 323 | function setRestricted(name) |
---|
| 324 | { |
---|
[3019] | 325 | var continue_set = confirm(get_lang('This property will change the visibility of all users that have access to this file, continue?')); |
---|
[3879] | 326 | |
---|
| 327 | if ( continue_set ) |
---|
| 328 | { |
---|
| 329 | cExecute_('./index.php?menuaction=filemanager.vfs_functions.setRestricted&file=' |
---|
| 330 | + base64_encode(name)+'&path='+base64_encode(currentPath),handler.restricted); |
---|
| 331 | } |
---|
[3019] | 332 | } |
---|
| 333 | |
---|
[3879] | 334 | function presetComments(el) |
---|
| 335 | { |
---|
[3019] | 336 | if (permissions['edit'] == 0){ |
---|
| 337 | el.blur(); |
---|
| 338 | write_error(get_lang('You have no permission to access this file')); |
---|
| 339 | } |
---|
| 340 | oldValue = el.value; |
---|
| 341 | } |
---|
| 342 | |
---|
[3879] | 343 | function setComments(el) |
---|
| 344 | { |
---|
| 345 | if ( el.value == oldValue ) |
---|
| 346 | return; |
---|
| 347 | |
---|
[3019] | 348 | var filename = base64_encode(el.id); |
---|
[3879] | 349 | |
---|
| 350 | cExecute_('./index.php?menuaction=filemanager.vfs_functions.editComment&file=' |
---|
| 351 | + filename+'&comment='+base64_encode(el.value), handler.updateComment); |
---|
[3019] | 352 | } |
---|
| 353 | |
---|
[3638] | 354 | function enterComments(e,el) |
---|
| 355 | { |
---|
| 356 | if ( e.keyCode == KEY_ENTER ) |
---|
| 357 | { |
---|
[3019] | 358 | el.blur(); |
---|
[3638] | 359 | } |
---|
[3019] | 360 | } |
---|
| 361 | |
---|
[3569] | 362 | function EditColumns( args ) |
---|
| 363 | { |
---|
| 364 | if( args == 'close' ) |
---|
[3019] | 365 | { |
---|
[3569] | 366 | _winBuild("window_tools_view","remove"); |
---|
[3019] | 367 | } |
---|
[3569] | 368 | else if( args == 'save') |
---|
[3019] | 369 | { |
---|
[3679] | 370 | var checkBoxes = document.getElementById('menu_col_pref').getElementsByTagName("input"); |
---|
| 371 | |
---|
[3569] | 372 | for ( var i = 0 ; i < checkBoxes.length; i++) |
---|
[3019] | 373 | { |
---|
[3569] | 374 | if( checkBoxes[i].checked === true ) |
---|
[3019] | 375 | preferences[checkBoxes[i].value] = '1'; |
---|
| 376 | else |
---|
| 377 | preferences[checkBoxes[i].value] = '0'; |
---|
| 378 | } |
---|
[3569] | 379 | |
---|
[3679] | 380 | cExecute_('./index.php?menuaction=filemanager.user.save_preferences',function () { toolbar.control('reload'); EditColumns('close'); }, 'preferences='+serialize(preferences)); |
---|
[3019] | 381 | } |
---|
[3569] | 382 | else |
---|
| 383 | { |
---|
[3610] | 384 | loadXtools(); |
---|
| 385 | |
---|
[3569] | 386 | var pTools = |
---|
| 387 | { |
---|
| 388 | 'checkList' : preferences['viewList'], |
---|
| 389 | 'checkIcons': preferences['viewIcons'], |
---|
| 390 | 'check_created' : preferences['created'], |
---|
| 391 | 'check_createdby_id' : preferences['createdby_id'], |
---|
| 392 | 'check_comment' : preferences['comment'], |
---|
| 393 | 'check_mime_type' : preferences['mime_type'], |
---|
| 394 | 'check_modified' : preferences['modified'], |
---|
| 395 | 'check_modifiedby_id' : preferences['modifiedby_id'], |
---|
| 396 | 'check_owner' : preferences['owner'], |
---|
| 397 | 'check_size' : preferences['size'], |
---|
| 398 | 'check_version' : preferences['version'], |
---|
| 399 | 'lang_cancel' : get_lang('cancel'), |
---|
| 400 | 'lang_created_by' : get_lang('created by'), |
---|
| 401 | 'lang_created' : get_lang('created'), |
---|
| 402 | 'lang_comment' : get_lang('comment'), |
---|
| 403 | 'lang_modified_by' : get_lang('modified by'), |
---|
| 404 | 'lang_modified' : get_lang('modified'), |
---|
| 405 | 'lang_owner' : get_lang('owner'), |
---|
| 406 | 'lang_save' : get_lang('save'), |
---|
| 407 | 'lang_size' : get_lang('size'), |
---|
| 408 | 'lang_type' : get_lang('type'), |
---|
| 409 | 'lang_version' : get_lang('version'), |
---|
| 410 | 'lang_view_as_list' : get_lang('view as list'), |
---|
| 411 | 'lang_view_as_icons' : get_lang('view as icons'), |
---|
| 412 | 'onclickCancel' : "EditColumns(\'close\')", |
---|
| 413 | 'onclickSave' : "EditColumns(\'save\')" |
---|
| 414 | } |
---|
| 415 | |
---|
| 416 | var winTools = |
---|
| 417 | { |
---|
| 418 | id_window : "window_tools_view", |
---|
| 419 | width : 250, |
---|
| 420 | height : 290, |
---|
[3879] | 421 | top : 100, |
---|
| 422 | left : 400, |
---|
[3569] | 423 | draggable : true, |
---|
[3879] | 424 | visible : "display", |
---|
[3569] | 425 | resizable : true, |
---|
| 426 | zindex : zIndex++, |
---|
| 427 | title : "Expresso FileManager - " + get_lang('View'), |
---|
[3879] | 428 | closeAction : "remove", |
---|
[3569] | 429 | content : Xtools.parse(Xtools.xml("view_config"), "view.xsl", pTools) |
---|
| 430 | }; |
---|
| 431 | |
---|
| 432 | _winBuild( winTools ); |
---|
| 433 | } |
---|
[3019] | 434 | } |
---|
| 435 | |
---|
| 436 | |
---|
| 437 | function searchFile(){ |
---|
| 438 | var inputText = document.getElementById('em_message_search'); |
---|
| 439 | if (inputText.value.length < 4) |
---|
| 440 | { |
---|
| 441 | alert(get_lang('Your search must have at least 4 characters')); |
---|
| 442 | return; |
---|
| 443 | } |
---|
| 444 | cExecute_('./index.php?menuaction=filemanager.uifilemanager.search&text='+inputText.value,folderList.drawSearch); |
---|
| 445 | } |
---|
| 446 | function selectAll(el){ |
---|
| 447 | checkBoxes = document.getElementsByName('fileman'); |
---|
| 448 | if (el.checked) |
---|
| 449 | for (i=0; i < checkBoxes.length; i++) |
---|
| 450 | checkBoxes[i].checked = true; |
---|
| 451 | else |
---|
| 452 | for (i=0; i < checkBoxes.length; i++) |
---|
| 453 | checkBoxes[i].checked = false; |
---|
| 454 | |
---|
| 455 | } |
---|
[3610] | 456 | |
---|
| 457 | function borkb(size) |
---|
| 458 | { |
---|
| 459 | var kbyte = 1024; |
---|
| 460 | var mbyte = kbyte*1024; |
---|
| 461 | var gbyte = mbyte*1024; |
---|
| 462 | |
---|
| 463 | if (!size) |
---|
| 464 | { |
---|
| 465 | size = 0; |
---|
| 466 | } |
---|
| 467 | |
---|
| 468 | if (size < kbyte) |
---|
| 469 | { |
---|
[3879] | 470 | return size + ' B'; |
---|
[3610] | 471 | } |
---|
| 472 | else if (size < mbyte) |
---|
| 473 | { |
---|
[3879] | 474 | return parseInt(size/kbyte) + ' KB'; |
---|
[3610] | 475 | } |
---|
| 476 | else if (size < gbyte) |
---|
| 477 | { |
---|
| 478 | if ( size/mbyte > 100) |
---|
[3879] | 479 | return (size/mbyte).toFixed(0) + ' MB'; |
---|
[3610] | 480 | else |
---|
[3879] | 481 | return (size/mbyte).toFixed(1) + ' MB'; |
---|
[3610] | 482 | } |
---|
| 483 | else |
---|
| 484 | { |
---|
[3879] | 485 | return (size/gbyte).toFixed(1) + ' GB'; |
---|
[3610] | 486 | } |
---|
[3019] | 487 | } |
---|
[3610] | 488 | |
---|
| 489 | function addNewInput() |
---|
| 490 | { |
---|
| 491 | var newElement = document.createElement('div'); |
---|
[3879] | 492 | newElement.innerHTML = '<div></div>' + |
---|
| 493 | '<input maxlength="255" name="upload_file[]" type="file" style="margin-right:5px;" />' + |
---|
| 494 | '<input name="upload_comment[]" type="text" style="margin-right:2px;" />' + |
---|
| 495 | '<span style="color:red; cursor:pointer;" onclick="removeInput(this);">'+get_lang('delete')+'</span>'; |
---|
[3610] | 496 | |
---|
| 497 | document.getElementById('uploadOption').parentNode.appendChild(newElement); |
---|
[3019] | 498 | } |
---|
| 499 | |
---|
[3610] | 500 | function removeInput() |
---|
| 501 | { |
---|
| 502 | if( arguments.length > 0 ) |
---|
| 503 | { |
---|
| 504 | var _parent = arguments[0].parentNode; |
---|
| 505 | |
---|
| 506 | _parent.parentNode.removeChild(_parent); |
---|
| 507 | } |
---|
[3415] | 508 | } |
---|
| 509 | |
---|
[3610] | 510 | function sendNotification() |
---|
| 511 | { |
---|
| 512 | var _div = document.getElementById('sendNotifcation'); |
---|
[3638] | 513 | |
---|
| 514 | var _SendNotification = function() |
---|
| 515 | { |
---|
| 516 | var pArgs = |
---|
| 517 | { |
---|
| 518 | 'lang_delete' : get_lang('delete'), |
---|
| 519 | 'lang_send_notification_email_to' : get_lang("Send Notification email to:"), |
---|
| 520 | 'value_email' : ( ( arguments.length > 0 ) ? arguments[0] : "" ) |
---|
| 521 | }; |
---|
[3610] | 522 | |
---|
[3638] | 523 | loadXtools(); |
---|
[3610] | 524 | |
---|
[3638] | 525 | _div.innerHTML += Xtools.parse( Xtools.xml("send_notification"), "send_notification.xsl", pArgs); |
---|
| 526 | } |
---|
| 527 | |
---|
| 528 | if( arguments.length > 0 ) |
---|
[3610] | 529 | { |
---|
[3638] | 530 | var emailsTo = arguments[0].split(","); |
---|
[3610] | 531 | |
---|
[3638] | 532 | _div.innerHTML += "<div style='margin:4 2 2 4px;'>" + |
---|
| 533 | "<label style='font-weight: bold;'>" + get_lang('The following addresses will be notified') + " : </label>" + |
---|
| 534 | "</div>"; |
---|
| 535 | for( var i = 0 ; i < emailsTo.length ; i++ ) |
---|
| 536 | { |
---|
| 537 | _SendNotification( emailsTo[i] ); |
---|
| 538 | _div.innerHTML += "<div style='margin:1 2 1 4px;'> - " + emailsTo[i] + "</div>"; |
---|
| 539 | } |
---|
| 540 | _div.innerHTML += "<br/>"; |
---|
| 541 | } |
---|
| 542 | else |
---|
| 543 | _SendNotification(); |
---|
[3610] | 544 | } |
---|
| 545 | |
---|
| 546 | function sendFiles() |
---|
| 547 | { |
---|
[3619] | 548 | var _formUp = document.getElementById('form_up'); |
---|
[3879] | 549 | var _uploadFiles = document.getElementsByTagName('input'); |
---|
[3619] | 550 | var _flagSend = true; |
---|
| 551 | |
---|
| 552 | for( var i = 0 ; i < _uploadFiles.length ; i++ ) |
---|
| 553 | { |
---|
| 554 | if( _uploadFiles[i].name.indexOf("upload_file") > -1 ) |
---|
| 555 | { |
---|
| 556 | if( _uploadFiles[i].value == "" ) |
---|
| 557 | { |
---|
| 558 | removeInput( _uploadFiles[i] ); |
---|
| 559 | _flagSend = false; |
---|
| 560 | } |
---|
| 561 | } |
---|
| 562 | } |
---|
| 563 | |
---|
| 564 | if( _flagSend ) |
---|
[3879] | 565 | cExecuteForm_( _formUp , handler.upload ); |
---|
[3619] | 566 | else |
---|
| 567 | write_msg(get_lang("No file(s) to send") + "!"); |
---|
| 568 | } |
---|