var offset;
var showHidden = null;
var Xtools = null;
var zIndex = 1000;
function getPointer(e) {
if (is_ie) {
DocX = event.clientX + document.body.scrollLeft;
DocY = event.clientY + document.body.scrollTop;
} else {
DocX = e.pageX;
DocY = e.pageY;
}
}
function loadHistory(filename){
cExecute_('./index.php?menuaction=filemanager.uifilemanager.history&file='+base64_encode(filename)+"&path="+base64_encode(currentPath),draw_window);
}
function loadXtools()
{
if( Xtools == null )
Xtools = new xtools( path_filemanager + "tp/expressowindow/" );
}
function loadPermissions(data)
{
var permission = parseInt(data);
var ACL_READ = 1;
var ACL_ADD = 2;
var ACL_EDIT = 4;
var ACL_DELETE = 8;
var ACL_PRIVATE = 16;
permissions['read']=(permission & ACL_READ);
permissions['add']=(permission & ACL_ADD);
permissions['edit']=(permission & ACL_EDIT);
permissions['delete']=(permission & ACL_DELETE);
permissions['private']=(permission & ACL_PRIVATE);
toolbar.load();
}
function close_window()
{
_winBuild( 'dwindow' + (zIndex-1) , "remove" );
}
function draw_window( )
{
if( arguments.length > 0 )
{
var htmlData = arguments[0];
var sizeW = ( arguments[1] ) ? arguments[1] : 420 ;
var sizeH = ( arguments[2] ) ? arguments[2] : 200 ;
var titleAction = ( arguments[3] ) ? " - " + arguments[3] : "";
var _janela =
{
id_window : "dwindow"+zIndex,
width : sizeW,
height : sizeH,
top : 200,
left : ( ( screen.width / 2 ) - ( sizeW / 2) ),
draggable : true,
visible : "display",
resizable : true,
zindex : ++zIndex,
title : "Expresso - " + get_lang("filemanager") + titleAction,
closeAction : "remove",
content : htmlData
};
_winBuild( _janela );
}
}
function draw_menu()
{
var _options = arguments[0];
var _parent = arguments[1];
var dt = new Date();
if( showHidden == null )
showHidden = new ShowHidden( 200 );
var _itens = "";
for( var i in _options )
{
if( _options[i].constructor == Function )
continue;
_itens += '
';
_itens += '' + _options[i][0] + '
'
}
var _optionsItens = document.createElement("div");
_optionsItens.id = "fastMenuFileManager";
_optionsItens.className = "x-menu";
_optionsItens.style.zIndex = zIndex++;
_optionsItens.innerHTML = _itens;
_optionsItens.onclick = function(){ showHidden.hiddenObject(false); };
_optionsItens.onmouseout = function(){ showHidden.hiddenObject(false); };
_optionsItens.onmouseover = function(){ showHidden.hiddenObject(true); };
showHidden.action('onmouseover', 'onmouseout', _optionsItens);
_parent.parentNode.appendChild( _optionsItens );
}
function resizeDiv(){
defaultHeight = document.body.clientHeight ? document.body.clientHeight : document.body.offsetHeight;
document.getElementById('fmFileWindow').style.height = defaultHeight-170;
document.getElementById('content_folders').style.height = defaultHeight - (is_ie ? 230 : 215);
}
var headerMsgLock = false;
var labelBefore = "";
function write_msg (message){
connector.hideProgressBar();
if (headerMsgLock){
setTimeout('write_msg("'+message+'");', 300);
return;
}
headerMsgLock = true;
headerDiv = document.getElementById("main_title");
labelBefore = headerDiv.innerHTML;
headerDiv.innerHTML = '
';
setTimeout('headerMsgLock = false; document.getElementById("main_title").innerHTML = labelBefore;', 3000);
}
function write_error (message){
connector.hideProgressBar();
if (headerMsgLock){
setTimeout('write_error("'+message+'");', 300);
return;
}
headerMsgLock = true;
headerDiv = document.getElementById("main_title");
labelBefore = headerDiv.innerHTML;
headerDiv.innerHTML = '';
setTimeout('headerMsgLock = false; document.getElementById("main_title").innerHTML = labelBefore;', 3000);
}
function displayMessages(){
var messages = document.getElementById("allMessages");
for (i=0; i < messages.childNodes.length; i++){
if (messages.childNodes[i].innerHTML.indexOf(get_lang('Error:')) == 0)
write_error(messages.childNodes[i].innerHTML);
else
write_msg(messages.childNodes[i].innerHTML);
}
}
function loadPreferences(){
preferencesEl = document.getElementById('userPreferences');
preferences = unserialize(preferencesEl.value);
preferencesEl.parentNode.removeChild(preferencesEl);
}
function reloadFiles(newCriteria){
if (newCriteria == criteria)
order_type = (order_type=='1'?'0':'1')
else
criteria = newCriteria;
toolbar.control('reload');
}
function initDrawApi(){
SecEl = document.getElementById('userKey');
crypt = new crypt(SecEl.value);
SecEl.parentNode.removeChild(SecEl);
loadPreferences();
preferences.files_per_page = (preferences.files_per_page != undefined) ? preferences.files_per_page : 10;
offset = (current_page-1)*preferences.files_per_page;
currentPath = document.getElementById('currentPath').value;
document.getElementById('divAppboxHeader').innerHTML = title_app;
displayMessages();
resizeDiv();
window.onresize = resizeDiv;
document.body.style.overflow = "hidden";
cExecute_('./index.php?menuaction=filemanager.uifilemanager.get_folders_list',handler.draw_folders_list);
}
function folderList(){
this.td = '';
}
folderList.prototype.init = function(){
this.element = document.getElementById('fmFileWindow');
}
folderList.prototype.clear = function(){
this.element.innerHTML = "";
}
folderList.prototype.drawSearch = function(data){
var fl = folderList;
var files = unserialize(data);
if (files == null)
{
alert(get_lang('No results found'));
return
}
toolbar.clear();
fl.init();
fl.clear();
var newpage;
var sp_hd = ' | | | ';
newpage += fl.td+sp_hd+' id="name">'+get_lang('file name')+sp_tl;
newpage += fl.td+sp_hd+' id="folder">'+get_lang('folder')+sp_tl;
if (preferences.mime_type =='1')
newpage += fl.td+sp_hd+' id="mime_type">'+get_lang('mime type')+sp_tl;
if (preferences.size =='1')
newpage += fl.td+sp_hd+' id="size">'+get_lang('size')+''+sp_tl;
if (preferences.created =='1')
newpage += fl.td+sp_hd+' id="created">'+get_lang('created')+''+sp_tl;
if (preferences.modified =='1')
newpage += fl.td+sp_hd+' id="modified">'+get_lang('modified')+''+sp_tl;
if (preferences.createdby_id =='1')
newpage += fl.td+sp_hd+' id="createdby_id">'+get_lang('created by')+''+sp_tl;
if (preferences.modifiedby_id =='1')
newpage += fl.td+sp_hd+' id="modifiedby_id">'+get_lang('modified by')+''+sp_tl;
if (preferences.comment =='1')
newpage += fl.td+sp_hd+' id="comment">'+get_lang('comment')+''+sp_tl;
if (preferences.version =='1') newpage += fl.td+sp_hd+' id="version">'+get_lang('version')+''+sp_tl+'';
for (var i=0; i < files.length; i++)
{
newpage += ''+fl.td;
newpage += '';
newpage += ' | | ';
newpage += fl.td+'
';
newpage += ''+files[i].name+' ';
newpage += fl.td+files[i].directory+'';
if (preferences.mime_type =='1') newpage += fl.td+files[i].mime_type+'';
if (preferences.size =='1') newpage += fl.td+borkb(files[i].size)+'';
if (preferences.created =='1') newpage += fl.td+files[i].created+'';
if (preferences.modified =='1') newpage += fl.td+files[i].modified+'';
if (preferences.createdby_id =='1') newpage += fl.td+files[i].createdby_id+'';
if (preferences.modifiedby_id =='1') newpage += fl.td+files[i].modifiedby_id+'';
if (preferences.comment =='1') newpage += fl.td+''+files[i].comment+'';
if (preferences.version =='1') newpage += fl.td+''+files[i].version+'
';
}
fl.element.innerHTML = newpage;
fl.drawStripes();
}
folderList.prototype.createLine = function(file){
var fl = folderList;
retBuff = '';
retBuff += fl.td;
retBuff += '';
if (permissions['private']) {
retBuff += ' | ';
}
else
retBuff += ' | ';
switch (file.mime_type)
{
case 'text/html':
retBuff += ' | ';
break;
case 'application/zip':
retBuff += ' | '
break;
default:
retBuff += ' | ';
}
retBuff += fl.td+'';
if((file.mime_type).toUpperCase().indexOf('IMAGE') == 0)
var mousefunc = 'draw_card(\'preview\',\''+file.name+'\')'
else
var mousefunc = 'hide_card()';
retBuff += ''+file.name+'
';
if (preferences.mime_type =='1') retBuff += fl.td+file.mime_type+'';
if (preferences.size =='1') retBuff += fl.td+borkb(file.size)+'';
var now = new Date();
var midnight = Date.parse(now.toDateString());
var dtString = "";
if (preferences.created =='1') {
var created = new Date();
created.setTime(file.created*1000);
if (created.getTime() > midnight)
if (created.getMinutes() < 10 )
dtString = created.getHours()+":0"+created.getMinutes();
else
dtString = created.getHours()+":"+created.getMinutes();
else {
dtString = (created.getDate() < 10) ? "0"+created.getDate()+"/" : created.getDate()+"/";
dtString += (created.getMonth() < 9) ? "0" : "";
dtString += (created.getMonth()+1)+"/"+created.getFullYear();
}
retBuff += fl.td+dtString+'';
}
if (preferences.modified =='1'){
var modified = new Date();
modified.setTime(file.modified*1000);
if (file.modified != "")
if (modified.getTime() > midnight)
if (modified.getMinutes() < 10)
dtString = modified.getHours()+":0"+modified.getMinutes();
else
dtString = modified.getHours()+":"+modified.getMinutes();
else {
dtString = (modified.getDate() < 10) ? "0"+modified.getDate()+"/" : modified.getDate()+"/";
dtString += (modified.getMonth() < 9) ? "0" : "";
dtString += (modified.getMonth()+1)+"/"+modified.getFullYear();
}
else
dtString = "";
retBuff += fl.td+dtString+'';
}
if (preferences.owner =='1'){
retBuff += fl.td;
retBuff += ''+file.owner+'
';
}
if (preferences.createdby_id =='1'){
retBuff += fl.td;
retBuff += ''+file.createdby_id+'
';
}
if (preferences.modifiedby_id =='1'){
retBuff += fl.td;
retBuff += ''+file.modifiedby_id+'
';
}
if (preferences.comment =='1') retBuff += fl.td+'';
if (preferences.version =='1') retBuff += fl.td+''+file.version+'';
retBuff += "
";
return retBuff;
}
folderList.prototype.updateQuota = function(quotaSize,usedSpace){
if (parseInt(quotaSize) != 0){
var contentQuota = document.getElementById('content_quota');
if (contentQuota != null)
contentQuota.innerHTML = '';
}
}
folderList.prototype.drawFiles = function(data){
var fl = folderList;
var returnData = unserialize(data);
loadPermissions(returnData.permissions);
var files = returnData.files;
draw_paging(returnData.files_count,data);
fl.init();
fl.clear();
var newpage = '';
if (preferences.viewIcons == 1){
for (var i = 0; i < files.length; i++)
{
newicon = '';
newpage += newicon;
}
fl.element.innerHTML = newpage;
}
else
{
var sp_hd = '';
if (files != null)
for (var i = 0; i < files.length; i++)
{
newpage += fl.createLine(files[i]);
}
else
newpage = ""+get_lang('no files in this directory.')+"";
fl.element.innerHTML = newpage;
header = document.getElementsByName('head');
for (var i=0; i < header.length; i++)
{
if (header[i].id == criteria){
header[i].style.fontWeight = 'bold';
arrow = document.createElement('IMG');
if (order_type == '1')
arrow.src = templatePath+'images/arrow_ascendant.gif';
else
arrow.src = templatePath+'images/arrow_descendant.gif';
header[i].appendChild(arrow);
}
}
fl.drawStripes();
}
folderList.updateQuota(returnData.quota.quotaSize,returnData.quota.usedSpace);
}
folderList.prototype.drawStripes = function(){
var classTr = "tr_msg_read";
folderList.init();
var elements = folderList.element.firstChild.firstChild.childNodes;
for (var i = 1; i < elements.length; i++){
elements[i].className = classTr;
classTr = (classTr == "tr_msg_read"?"tr_msg_read2":"tr_msg_read");
}
}
var folderList = new folderList();
function toolbar()
{
var element;
}
toolbar.prototype.clear = function (){
this.element.innerHTML = "";
}
toolbar.prototype.load = function (){
this.element = document.getElementById('fmMenu');
if (permissions['read'] == 0){
this.element.innerHTML = "";
return;
}
var pageContent = '';
var createButton = function(name) { return ' '+get_lang(name.replace('_',' '))+' | '; }
if (permissions['edit'] != 0){
pageContent += createButton('edit');
pageContent += createButton('rename');
}
if (permissions['delete'] != 0){
pageContent += createButton('delete');
pageContent += createButton('move_to');
}
pageContent += createButton('copy_to');
this.element.innerHTML = pageContent+'
';
}
toolbar.prototype.getCheckedFiles = function () {
filesUrl = "";
var one_checked = false;
files=document.getElementsByName('fileman');
var j=0;
for (i = 0; i < files.length; i++)
if (files[i].checked){
one_checked = true;
filesUrl += "&fileman["+j+"]="+base64_encode(files[i].value);
j++;
}
if (!one_checked)
{
write_msg(get_lang('Please select a file'));
return;
}
return filesUrl;
}
toolbar.prototype.control = function ()
{
var _arg = arguments[0];
var _parent = ( arguments[1] ) ? arguments[1] : null ;
switch ( _arg )
{
case 'new':
address = document.location.toString();
address = address.split("?");
var itens = [
[ get_lang('empty file'),'javascript:newEmptyFile()',templatePath+'images/group_close.gif', '' ],
[ get_lang('File from model'), address[0]+"?menuaction=filemanager.uifilemanager.fileModels", templatePath+'images/group_close.gif', '' ],
[ get_lang('Upload'), 'javascript:newUpload()', templatePath+'images/group_close.gif', '' ]
];
draw_menu( itens, _parent );
break;
case 'rename':
var one_checked = false;
files=document.getElementsByName('fileman');
for (i = 0; i < files.length; i++)
if (files[i].checked){
one_checked = true;
files[i].checked = false;
var nameLink = document.getElementById('name_'+files[i].value);
var inputName = document.createElement('INPUT');
inputName.id = 'input_'+files[i].value;
var filename = nameLink.innerHTML;
inputName.value = filename;
inputName.onclick = function () { oldValue = inputName.value; }
inputName.onblur = function () { if (inputName.value == oldValue) handler.rename(); else cExecute_('./index.php?menuaction=filemanager.vfs_functions.rename&file='+base64_encode(this.id.substr(6))+'&to='+base64_encode(this.value)+"&path="+base64_encode(currentPath),handler.rename) };
inputName.onkeydown=function (event) {if (event.keyCode == KEY_ENTER) this.blur(); };
nameLink.parentNode.appendChild(inputName);
nameLink.parentNode.removeChild(nameLink);
}
if (!one_checked)
write_msg(get_lang('Please select a file'));
break;
case 'edit':
var one_checked = false;
files=document.getElementsByName('fileman');
for (i = 0; i < files.length; i++)
if (files[i].checked){
one_checked = true;
var filename=files[i].value;
}
if (one_checked){
address = document.location.toString();
address = address.split("&");
document.location = address[0]+"&"+arg+".x=1&filename="+base64_encode(filename)+".&path="+base64_encode(currentPath);
}
else
{
write_msg(get_lang('Please select a file'));
return;
}
break;
case 'delete':
var filesUrl = this.getCheckedFiles();
cExecute_('./index.php?menuaction=filemanager.vfs_functions.delete&path='+
base64_encode(currentPath)+filesUrl,handler.del);
break;
case 'archive':
var filesUrl = this.getCheckedFiles();
password = prompt(get_lang('Please, type a strong password (suggestion: at least 8 characters, letters and numbers) or leave it empty to archive only'));
if (password == null)
return;
if (password.length > 0)
{
password2 = prompt(get_lang('Please, retype your password'));
if (password != password2)
{
alert(get_lang('Error:')+get_lang('passwords are differents'));
return;
}
}
var pswd = crypt.encode(password);
cExecute_('./index.php?menuaction=filemanager.vfs_functions.archive&pswd='+base64_encode(pswd.toString())+'&path='+base64_encode(currentPath)+filesUrl,handler.archive);
break;
case 'move_to':
case 'copy_to':
var filesUrl = this.getCheckedFiles();
if ( filesUrl != undefined)
{
DocY -= ( folders.length * 30 );
var action = ( ( _arg == 'move_to') ? get_lang('move to:') : get_lang('copy to:') );
loadXtools();
var _xml = Xtools.xml('files');
var _files = _xml.documentElement;
var _links = _xml.createElement('links');
for( var i = 0 ; i < folders.length ; i++ )
{
var _lk = _xml.createElement('lk');
_lk.setAttribute('function', "javascript:"+escape(_arg)+"('"+folders[i]+"','"+filesUrl+"'); close_window();" );
_lk.appendChild( _xml.createTextNode( folders[i].replace( my_home_filemanager , get_lang("My folder") ) ) );
_links.appendChild( _lk );
}
_files.appendChild( _links );
var img_1 = path_filemanager + "templates/default/images/button_copy_to.png";
var img_2 = path_filemanager + "templates/default/images/button_move_to.png";
var img_3 = templatePath+"images/group_close.gif";
var pArgs =
{
'action' : action,
'img' : ( ( _arg == 'move_to') ? img_2 : img_1 ),
'img_1' : img_3,
'width' : 380,
'height' : 200
};
var code = Xtools.parse( _files, "copy_move_files.xsl", pArgs );
draw_window( code , 380, 200 );
}
break;
case 'reload':
last_folder = last_folder ? last_folder : currentPath;
current_folder = ( current_folder != "" ) ? current_folder : currentPath;
cExecute_('./index.php?menuaction=filemanager.uifilemanager.dir_ls&path='+base64_encode(currentPath)+'&criteria='+criteria+'&otype='+order_type+'&limit='+preferences.files_per_page+'&offset='+offset,folderList.drawFiles);
return;
case 'tools':
var itens = [
[ get_lang('Preferences'), 'preferences/preferences.php?appname=filemanager', templatePath+'images/preferences.png', 'width="16px" height="16px"' ],
[ get_lang('Edit Folders'), 'javascript:editFolders()', templatePath+'images/button_createdir.png', 'width="16px" height="16px"'],
[ get_lang('Share Folders'), './index.php?menuaction=preferences.uiaclprefs.index&acl_app=filemanager', templatePath+'images/mime16_directory.png', 'width="16px" height="16px"'],
[ get_lang('View'), 'javascript:EditColumns()', templatePath+'images/editpaste.png', 'width="16px" height="16px"' ],
[ get_lang('Archive'), 'javascript:toolbar.control("archive")', templatePath+'images/button_zip.png', 'width="16px" height="16px"' ]
];
draw_menu( itens, _parent );
break;
default:
return;
}
}
var toolbar = new toolbar();
function unarchive(filename)
{
password = crypt.encode(prompt(get_lang('Please, type archive password or leave it empty if it is not encrypted')));
if (password == null)
return;
cExecute_('./index.php?menuaction=filemanager.vfs_functions.unarchive&pswd='+base64_encode(password)+'&path='+base64_encode(currentPath)+'&file='+base64_encode(filename),handler.archive);
}
function move_to(to,filesUrl)
{
cExecute_('./index.php?menuaction=filemanager.vfs_functions.moveto&from='+base64_encode(currentPath)+'&to='+base64_encode(to)+filesUrl,handler.moveto);
}
function copy_to(to,filesUrl)
{
cExecute_('./index.php?menuaction=filemanager.vfs_functions.copyto&from='+base64_encode(currentPath)+'&to='+base64_encode(to)+filesUrl,handler.copyto);
}
function draw_card(type,name)
{
clearTimeout(menuTimeout);
switch(type){
case 'preview':
var url = './index.php?menuaction=filemanager.vfs_functions.summary&file='+base64_encode(name)+"&path="+base64_encode(currentPath);
var htmlData = '
';
menuTimeout = setTimeout("draw_window_card(\'"+htmlData+"\')",500);
break;
case 'user':
var url = './index.php?menuaction=filemanager.user.card&lid='+base64_encode(name);
menuTimeout = setTimeout("cExecute_('"+url+"',draw_window_card)",500);
break;
default:
break;
}
}
function editFolders( operation )
{
if( operation == 'new' || operation == 'remove')
{
var _selectFolders = document.getElementById('folders_box');
var Dfolder = "";
var parentDir = "";
for( var i = 0 ; i < _selectFolders.options.length; i++ )
{
if( _selectFolders.options[i].selected )
{
Dfolder = _selectFolders.options[i].value;
parentDir = _selectFolders.options[i].value;
}
}
}
if ( operation == 'new' )
{
var name = prompt(get_lang('Enter with the name of new file/directory'), '');
if ( name != null && name != '' )
{
if( parentDir == "" )
parentDir = my_home_filemanager;
var parentDir_en = base64_encode( parentDir );
cExecute_('./index.php?menuaction=filemanager.uifilemanager.createdir&path='+parentDir_en+'&filename='+base64_encode(name), handler.refreshDir);
currentPath = parentDir + '/' + name;
close_window();
}
}
else
{
if ( operation == 'remove' )
{
if( Dfolder != "" )
{
if ( confirm(get_lang('Do you really want to remove folder: %1?',
Dfolder.replace(my_home_filemanager, get_lang("My folder"))), '') )
{
var Dfolder_en = base64_encode( Dfolder );
cExecute_('./index.php?menuaction=filemanager.uifilemanager.removedir&path=' + Dfolder_en ,handler.refreshDir );
var lastIndex = Dfolder.lastIndexOf('/');
currentPath = Dfolder.substr(0,lastIndex);
close_window();
}
}
else
alert( get_lang("You must choose a folder !") );
}
else
{
loadXtools();
var _xml = Xtools.xml("root");
var _doc = _xml.documentElement;
var _folders = _xml.createElement("folders");
for( var i = 0; i < folders.length; i++ )
{
if( folders[i].indexOf(my_home_filemanager) > -1 )
{
var fd = _xml.createElement('name');
fd.setAttribute('value', folders[i] );
fd.appendChild( _xml.createTextNode(folders[i].replace(my_home_filemanager, get_lang("My folder"))) );
_folders.appendChild(fd);
}
}
_doc.appendChild( _folders );
var pArgs =
{
'lang_new_folder' : get_lang('new folder'),
'lang_remove_folder' : get_lang('remove folder'),
'path_filemanager' : path_filemanager,
'onclick_new_folder' : 'editFolders("new")',
'onclick_remove_folder' : 'editFolders("remove")'
};
var code = Xtools.parse( _doc, "edit_folders.xsl", pArgs );
draw_window( code, 310, 230 );
}
}
}
function draw_window_card(content){
var menu = document.getElementById('menu_newFile');
if (menu == null){
menu = document.createElement('DIV');
menu.className = 'menubox';
menu.id = "menu_newFile";
menu.style.left = DocX;
menu.style.top = (DocY+20)+"px";
menu.width = "100%";
menu.onmouseout = function () { menuTimeout = setTimeout("hide_card()",50);}
menu.onmouseover = function () { clearTimeout(menuTimeout); };
menu.style.zIndex='1';
document.getElementById('divAppbox').appendChild(menu);
}
else
{
menu.style.left = DocX;
menu.style.top = (DocY+20)+"px";
}
menu.innerHTML = content;
menu.style.visibility = 'visible';
clearTimeout(menuTimeout);
menuTimeout = setTimeout("hide_card()",4000);
}
function hide_card(){
var e=document.getElementById('menu_newFile');
if (e!=null)
e.style.visibility = 'hidden';
}
function draw_paging(num_files,data){
num_files = parseInt(num_files);
total_pages = 1;
if(last_folder != current_folder){
lastPage = 1;
current_page = 1;
last_folder = current_folder;
}
if(num_files > parseInt(preferences.files_per_page)) {
total_pages = parseInt(num_files/preferences.files_per_page);
if((num_files/preferences.files_per_page) > total_pages)
total_pages++;
}
if(total_pages == 1) {
if(span_paging = document.getElementById("span_paging")) {
span_paging.parentNode.removeChild(span_paging);
}
return;
}
span_paging = document.getElementById("span_paging");
if(!span_paging){
span_paging = document.createElement("DIV");
span_paging.id = "span_paging";
span_paging.className = "boxHeaderText";
span_paging.align="right";
document.getElementById("div_menu_c3").appendChild(span_paging);
}
span_paging.style.width="100%";
span_paging.innerHTML="";
files_range_begin = 1;
files_range_end = preferences.files_per_page;
if(current_page != 1) {
lnk_page = document.createElement("A");
lnk_page.setAttribute("href", "javascript:current_page=1;offset=0;toolbar.control('reload');");
}
else {
lnk_page = document.createElement("SPAN");
}
span_paging.appendChild(lnk_page);
lnk_page.innerHTML = "<<";
lnk_page.title = get_lang("First");
span_paging.innerHTML += " ";
if(current_page == lastPage + numPages)
lastPage = current_page - 1;
else if((lastPage != 1 && lastPage == current_page) || current_page == total_pages)
lastPage = current_page - (numPages - 1);
else if(current_page == 1)
lastPage = 1;
if(lastPage < 1)
lastPage = 1;
else if(lastPage > 1 && (lastPage > (total_pages -(numPages - 1))))
lastPage = total_pages -(numPages - 1);
var hasMarked = false;
for(i = lastPage; i <= total_pages; i++) {
if(current_page == i || (i == total_pages && !hasMarked)) {
lnk_page = document.createElement("SPAN");
span_paging.appendChild(lnk_page);
lnk_page.innerHTML = " "+i+" ";
hasMarked = true;
continue;
}
else{
lnk_page = document.createElement("A");
span_paging.appendChild(lnk_page);
files_range_begin = ((i*preferences.files_per_page)-(preferences.files_per_page-1));
files_range_end = (i*preferences.files_per_page);
lnk_page.setAttribute("href", "javascript:current_page="+i+";offset=((current_page-1)*preferences.files_per_page);toolbar.control('reload');");
}
lnk_page.innerHTML = " ... ";
if(i == (lastPage + numPages))
break;
else if(lastPage == 1 || i != lastPage)
lnk_page.innerHTML = " "+i+" ";
span_paging.innerHTML += " ";
}
if(current_page != total_pages) {
lnk_page = document.createElement("A");
files_range_begin = ((total_pages*preferences.files_per_page)-(preferences.files_per_page-1));
files_range_end = (total_pages*preferences.files_per_page);
lnk_page.setAttribute("href", "javascript:current_page="+total_pages+";offset=((current_page-1)*preferences.files_per_page);toolbar.control('reload');");
}
else {
lnk_page = document.createElement("SPAN");
}
span_paging.innerHTML += " ";
span_paging.appendChild(lnk_page);
lnk_page.title = get_lang("Last");
lnk_page.innerHTML = ">>";
}