File "phpXplorer.js"
Full Path: /home/analogde/www/JAVA/system/phpXplorer.js
File size: 15.34 KB
MIME-type: text/plain
Charset: utf-8
/***************************************************************
* Copyright notice
*
* (c) 2003-2004 Tobias Bender (tobias@phpXplorer.org)
* All rights reserved
*
* This script is part of the phpXplorer project. The phpXplorer project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt distributed with these scripts.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
var windows = new Array()
function getTypeKeyByExtension(fileName){
var extKey = "";
var strExt = fileName;
do
{
var arrExt = strExt.split(".")
arrExt = arrExt.slice(1)
strExt = arrExt.join(".")
if(eXTT[strExt])
extKey = eXTT[strExt]
if(extKey == "")
if(eXTT[strExt.toLowerCase()])
extKey = eXTT[strExt.toLowerCase()]
}while(arrExt.length > 1 && extKey == "")
return extKey
}
function getExtension(filename){
return filename.split(".").slice(1).join(".")
}
function showInfo(){
var rn = getRndName()
windows[rn] = window.open("./info.php", rn, "scrollbars=yes, resizable=yes, width=380, height=350, left=150, top=150")
}
function createLanguagefile(){
var rn = getRndName()
windows[rn] = window.open("./filetypes/pxl/edit.php?fileName=" + language + ".pxl.php&shareId=system¤tDir=" + systemBaseDir + "/lang.pxlf" + "&lng_id=" + language, rn, "scrollbars=yes, resizable=yes, width=800, height=480, left=150, top=150")
}
function phpInfo(){
var rn = getRndName()
windows[rn] = window.open("./phpInfo.php", rn, "scrollbars=yes, resizable=yes, width=800, height=480, left=150, top=150")
}
function systemRights(){
var rn = getRndName()
windows[rn] = window.open("./filetypes/pxrf/edit.php?fileName=rights.pxrf&shareId=system¤tDir=" + systemBaseDir, rn, "scrollbars=yes, resizable=yes, width=800, height=320, left=150, top=150")
}
function adminShares(){
var rn = getRndName()
windows[rn] = window.open("./filetypes/pxsf/edit.php?fileName=shares.pxsf&shareId=system¤tDir=" + systemBaseDir, rn, "scrollbars=yes, resizable=yes, width=800, height=320, left=150, top=150")
}
function adminUsers(){
var rn = getRndName()
windows[rn] = window.open("./filetypes/pxuf/edit.php?fileName=users.pxuf&shareId=system¤tDir=" + systemBaseDir, rn, "scrollbars=yes, resizable=yes, width=800, height=320, left=150, top=150")
}
function adminRoles(){
var rn = getRndName()
windows[rn] = window.open("./filetypes/htgroups/edit.php?fileName=.htgroups&shareId=system¤tDir=" + systemBaseDir + "&fileName=.htgroups", rn, "scrollbars=yes, resizable=yes, width=320, height=320, left=150, top=150")
}
function update(){
var rn = getRndName()
windows[rn] = window.open("http://www.phpxplorer.org/phpXplorer/website/download.php?language=en", rn, "scrollbars=yes, resizable=yes, width=520, height=480, left=150, top=150")
}
function donate(){
var rn = getRndName()
windows[rn] = window.open("http://www.phpxplorer.org/phpXplorer/website/donate.php?language=en", rn, "scrollbars=yes, resizable=yes, width=800, height=560, left=150, top=150")
}
function bodyKeyUp(event){
switch(event.keyCode){
case 18:
altDown = false
break;
case 17:
strgDown = false
break;
case 46:
deleteSelection()
break;
case 45:
paste()
break;
}
}
function bodyKeyDown(){
switch(event.keyCode){
case 18:
altDown = true
break;
case 17:
strgDown = true
break;
}
}
function headHooverOver(nd){
nd.className = 'headDiv hover'
nd = nd.nextSibling
while(nd.nodeName != "DIV")nd = nd.nextSibling
nd.className = 'sizer hover'
}
function headHooverOut(nd){
nd.className = 'headDiv'
nd = nd.nextSibling
while(nd.nodeName != "DIV")nd = nd.nextSibling
nd.className = 'sizer'
}
function highlightItem(item, view){
for(i = 2; i < item.childNodes.length - 1; i++)
item.childNodes[i].style.backgroundColor = ROW_HIGHLIGHT_COLOR
// item.className="hover"+view
}
function clearHighlightedItem(item, view){
for(i = 2; i < item.childNodes.length - 1; i++)
item.childNodes[i].style.backgroundColor = ''
// item.className=(item.id=="selectedItem")?"selected":""
}
function sort(columnKey){
document.frm1.orderBy.value = columnKey;
if(columnKey == orderBy){
document.frm1.orderDirection.value = (orderDirection == "asc") ? "desc" : "asc"
}else{
document.frm1.orderDirection.value = "asc"
}
document.frm1.submit()
}
function refreshDir(){
if(parent.frames.length > 0)
document.frm1.thumbnailCols.value = Math.round((((document.all)?parent.frames['basefrm'].document.body.offsetWidth:parent.frames['basefrm'].innerWidth)/140)-0.455555555)
document.frm1.submit()
}
function getRndName(){return "f"+String(Math.random()).replace(".","")}
function cut(){
setClipboardAction("cut")
}
function copy(){
setClipboardAction("copy")
}
function setClipboardAction(action){
var fL = Array()
var f = document.frm1
for(var e = 0; e < document.frm1.elements.length; e++){
if(document.frm1.elements[e].name == "fileSelection[]" || document.frm1.elements[e].name == "folderSelection[]")
if(document.frm1.elements[e].checked)
fL[fL.length] = currentDir + "/" + document.frm1.elements[e].value
}
if(fL.length > 0){
f.clipboard.value = fL.join(",")
f.clipboardAction.value = action
}
}
function paste(){
var f = document.frm1
f.selAction.value = "paste"
f.submit()
}
function showClipboard(){
var f = document.frm1
if(f.clipboardAction.value == "")
return
var m = ""
var fL = f.clipboard.value.split(",")
m += f.clipboardAction.value + "\n\n"
m += currentDir.replace(/%2F/g, "/").replace(/%3A/g, ":") + "\n\n"
for(var i in fL){
var it = fL[i]
it = it.replace(baseDir, "")
it = it.replace(/%2F/g, "/")
m += it + "\n"
}
alert(m)
}
function destruct(){
for(var w in windows)
if(windows[w])
if(windows[w].close)
windows[w].close()
}
function init(){
if(viewMode == "details"){
oCHead = new cm_makeObj("columnHead", "", 0, this.document)
oCHead.checkscrolled = function (){
var yOffset = (bw.ns4 || bw.ns6 || bw.op5) ? window.pageYOffset : document.body.scrollTop
if(yOffset != oCHead.yOffset){
oCMenu.checkscrolled(oCMenu)
oCHead.moveIt(0,yOffset + 26)
oCHead.yOffset = yOffset
}
window.setTimeout("oCHead.checkscrolled()", 200)
}
if(bw.ie){
document.body.onscroll = oCHead.checkscrolled
}else{
window.setTimeout("oCHead.checkscrolled()", 200)
}
}
if(currentDir == baseDir)
document.getElementById("dirUpButton").disabled = true
if(parent.frames['phpXplorerHead'])
parent.frames['phpXplorerHead'].document.frm1.address.value = visibleDir
var e = document.getElementById("selectedItem")
if(e)
e.className='selected'
window.onresize = resizeTable
resizeTable()
syncTree()
}
function syncTree(){
var frm = parent.frames['phpXplorerTree']
if(frm)
if(frm.jst_loaded){
if(!frm.selectNode(visibleDir == "/" ? visibleDir : "/" + visibleDir.replace(/\//g, "|")))
window.setTimeout("syncTree()", 222)
}else{
window.setTimeout("syncTree()", 222)
}
}
function dirUp(){
if(currentDir==baseDir)return
var f=document.frm1
f.currentDir.value=parentDir
f.submit()
}
function dirDown(dir){
var f=document.frm1
f.currentDir.value=currentDir + "/" + dir
f.submit()
}
function changeDir(dir){
var f = document.frm1
if(f){
if(f.currentDir){
f.currentDir.value = dir
f.submit()
}
}else{
parent.frames["basefrm"].location.href = "./directory.php?shareId=" + shareId
}
}
function newFile(typeKey){
if(typeKey != "")
typeKey += "/"
var rn = getRndName()
windows[rn] = window.open("./filetypes/" + typeKey + "create.php?currentDir=" + currentDir + "&shareId=" + shareId, rn, "scrollbars=yes,resizable=yes,width=500,height=300,left=150,top=150")
}
function uploadFile(){
var rn = getRndName()
windows[rn] = window.open("./filetypes/upload.php?currentDir=" + currentDir + "&shareId=" + shareId, rn, "scrollbars=yes,resizable=yes,width=500,height=300,left=150,top=150")
}
function getFile(){
var rn = getRndName()
windows[rn] = window.open("./filetypes/get.php?currentDir=" + currentDir + "&shareId=" + shareId, rn, "scrollbars=yes,resizable=yes,width=500,height=300,left=150,top=150")
}
function deleteFile(typeKey, file){
if(typeKey != "")
typeKey += "/"
var rn = getRndName()
windows[rn] = window.open("./filetypes/" + typeKey + "delete.php?currentDir=" + currentDir + "&fileName=" + file + "&shareId=" + shareId, rn, "scrollbars=yes, resizable=yes, width=500, height=300, left=150, top=150")
}
function openFolder(file, isFile){
var url = currentURL
if(file)
url += "/" + file
if(!isFile)url += "/"
var rn = getRndName()
windows[rn] = window.open(url, rn, "scrollbars=yes, resizable=yes, toolbar=yes, width=640, height=480, left=150, top=150")
}
function openFile(typeKey, file){
if(typeKey != "")
typeKey += "/"
var rn = getRndName()
windows[rn] = window.open("./filetypes/" + typeKey + "open.php?currentDir=" + currentDir + "&fileName=" + file + "&shareId=" + shareId, rn, "scrollbars=yes, resizable=yes, toolbar=yes, width=640, height=480, left=150, top=150")
}
function downloadFile(typeKey, file){
if(typeKey != "")
typeKey += "/"
var rn = getRndName()
windows[rn] = window.open("./filetypes/" + typeKey + "open.php?action=download¤tDir=" + currentDir + "&fileName=" + file + "&shareId=" + shareId, rn, "scrollbars=yes, resizable=yes, toolbar=yes, width=640, height=480, left=150, top=150")
}
function editFile(typeKey, file){
var typeFolder = typeKey
if(typeKey != "")
typeFolder += "/"
var rn = getRndName()
windows[rn] = window.open("./filetypes/" + typeFolder + "edit.php?currentDir=" + currentDir + "&fileName=" + file + "&shareId=" + shareId, rn, "scrollbars=yes, resizable=yes, width=680, height=480, left=150, top=150")
}
function selectFile(extension, file){
if(opener){
var objectURL=opener.location.href.substr(0, opener.location.href.lastIndexOf("/"))
if(currentURL.indexOf(objectURL) >- 1){
path = "." + currentURL.replace(objectURL,"") + "/"+file
}else{
if(objectURL.indexOf(currentURL) >- 1){
rest = objectURL.replace(currentURL, "")
path = "./"
for(var i = 0; i < rest.split("/").length - 1; i++)path += "../"
path += file
}else{
alert("Incorrect path")
return false
}
}
hdCtl(path)
window.close()
}
}
function selectAll(){
for(var e = 0; e < document.frm1.elements.length; e++){
if(document.frm1.elements[e].name == "fileSelection[]" || document.frm1.elements[e].name == "folderSelection[]")
document.frm1.elements[e].checked = true
}
}
function clearSelection(){
for(var e = 0; e < document.frm1.elements.length; e++){
if(document.frm1.elements[e].name == "fileSelection[]" || document.frm1.elements[e].name == "folderSelection[]")
document.frm1.elements[e].checked = false
}
}
function invertSelection(){
for(var e = 0; e < document.frm1.elements.length; e++){
if(document.frm1.elements[e].name == "fileSelection[]" || document.frm1.elements[e].name == "folderSelection[]")
document.frm1.elements[e].checked =! document.frm1.elements[e].checked
}
}
function deleteSelection(){
if(confirm(deleteWarning + "?")){
document.frm1.selAction.value = 'delete';
document.frm1.submit()
}
}
function editSelection(){
for(var e = 0; e < document.frm1.elements.length; e++){
var el = document.frm1.elements[e]
if(el.name == "fileSelection[]" || el.name == "folderSelection[]")
if(el.checked){
var file = el.value
if(el.name == "folderSelection[]"){
editFile("folder", file)
}else{
editFile(getTypeKeyByExtension(file), file)
}
}
}
}
function openSelection(){
for(var e = 0; e < document.frm1.elements.length; e++){
var el = document.frm1.elements[e]
if(el.name == "fileSelection[]")
if(el.checked){
var file = el.value
openFile(getTypeKeyByExtension(file), file)
}
}
}
function downloadSelection(){
for(var e = 0; e < document.frm1.elements.length; e++){
var el = document.frm1.elements[e]
if(el.name == "fileSelection[]")
if(el.checked){
var file = el.value
downloadFile(getTypeKeyByExtension(file), file)
}
}
}
function resizeTable(){
var p = document.getElementById("columnHead")
if(!p)return
var c = p.childNodes
var s = 0
for(var i = 0; i < c.length; i++){
if(c[i].nodeType == 1)
s += parseInt(c[i].style.width)
}
p.parentNode.style.width = (s+20) + "px"
}
function resizeColumn(sizeDiv, size){
var p = sizeDiv.parentNode
var s = 0
while(p.nodeName != "DIV")
p = p.parentNode
var c = p.childNodes
var d = 0
for(var i = 0; i < c.length; i++){
if(c[i].nodeType == 1 && c[i].id != ""){
d++
if(c[i].id == sizeDiv.id)break
}
}
var cont = p.nextSibling
while(cont.nodeName != "DIV")cont = cont.nextSibling
cont = cont.nextSibling
for(var i = 0; i < cont.childNodes.length; i++)
cont.childNodes[i].childNodes[1 + d].style.width = size + 8
resizeTable()
}
function startResize(dragDiv, event){
var sizeDiv = dragDiv.previousSibling
while(sizeDiv.nodeName != "DIV")
sizeDiv = sizeDiv.previousSibling
var x = event.clientX
var startSize = sizeDiv.offsetWidth
var resizeHead = function(){
var size = startSize + event.clientX - x
sizeDiv.style.width = (size < 8) ? 8 : size
}
var stopResize = function(){
dragDiv.detachEvent("onmousemove", resizeHead)
dragDiv.detachEvent("onmouseup", stopResize)
dragDiv.detachEvent("onlosecapture", stopResize)
dragDiv.releaseCapture()
var size = startSize + event.clientX - x
size = (size < 8) ? 8 : size
sizeDiv.style.width = size
resizeColumn(sizeDiv, size)
document.frm1.elements["columnWidth_" + sizeDiv.id].value = size
}
dragDiv.attachEvent("onmousemove", resizeHead)
dragDiv.attachEvent("onmouseup", stopResize)
dragDiv.attachEvent("onlosecapture", stopResize)
dragDiv.setCapture()
event.cancelBubble = true
}
(function(){
if(!window.HTMLElement)
return
var element = HTMLElement.prototype;
var events = Array("click", "mousedown", "mouseup", "mousemove", "mouseover", "mouseout");
element.setCapture = function(){
var self = this;
var s = false;
this._capture = function(event){
if(s)
return
s = true
self.dispatchEvent(event)
s = false
}
for (var e = 0; e < events.length; e++){
window.addEventListener(events[e], this._capture, true)
window.captureEvents(Event[events[e]])
}
}
element.releaseCapture = function(){
for (var e = 0; e < events.length; e++){
window.releaseEvents(Event[events[e]])
window.removeEventListener(events[e], this._capture, true)
}
this._capture = null;
}
element.attachEvent = function(name, hdl){
if(typeof hdl != "function")
return
var nsName = name.replace(/^on/, "")
var nsHdl = function(event){
window.event = event
hdl()
window.event = null
}
hdl[name] = nsHdl
this.addEventListener(nsName, nsHdl, false)
}
element.detachEvent = function(name, hdl) {
if(typeof hdl != "function")
return
var nsName = name.replace(/^on/, "")
this.removeEventListener(nsName, hdl[name], false)
hdl[name] = null
}
})();