Merge commit 'refs/merge-requests/18' of git://gitorious.org/owncloud/owncloud
merge Conflicts: index.php
This commit is contained in:
commit
c69eab18d2
159
css/default.php
159
css/default.php
|
@ -2,10 +2,49 @@
|
|||
header('Content-Type: text/css');
|
||||
require_once('../inc/lib_base.php');
|
||||
?>
|
||||
body {
|
||||
html,body {
|
||||
background-color: #F9F9F9;
|
||||
margin:0px;
|
||||
height:100%;
|
||||
width:100%;
|
||||
position:absolute;
|
||||
}
|
||||
#mainlayout{
|
||||
width:100%;
|
||||
height:100%;
|
||||
}
|
||||
|
||||
#mainlayout>div{
|
||||
position:absolute;
|
||||
width:100%;
|
||||
left:0px;
|
||||
}
|
||||
|
||||
#mainlayout>.head{
|
||||
height:175px;
|
||||
top:0px;
|
||||
}
|
||||
|
||||
#mainlayout>.body{
|
||||
vertical-align:top;
|
||||
top:175px;
|
||||
bottom:75px;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#mainlayout>.foot{
|
||||
height:75px;
|
||||
bottom:0px;
|
||||
}
|
||||
|
||||
#mainlayout>.foot>.bar{
|
||||
background-color:#EEE;
|
||||
position:absolute;
|
||||
top:0px;
|
||||
height:24px;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
body.error {background-color: #F0F0F0;}
|
||||
body,th,td,ul,li,a,div,p,pre {color:#333333; font-family:Verdana,"Bitstream Vera Sans",Arial,Helvetica,Sans,"Bitstream Vera Serif"; font-size:9.0pt;}
|
||||
|
||||
|
@ -35,6 +74,8 @@ div#nav {
|
|||
background-color: #EEEEEE;
|
||||
padding:0px;
|
||||
margin:0px;
|
||||
position:absolute;
|
||||
bottom:0px;
|
||||
}
|
||||
|
||||
a#owncloud-logo {
|
||||
|
@ -54,10 +95,13 @@ a#owncloud-logo span {
|
|||
.errortext {color:#CC3333; font-size:9pt; font-weight:bold; text-decoration:none;}
|
||||
.highlighttext {color:#333333; font-size:9pt; font-weight:bold; text-decoration:none;}
|
||||
.datetext {color:#333333; font-size:7pt;}
|
||||
.sizetext {color:#333333; font-size:7pt;}
|
||||
.sizetext{
|
||||
color:#333333;
|
||||
font-size:7pt;
|
||||
}
|
||||
.footer {color:#999999; text-align:center; font-size:9pt; margin-top:4em;}
|
||||
.footer a {color:#999999; text-decoration:none;}
|
||||
.hint {color:#AAAAAA; text-align:center; font-size:8pt; margin-top:4em; margin-bottom:2em;}
|
||||
.hint {color:#AAAAAA; text-align:center; font-size:8pt; margin-top:10px;}
|
||||
.hint a{color:#AAAAAA; text-align:center; font-size:8pt;}
|
||||
|
||||
.formstyle {
|
||||
|
@ -139,7 +183,11 @@ a#owncloud-logo span {
|
|||
margin:0px;
|
||||
padding:0px;
|
||||
border:0px;
|
||||
//do not use display:none here, it breaks iframes in some browsers
|
||||
position:absolute;
|
||||
top:0px;
|
||||
left:0px;
|
||||
overflow:hidden;
|
||||
/*do not use display:none here, it breaks iframes in some browsers*/
|
||||
}
|
||||
|
||||
div.OCNotification{
|
||||
|
@ -153,7 +201,7 @@ div.OCNotification{
|
|||
div.OCNotificationHolder{
|
||||
right:20px;
|
||||
bottom:0px;
|
||||
position:absolute;
|
||||
position:fixed;
|
||||
color:white;
|
||||
}
|
||||
|
||||
|
@ -163,20 +211,10 @@ td img.file_actions{
|
|||
width:9px;
|
||||
}
|
||||
|
||||
td:hover img.file_actions{
|
||||
td.nametext:hover img.file_actions{
|
||||
height:auto;
|
||||
}
|
||||
|
||||
td img.rename, td img.delete{
|
||||
height:0px;
|
||||
width:16px;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
td:hover img.rename, tr:hover img.delete{
|
||||
height:16px;
|
||||
}
|
||||
|
||||
div.breadcrumb{
|
||||
background-color: #F0F0F0;
|
||||
}
|
||||
|
@ -195,3 +233,92 @@ div.fileactionlist td{
|
|||
div.fileactionlist td:hover{
|
||||
background-color: #CCCCCC;
|
||||
}
|
||||
|
||||
tr.breadcrumb{
|
||||
background-color: #CCCCCC;
|
||||
}
|
||||
|
||||
#content, div.browser{
|
||||
vertical-align:top;
|
||||
/*min-height:200px;*/
|
||||
height:100%;
|
||||
}
|
||||
|
||||
table.browser{
|
||||
border: solid 3px #CCC;
|
||||
height:100%;
|
||||
border-spacing:0px;
|
||||
}
|
||||
|
||||
table.browser thead, table.browser tfoot{
|
||||
background-color:#CCC;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
td.sizetext{
|
||||
width:110px;
|
||||
text-align:right;
|
||||
}
|
||||
|
||||
td.fileSelector, td.fileicon{
|
||||
width:16px;
|
||||
}
|
||||
|
||||
span.upload{
|
||||
float:right;
|
||||
text-align:right;
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
|
||||
table.browser>tbody{
|
||||
vertical-align:top;
|
||||
}
|
||||
|
||||
table.browser>tbody>tr>td, table.browser>tbody>tr{
|
||||
padding:0px;
|
||||
/*height:100%;*/
|
||||
}
|
||||
|
||||
div.fileList{
|
||||
width:800px;
|
||||
overflow:auto;
|
||||
vertical-align:top;
|
||||
height:100%;
|
||||
min-height:200px;
|
||||
top:0px;
|
||||
}
|
||||
|
||||
div.fileList table{
|
||||
width:100%;
|
||||
vertical-align:top;
|
||||
}
|
||||
|
||||
table.browser thead td,table.browser tfoot td{
|
||||
padding-left:6px;
|
||||
padding-top:0px;
|
||||
padding-bottom:0px;
|
||||
}
|
||||
|
||||
#imageframe{
|
||||
position:absolute;
|
||||
top:0px;
|
||||
left:0px;
|
||||
height:100%;
|
||||
width:100%;
|
||||
background:rgb(20,20,20);
|
||||
background:rgba(20,20,20,0.9);
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
#imageframe img{
|
||||
vertical-align:middle;
|
||||
max-height:90%;
|
||||
max-width:90%;
|
||||
margin:10px;
|
||||
border: black solid 3px;
|
||||
}
|
||||
|
||||
tr.hint, tr.hint td{
|
||||
background:transparent;
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
//not this file is for getting files themselves, get_files.php is for getting a list of files.
|
||||
//note this file is for getting files themselves, get_files.php is for getting a list of files.
|
||||
|
||||
require_once('../inc/lib_base.php');
|
||||
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/**
|
||||
* ownCloud - ajax frontend
|
||||
*
|
||||
* @author Robin Appelman
|
||||
* @copyright 2010 Robin Appelman icewind1991@gmail.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library 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 AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//not this file is for getting files themselves, get_files.php is for getting a list of files.
|
||||
|
||||
require_once('../inc/lib_base.php');
|
||||
|
||||
function get_mime_type($filename, $mimePath = '../etc') {
|
||||
$fileext = substr(strrchr($filename, '.'), 1);
|
||||
if (empty($fileext)) return (false);
|
||||
$regex = "/^([\w\+\-\.\/]+)\s+(\w+\s)*($fileext\s)/i";
|
||||
$lines = file("$mimePath/mime.types");
|
||||
foreach($lines as $line) {
|
||||
if (substr($line, 0, 1) == '#') continue; // skip comments
|
||||
$line = rtrim($line) . " ";
|
||||
if (!preg_match($regex, $line, $matches)) continue; // no match to the extension
|
||||
return ($matches[1]);
|
||||
}
|
||||
return (false); // no match at all
|
||||
}
|
||||
|
||||
$file=$_GET['file'];
|
||||
$dir=(isset($_GET['dir']))?$_GET['dir']:'';
|
||||
if(strstr($file,'..') or strstr($dir,'..')){
|
||||
die();
|
||||
}
|
||||
$filename=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$file;
|
||||
// $ftype='application/octet-stream';
|
||||
// $finfo=new finfo(FILEINFO_MIME);
|
||||
// $fres=@$finfo->file($filename);
|
||||
// if (is_string($fres) && !empty($fres)) {
|
||||
// $ftype = $fres;
|
||||
// }
|
||||
$ftype=get_mime_type($filename);
|
||||
ob_end_clean();
|
||||
// echo $ftype;
|
||||
// die();
|
||||
header('Content-Type: '.$ftype);
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . filesize($filename));
|
||||
readfile($filename);
|
||||
?>
|
|
@ -77,7 +77,7 @@ class OC_FILES {
|
|||
echo('</table>');
|
||||
if(!$content) echo('<p>no files here</p>');
|
||||
echo('</div>');*/
|
||||
echo '<div id="content"/>';
|
||||
echo '<div id="content"></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -59,7 +59,7 @@ class OC_LOG {
|
|||
*/
|
||||
public static function show(){
|
||||
global $CONFIG_DATEFORMAT;
|
||||
echo('<div class="center"><table cellpadding="6" cellspacing="0" border="0" class="browser">');
|
||||
echo('<div class="center"><table cellpadding="6" cellspacing="0" border="0" class="log">');
|
||||
|
||||
$result = OC_DB::query('select timestamp,user,type,message from log order by timestamp desc limit 20');
|
||||
$count=OC_DB::numrows($result);
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
<?php
|
||||
global $WEBROOT;
|
||||
?>
|
||||
</div>
|
||||
<div class='foot'>
|
||||
<div class='bar'><p class="hint">
|
||||
Hint: Mount it via webdav like this: <a href="webdav://'.<?php echo($_SERVER["HTTP_HOST"].$WEBROOT.'/webdav/owncloud.php');?>">webdav://<?php echo($_SERVER["HTTP_HOST"].$WEBROOT);?>/webdav/owncloud.php</a>
|
||||
</p></div>
|
||||
<p class="footer">
|
||||
<?php
|
||||
echo('<a href="http://ownCloud.org">ownCloud</a> - 1.0 beta 2');
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</body></html>
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
<script type='text/ecmascript' src='<?php echo($WEBROOT)?>/js/lib_notification.js'></script>
|
||||
<script type='text/ecmascript' src='<?php echo($WEBROOT)?>/js/lib_xmlloader.js'></script>
|
||||
<script type='text/ecmascript' src='<?php echo($WEBROOT)?>/js/lib_files.js'></script>
|
||||
<script type='text/ecmascript' src='<?php echo($WEBROOT)?>/js/lib_event.js'></script>
|
||||
<script type='text/ecmascript' src='<?php echo($WEBROOT)?>/js/filebrowser.js'></script>
|
||||
<?php
|
||||
foreach(OC_UTIL::$scripts as $script){
|
||||
echo("<script type='text/ecmascript' src='$WEBROOT/$script'></script>");
|
||||
|
@ -20,6 +22,8 @@ foreach(OC_UTIL::$scripts as $script){
|
|||
</script>
|
||||
</head>
|
||||
<body onload='OC_onload.run()'>
|
||||
<div id='mainlayout'>
|
||||
<div class='head'>
|
||||
<?php
|
||||
echo('<h1><a id="owncloud-logo" href="'.$WEBROOT.'"><span>ownCloud</span></a></h1>');
|
||||
|
||||
|
@ -51,6 +55,7 @@ echo('<h1><a id="owncloud-logo" href="'.$WEBROOT.'"><span>ownCloud</span></a></h
|
|||
echo('<div id="nav" class="center">');
|
||||
OC_UTIL::shownavigation();
|
||||
echo('</div>');
|
||||
echo('</div><div class="body">');
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -37,8 +37,6 @@ echo('heya');
|
|||
OC_UTIL::showheader();
|
||||
|
||||
OC_FILES::showbrowser($CONFIG_DATADIRECTORY,$dir);
|
||||
echo('hi');
|
||||
echo('<br /><br /><p class="hint">Hint: Mount it via webdav like this: <a href="webdav://'.$_SERVER["HTTP_HOST"].$WEBROOT.'/webdav/owncloud.php">webdav://'.$_SERVER["HTTP_HOST"].$WEBROOT.'/webdav/owncloud.php</a></p>');
|
||||
|
||||
OC_UTIL::showfooter();
|
||||
|
||||
|
|
|
@ -19,10 +19,5 @@
|
|||
*
|
||||
*/
|
||||
|
||||
var dir=''
|
||||
var loc=document.location.toString();
|
||||
if(loc.indexOf('#')!=-1){
|
||||
dir=loc.substring(loc.indexOf('#')+1);
|
||||
}
|
||||
|
||||
OC_onload.add(new function(){OC_FILES.showbrowser(dir)});
|
||||
OC_onload.add(OC_FILES.browser.showInitial);
|
|
@ -0,0 +1,376 @@
|
|||
/**
|
||||
* ownCloud - ajax frontend
|
||||
*
|
||||
* @author Robin Appelman
|
||||
* @copyright 2010 Robin Appelman icewind1991@gmail.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library 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 AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
OC_FILES.browser=new Object();
|
||||
|
||||
OC_FILES.browser.showInitial=function(){
|
||||
var dir=''
|
||||
var loc=document.location.toString();
|
||||
if(loc.indexOf('#')!=-1){
|
||||
dir=loc.substring(loc.indexOf('#')+1);
|
||||
}
|
||||
OC_FILES.dir=dir;
|
||||
OC_FILES.getdirectorycontent(dir,OC_FILES.browser.show_callback);
|
||||
}
|
||||
|
||||
OC_FILES.browser.show=function(dir){
|
||||
if(!dir){
|
||||
dir='';
|
||||
}
|
||||
OC_FILES.dir=dir;
|
||||
OC_FILES.getdirectorycontent(dir,OC_FILES.browser.show_callback);
|
||||
}
|
||||
|
||||
OC_FILES.browser.show_callback=function(content){
|
||||
var dir=OC_FILES.dir
|
||||
var dirs=dir.split('/');
|
||||
var tr=null;
|
||||
var td=null;
|
||||
var img=null;
|
||||
|
||||
body=document.getElementsByTagName('body').item(0);
|
||||
body.addEvent('onclick',OC_FILES.browser.hideallactions);
|
||||
|
||||
//remove current content;
|
||||
var contentNode=document.getElementById('content');
|
||||
contentNode.className='center';
|
||||
if(contentNode.hasChildNodes()){
|
||||
while(contentNode.childNodes.length >=1){
|
||||
contentNode.removeChild(contentNode.firstChild);
|
||||
}
|
||||
}
|
||||
var table=document.createElement('table');
|
||||
table.className='browser';
|
||||
var tbody=document.createElement('tbody');
|
||||
var thead=document.createElement('thead');
|
||||
var tfoot=document.createElement('tfoot');
|
||||
table.appendChild(thead);
|
||||
table.appendChild(tbody);
|
||||
table.appendChild(tfoot);
|
||||
// table.setAttribute('cellpadding',6);
|
||||
|
||||
// breadcrumb
|
||||
if(dirs.length>0) {
|
||||
tr=document.createElement('tr');
|
||||
thead.appendChild(tr);
|
||||
tr.className='breadcrumb';
|
||||
td=document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
td.className='fileSelector'
|
||||
input=document.createElement('input');
|
||||
input.setAttribute('type','checkbox');
|
||||
input.setAttribute('name','fileSelector');
|
||||
input.setAttribute('value','select_all');
|
||||
input.setAttribute('id','select_all');
|
||||
input.addEvent('onclick',OC_FILES.selectAll);
|
||||
td.appendChild(input);
|
||||
td=document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
td.className='breadcrumb';
|
||||
var a=document.createElement('a');
|
||||
td.appendChild(a);
|
||||
a.setAttribute('href','#');
|
||||
a.addEvent('onclick',OC_FILES.browser.show);
|
||||
a.appendChild(document.createTextNode('Home'));
|
||||
var currentdir='';
|
||||
for(var index=0;index<dirs.length;index++){
|
||||
d=dirs[index];
|
||||
currentdir=currentdir+'/'+d;
|
||||
if(d!=''){
|
||||
a=document.createElement('a');
|
||||
td.appendChild(a);
|
||||
a.setAttribute('href','#'+currentdir);
|
||||
a.addEvent('onclick',OC_FILES.browser.show,currentdir);
|
||||
img=document.createElement('img');
|
||||
a.appendChild(img);
|
||||
img.src=WEBROOT+'/img/arrow.png';
|
||||
a.appendChild(document.createTextNode(' ' +d));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// files and directories
|
||||
|
||||
var filesfound=false;
|
||||
var sizeTd=null;
|
||||
if(content){
|
||||
tr=document.createElement('tr');
|
||||
tbody.appendChild(tr);
|
||||
td=document.createElement('td');
|
||||
td.setAttribute('colspan','6');
|
||||
tr.appendChild(td);
|
||||
div=document.createElement('div');
|
||||
td.appendChild(div);
|
||||
div.className='fileList';
|
||||
div.setAttribute('style','max-height:'+(parseInt(document.body.clientHeight)-300)+'px;');
|
||||
table2=document.createElement('table');
|
||||
div.appendChild(table2);
|
||||
tbody2=document.createElement('tbody');
|
||||
table2.appendChild(tbody2);
|
||||
table2.setAttribute('cellpadding',6);
|
||||
table2.setAttribute('cellspacing',0);
|
||||
for(index in content){
|
||||
var file=content[index];
|
||||
if(file.name){
|
||||
file.name=file.name.replace('\'','');
|
||||
OC_FILES.files[file['name']]=new OC_FILES.file(dir,file['name'],file['type']);
|
||||
tr=document.createElement('tr');
|
||||
tbody2.appendChild(tr);
|
||||
tr.className='browserline';
|
||||
td=document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
td.className='fileSelector';
|
||||
input=document.createElement('input');
|
||||
input.setAttribute('type','checkbox');
|
||||
input.setAttribute('name','fileSelector');
|
||||
input.setAttribute('value',file['name']);
|
||||
td.appendChild(input);
|
||||
tr.appendChild(OC_FILES.browser.showicon(file['type']));
|
||||
td=document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
td.className='nametext';
|
||||
td.setAttribute('name',file['name']);
|
||||
td.setAttribute('id',file['name']);
|
||||
a=document.createElement('a');
|
||||
td.appendChild(a);
|
||||
a.appendChild(document.createTextNode(file['name']));
|
||||
var fileObject=OC_FILES.files[file['name']];
|
||||
a.addEvent('onclick',new callBack(fileObject.actions['default'],fileObject));
|
||||
if(file['type']=='dir'){
|
||||
td.setAttribute('colspan',2);
|
||||
a.setAttribute('href','#'+dir+'/'+file['name']);
|
||||
}else{
|
||||
a.setAttribute('href','#'+dir);
|
||||
sizeTd=document.createElement('td');
|
||||
tr.appendChild(sizeTd);
|
||||
sizeTd.className='sizetext';
|
||||
sizeTd.appendChild(document.createTextNode(sizeFormat(file['size'])));
|
||||
}
|
||||
a=document.createElement('a');
|
||||
var img=document.createElement('img');
|
||||
td.appendChild(img);
|
||||
img.className='file_actions';
|
||||
img.alt=''
|
||||
img.title='actions';
|
||||
img.src=WEBROOT+'/img/arrow_down.png';
|
||||
var name=file['name'];
|
||||
img.addEvent('onclick',OC_FILES.browser.showactions,name);
|
||||
td=document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
td.className='sizetext';
|
||||
td.appendChild(document.createTextNode(file['date']));
|
||||
}
|
||||
}
|
||||
}
|
||||
tr=document.createElement('tr');
|
||||
tfoot.appendChild(tr);
|
||||
tr.className='utilityline';
|
||||
td=document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
td.setAttribute('colspan','4');
|
||||
span=document.createElement('span');
|
||||
td.appendChild(span);
|
||||
dropdown=document.createElement('select');
|
||||
span.appendChild(dropdown);
|
||||
dropdown.setAttribute('id','selected_action');
|
||||
for(index in this.actions_selected){
|
||||
if(this.actions_selected[index].call){
|
||||
option=document.createElement('option');
|
||||
dropdown.appendChild(option);
|
||||
option.setAttribute('value',index);
|
||||
option.appendChild(document.createTextNode(capitaliseFirstLetter(index)));
|
||||
}
|
||||
}
|
||||
span.appendChild(document.createTextNode(' Selected '));
|
||||
button=document.createElement('button');
|
||||
span.appendChild(button);
|
||||
button.appendChild(document.createTextNode('Go'));
|
||||
button.addEvent('onclick',OC_FILES.action_selected);
|
||||
span=document.createElement('span');
|
||||
span.className='upload';
|
||||
td.appendChild(span);
|
||||
OC_FILES.browser.showuploader(dir,span,content['max_upload']);
|
||||
contentNode.appendChild(table);
|
||||
}
|
||||
|
||||
OC_FILES.browser.showicon=function(filetype){
|
||||
var td=document.createElement('td');
|
||||
td.className='fileicon';
|
||||
var img=document.createElement('img');
|
||||
td.appendChild(img);
|
||||
img.setAttribute('width',16);
|
||||
img.setAttribute('height',16);
|
||||
if(filetype=='dir'){
|
||||
img.src=WEBROOT+'/img/icons/folder.png';
|
||||
}else{
|
||||
img.src=WEBROOT+'/img/icons/other.png';
|
||||
}
|
||||
return td;
|
||||
}
|
||||
|
||||
OC_FILES.browser.showuploader=function(dir,parent,max_upload){
|
||||
OC_FILES.uploadForm=document.createElement('form');
|
||||
OC_FILES.uploadForm.setAttribute('target','uploadIFrame');
|
||||
OC_FILES.uploadForm.setAttribute('action','files/upload.php?dir='+dir);
|
||||
OC_FILES.uploadForm.method='post';
|
||||
OC_FILES.uploadForm.setAttribute('enctype','multipart/form-data');
|
||||
OC_FILES.uploadIFrame=document.createElement('iframe');
|
||||
OC_FILES.uploadIFrame.className='hidden';
|
||||
OC_FILES.uploadIFrame.name='uploadIFrame';
|
||||
var input=document.createElement('input');
|
||||
input.setAttribute('type','hidden');
|
||||
input.setAttribute('name','MAX_FILE_SIZE');
|
||||
input.setAttribute('value',max_upload);
|
||||
input.setAttribute('id','max_upload');
|
||||
OC_FILES.uploadForm.appendChild(input);
|
||||
var file=document.createElement('input');
|
||||
file.name='file';
|
||||
file.setAttribute('id','fileSelector');
|
||||
file.setAttribute('type','file');
|
||||
file.addEvent('onchange',OC_FILES.upload,[dir]);
|
||||
OC_FILES.uploadForm.appendChild(document.createTextNode('Upload file: '));
|
||||
OC_FILES.uploadForm.appendChild(file);
|
||||
parent.appendChild(OC_FILES.uploadForm);
|
||||
parent.appendChild(OC_FILES.uploadIFrame);
|
||||
}
|
||||
|
||||
OC_FILES.browser.show_rename=function(dir,file){
|
||||
var item=document.getElementById(file);
|
||||
item.oldContent=Array();
|
||||
if(item.hasChildNodes()){
|
||||
while(item.childNodes.length >=1){
|
||||
item.oldContent[item.oldContent.length]=item.firstChild;
|
||||
item.removeChild(item.firstChild);
|
||||
}
|
||||
}
|
||||
var form=document.createElement('form');
|
||||
form.addEvent('onsubmit',OC_FILES.rename,[dir,file]);
|
||||
var input=document.createElement('input');
|
||||
input.setAttribute('type','text');
|
||||
input.setAttribute('name','newname');
|
||||
input.setAttribute('value',file);
|
||||
input.setAttribute('id',file+'_newname')
|
||||
input.addEvent('onblur',OC_FILES.browser.rename_cancel,[file]);
|
||||
form.appendChild(input);
|
||||
item.appendChild(form);
|
||||
input.focus();
|
||||
}
|
||||
|
||||
OC_FILES.browser.rename_cancel=function(file){
|
||||
var item=document.getElementsByName(file).item(0);
|
||||
if(item.hasChildNodes()){
|
||||
while(item.childNodes.length >=1){
|
||||
item.removeChild(item.firstChild);
|
||||
}
|
||||
}
|
||||
for(index in item.oldContent){
|
||||
if(item.oldContent[index].nodeType){
|
||||
item.appendChild(item.oldContent[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OC_FILES.browser.showactions=function(file,hide){
|
||||
node=document.getElementById(file);
|
||||
if(node &&(node.actionsshown || hide)){
|
||||
if(node.actionsdiv){
|
||||
node.removeChild(node.actionsdiv);
|
||||
}
|
||||
node.actionsdiv=null;
|
||||
node.actionsshown=false
|
||||
}else if(node){
|
||||
node.actionsshown=true
|
||||
div=document.createElement('div');
|
||||
node.actionsdiv=div;
|
||||
div.className='fileactionlist';
|
||||
table=document.createElement('table');
|
||||
div.appendChild(table);
|
||||
tbody=document.createElement('tbody');
|
||||
table.appendChild(tbody);
|
||||
var file=OC_FILES.files[file]
|
||||
var actions=file.actions;
|
||||
for(name in actions){
|
||||
if(actions[name].call && name!='default'){
|
||||
tr=document.createElement('tr');
|
||||
tbody.appendChild(tr);
|
||||
td=document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
a=document.createElement('a');
|
||||
td.appendChild(a);
|
||||
a.appendChild(document.createTextNode(capitaliseFirstLetter(name)));
|
||||
var action=actions[name];
|
||||
td.addEvent('onclick',new callBack(action,file));
|
||||
}
|
||||
}
|
||||
node.appendChild(div);
|
||||
OC_FILES.hideallenabled=false;
|
||||
setTimeout('OC_FILES.hideallenabled=true',50);
|
||||
}
|
||||
}
|
||||
|
||||
OC_FILES.browser.hideallactions=function(){
|
||||
if(OC_FILES.hideallenabled){
|
||||
for(name in OC_FILES.files){
|
||||
if(OC_FILES.files[name]){
|
||||
if(OC_FILES.files[name].hideactions){
|
||||
OC_FILES.files[name].hideactions.call(OC_FILES.files[name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OC_FILES.hideallenabled=true; //used to prevent browsers from hiding actionslists right after they are displayed;
|
||||
|
||||
sizeFormat=function(size){
|
||||
var orig=size;
|
||||
var steps=Array('B','KiB','MiB','GiB','TiB');
|
||||
var step=0;
|
||||
while(size>(1024*2)){
|
||||
step++;
|
||||
size=size/1024;
|
||||
}
|
||||
if(size.toFixed){
|
||||
size=size.toFixed(2);
|
||||
}
|
||||
return ''+size+' '+steps[step];
|
||||
}
|
||||
|
||||
OC_FILES.browser.showImage=function(dir,file){
|
||||
var path=WEBROOT+'/files/open_file.php?dir='+dir+'&file='+file
|
||||
var div=document.createElement('div');
|
||||
div.setAttribute('id','imageframe');
|
||||
div.addEvent('onclick',OC_FILES.browser.hideImage)
|
||||
var img=document.createElement('img');
|
||||
img.setAttribute('src',path);
|
||||
div.appendChild(img);
|
||||
body=document.getElementsByTagName('body').item(0);
|
||||
body.appendChild(div);
|
||||
}
|
||||
|
||||
OC_FILES.browser.hideImage=function(){
|
||||
var div=document.getElementById('imageframe');
|
||||
div.parentNode.removeChild(div);
|
||||
}
|
||||
|
||||
function capitaliseFirstLetter(string){
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
|
@ -32,35 +32,84 @@ callBack.callBacks=Array();
|
|||
callBack.call=function(id,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10){
|
||||
callback=callBack.callBacks[id];
|
||||
if(callback){
|
||||
callback.func.call(callback.obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
|
||||
return callback.func.call(callback.obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
|
||||
}
|
||||
}
|
||||
|
||||
callBack.prototype=function(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10){
|
||||
this.call(false,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
|
||||
return this.call(false,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
|
||||
}
|
||||
callBack.prototype.func=false;
|
||||
callBack.prototype.obj=false;
|
||||
callBack.prototype.call=function(dummy,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10){
|
||||
//the dummy is just to provide compatibility with the normal call function and isn't used
|
||||
this.func.call(this.obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
|
||||
return this.func.call(this.obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
|
||||
}
|
||||
callBack.prototype.apply=function(dummy,arguments){
|
||||
//the dummy is just to provide compatibility with the normal call function and isn't used
|
||||
this.apply(this.obj,arguments);
|
||||
return this.func.apply(this.obj,arguments);
|
||||
}
|
||||
|
||||
//provide a simple way to add things to the onload
|
||||
OC_onload=new Object();
|
||||
|
||||
OC_onload.items=new Array();
|
||||
OC_onload.add=function(callback){
|
||||
OC_onload.itemsPriority=new Array();
|
||||
OC_onload.add=function(callback,priority){
|
||||
if(priority){
|
||||
OC_onload.itemsPriority[OC_onload.items.length]=callback;
|
||||
}else{
|
||||
OC_onload.items[OC_onload.items.length]=callback;
|
||||
}
|
||||
}
|
||||
OC_onload.run=function(){
|
||||
for(index in OC_onload.itemsPriority){
|
||||
if(OC_onload.itemsPriority[index].call){
|
||||
OC_onload.itemsPriority[index].call();
|
||||
}
|
||||
}
|
||||
for(index in OC_onload.items){
|
||||
if(OC_onload.items[index].call){
|
||||
OC_onload.items[index].call();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//implement Node.prototype under IE
|
||||
if(typeof Node=='undefined'){
|
||||
Node=new Object();
|
||||
Node.prototype=new Object();
|
||||
|
||||
tmpObj=new Object();
|
||||
tmpObj.prototype=document.createElement;
|
||||
document.createElementNative=document.createElement;
|
||||
tmpObj=null;
|
||||
|
||||
document.createElement=function(tagName){
|
||||
// alert(tagName);
|
||||
node=document.createElementNative(tagName);
|
||||
for(name in Node.prototype){
|
||||
node[name]=Node.prototype[name];
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
addNodePrototype=function(node){
|
||||
if(!node){
|
||||
node=document.getElementsByTagName('body');
|
||||
node=node.item(0)
|
||||
}
|
||||
if(node.nodeType==1){
|
||||
for(name in Node.prototype){
|
||||
// node[name]=Node.prototype[name];
|
||||
eval('node.'+name+'=Node.prototype.'+name+';');
|
||||
}
|
||||
if(node.hasChildNodes){
|
||||
var childs=node.childNodes;
|
||||
for(var i=0;i<childs.length;i++){
|
||||
addNodePrototype(childs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
OC_onload.add(new function(){addNodePrototype(document.documentElement);});
|
||||
OC_onload.add(addNodePrototype,true);
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
* eventHandler
|
||||
*
|
||||
* @author Icewind <icewind (at) derideal (dot) com>
|
||||
* @copyright 2009
|
||||
* @license http://www.gnu.org/licenses/gpl.html GNU Public License
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
/*event handling
|
||||
usage: document.events.add(node,type,function,arguments);
|
||||
or: node.addEvent(type,function,arguments);
|
||||
*/
|
||||
|
||||
document.events=new Object;
|
||||
document.events.functions=Array();
|
||||
document.events.args=Array();
|
||||
|
||||
document.events.add=function(element,type,func,args){
|
||||
if(args){
|
||||
if(typeof args!='object' && typeof args!='Object'){
|
||||
args=[args];
|
||||
}
|
||||
}
|
||||
if(!args){
|
||||
args=Array();
|
||||
}
|
||||
if (type && element){
|
||||
|
||||
//wrap the function in a function, otherwise it won't work if func is actually a callBack
|
||||
var funcId=document.events.functions.length;
|
||||
document.events.functions[funcId]=func;
|
||||
document.events.args[funcId]=args;
|
||||
eval('callback=function(event){result=document.events.functions['+funcId+'].apply(this,document.events.args['+funcId+']);if(result===false){if(event.preventDefault){event.preventDefault();}}};');
|
||||
if(element.addEventListener){
|
||||
var eventType=type;
|
||||
if(eventType.substr(0,2)=='on'){
|
||||
eventType=eventType.substr(2);
|
||||
}
|
||||
element.addEventListener(eventType,callback,false);
|
||||
}else{
|
||||
element.attachEvent(type,callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Node.prototype.addEvent=function(type,func,arguments){
|
||||
document.events.add(this,type,func,arguments);
|
||||
}
|
368
js/lib_files.js
368
js/lib_files.js
|
@ -55,225 +55,16 @@ OC_FILES.getdirectorycontent=function(dir,callback){
|
|||
OC_FILES.xmlloader.load('files/get_files.php?dir='+dir);
|
||||
}
|
||||
|
||||
OC_FILES.showicon=function(filetype){
|
||||
var td=document.createElement('td');
|
||||
var img=document.createElement('img');
|
||||
td.appendChild(img);
|
||||
img.setAttribute('width',16);
|
||||
img.setAttribute('height',16);
|
||||
if(filetype=='dir'){
|
||||
img.src=WEBROOT+'/img/icons/folder.png';
|
||||
}else{
|
||||
img.src=WEBROOT+'/img/icons/other.png';
|
||||
}
|
||||
return td;
|
||||
}
|
||||
|
||||
OC_FILES.dir='';
|
||||
OC_FILES.browser=null;
|
||||
OC_FILES.showbrowser=function(dir){
|
||||
dir=(dir)?dir:'';
|
||||
OC_FILES.dir=dir;
|
||||
OC_FILES.getdirectorycontent(dir,OC_FILES.showbrowser_callback);
|
||||
}
|
||||
|
||||
OC_FILES.showbrowser_callback=function(content){
|
||||
var dir=OC_FILES.dir
|
||||
var dirs=dir.split('/');
|
||||
var tr=null;
|
||||
var td=null;
|
||||
var img=null;
|
||||
|
||||
body=document.getElementsByTagName('body').item(0);
|
||||
body.setAttribute('onclick',body.getAttribute('onclick')+' ; OC_FILES.hideallactions()');
|
||||
|
||||
//remove current content;
|
||||
var contentNode=document.getElementById('content');
|
||||
if(contentNode.hasChildNodes()){
|
||||
while(contentNode.childNodes.length >=1){
|
||||
contentNode.removeChild(contentNode.firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
var browser=document.createElement('div');
|
||||
browser.className='center';
|
||||
var table=document.createElement('table');
|
||||
browser.appendChild(table);
|
||||
|
||||
// breadcrumb
|
||||
if(dirs.length>0) {
|
||||
table.setAttribute('cellpadding',2);
|
||||
table.setAttribute('cellspacing',0);
|
||||
var tbody=document.createElement('tbody');//some IE versions need this
|
||||
table.appendChild(tbody);
|
||||
tr=document.createElement('tr');
|
||||
tbody.appendChild(tr);
|
||||
td=document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
td.setAttribute('colspan','6');
|
||||
td.className='breadcrumb';
|
||||
var a=document.createElement('a');
|
||||
td.appendChild(a);
|
||||
a.setAttribute('href','#');
|
||||
a.setAttribute('onclick','OC_FILES.showbrowser()');
|
||||
a.appendChild(document.createTextNode('Home'));
|
||||
var currentdir='';
|
||||
for(index in dirs) {
|
||||
d=dirs[index];
|
||||
currentdir+='/'+d;
|
||||
if(d!=''){
|
||||
// td=document.createElement('td');
|
||||
// tr.appendChild(td);
|
||||
// td.className='breadcrumb';
|
||||
a=document.createElement('a');
|
||||
td.appendChild(a);
|
||||
a.setAttribute('href','#'+currentdir);
|
||||
a.setAttribute('onclick','OC_FILES.showbrowser("'+currentdir+'")');
|
||||
img=document.createElement('img');
|
||||
a.appendChild(img);
|
||||
img.src=WEBROOT+'/img/arrow.png';
|
||||
a.appendChild(document.createTextNode(' ' +d));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// files and directories
|
||||
table.setAttribute('cellpadding',6);
|
||||
table.setAttribute('cellspacing',0);
|
||||
table.className='browser';
|
||||
var tbody=document.createElement('tbody');//some IE versions need this
|
||||
table.appendChild(tbody);
|
||||
var filesfound=false;
|
||||
var sizeTd=null;
|
||||
if(content){
|
||||
tr=document.createElement('tr');
|
||||
tbody.appendChild(tr);
|
||||
tr.className='browserline';
|
||||
td=document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
td.setAttribute('colspan','2');
|
||||
input=document.createElement('input');
|
||||
input.setAttribute('type','checkbox');
|
||||
input.setAttribute('name','fileSelector');
|
||||
input.setAttribute('value','select_all');
|
||||
input.setAttribute('id','select_all');
|
||||
input.setAttribute('onclick','OC_FILES.selectAll()');
|
||||
td.appendChild(input);
|
||||
td=document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
td.setAttribute('colspan','4');
|
||||
dropdown=document.createElement('select');
|
||||
td.appendChild(dropdown);
|
||||
dropdown.setAttribute('id','selected_action');
|
||||
for(index in this.actions_selected){
|
||||
if(this.actions_selected[index].call){
|
||||
option=document.createElement('option');
|
||||
dropdown.appendChild(option);
|
||||
option.setAttribute('value',index);
|
||||
option.appendChild(document.createTextNode(index));
|
||||
}
|
||||
}
|
||||
td.appendChild(document.createTextNode(' selected. '));
|
||||
button=document.createElement('button');
|
||||
td.appendChild(button);
|
||||
button.appendChild(document.createTextNode('Go'));
|
||||
button.setAttribute('onclick','OC_FILES.action_selected()');
|
||||
for(index in content){
|
||||
file=content[index];
|
||||
if(file.name){
|
||||
file.name=file.name.replace('\'','');
|
||||
OC_FILES.files[file['name']]=new OC_FILES.file(dir,file['name'],file['type']);
|
||||
tr=document.createElement('tr');
|
||||
tbody.appendChild(tr);
|
||||
tr.className='browserline';
|
||||
td=document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
input=document.createElement('input');
|
||||
input.setAttribute('type','checkbox');
|
||||
input.setAttribute('name','fileSelector');
|
||||
input.setAttribute('value',file['name']);
|
||||
td.appendChild(input);
|
||||
tr.appendChild(OC_FILES.showicon(file['type']));
|
||||
td=document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
td.className='nametext';
|
||||
td.setAttribute('name',file['name']);
|
||||
td.setAttribute('id',file['name']);
|
||||
a=document.createElement('a');
|
||||
td.appendChild(a);
|
||||
a.appendChild(document.createTextNode(file['name']))
|
||||
if(file['type']=='dir'){
|
||||
a.setAttribute('onclick','OC_FILES.showbrowser("'+dir+file['name']+'")');
|
||||
td.setAttribute('colspan',2);
|
||||
a.setAttribute('href','#'+dir+file['name']);
|
||||
}else{
|
||||
a.setAttribute('href',WEBROOT+'/?dir=/'+dir+'&file='+file['name']);
|
||||
sizeTd=document.createElement('td');
|
||||
tr.appendChild(sizeTd);
|
||||
sizeTd.className='sizetext';
|
||||
sizeTd.appendChild(document.createTextNode(sizeFormat(file['size'])));
|
||||
}
|
||||
a=document.createElement('a');
|
||||
img=document.createElement('img');
|
||||
td.appendChild(img);
|
||||
img.className='file_actions';
|
||||
img.alt=''
|
||||
img.title='actions';
|
||||
img.src=WEBROOT+'/img/arrow_down.png';
|
||||
img.setAttribute('onclick','OC_FILES.showactions(\''+file['name']+'\')')
|
||||
td=document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
td.className='sizetext';
|
||||
td.appendChild(document.createTextNode(file['date']));
|
||||
}
|
||||
}
|
||||
}
|
||||
td=document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
tr=document.createElement('tr');
|
||||
tbody.appendChild(tr);
|
||||
tr.className='utilrow';
|
||||
td=document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
td.className='upload';
|
||||
td.setAttribute('colspan','6');
|
||||
this.showuploader(dir,td,content['max_upload']);
|
||||
contentNode.appendChild(browser);
|
||||
}
|
||||
|
||||
OC_FILES.showuploader=function(dir,parent,max_upload){
|
||||
this.uploadForm=document.createElement('form');
|
||||
this.uploadForm.setAttribute('target','uploadIFrame');
|
||||
this.uploadForm.setAttribute('action','files/upload.php?dir='+dir);
|
||||
this.uploadForm.method='post';
|
||||
this.uploadForm.setAttribute('enctype','multipart/form-data');
|
||||
this.uploadIFrame=document.createElement('iframe');
|
||||
this.uploadIFrame.className='hidden';
|
||||
this.uploadIFrame.name='uploadIFrame';
|
||||
parent.appendChild(this.uploadIFrame);
|
||||
var input=document.createElement('input');
|
||||
input.setAttribute('type','hidden');
|
||||
input.setAttribute('name','MAX_FILE_SIZE');
|
||||
input.setAttribute('value',max_upload);
|
||||
input.setAttribute('id','max_upload');
|
||||
this.uploadForm.appendChild(input);
|
||||
var file=document.createElement('input');
|
||||
file.name='file';
|
||||
file.setAttribute('id','fileSelector');
|
||||
file.setAttribute('type','file');
|
||||
file.setAttribute('onchange','OC_FILES.upload("'+dir+'")');
|
||||
this.uploadForm.appendChild(document.createTextNode('Upload file: '));
|
||||
this.uploadForm.appendChild(file);
|
||||
parent.appendChild(this.uploadForm);
|
||||
}
|
||||
|
||||
OC_FILES.upload=function(dir){
|
||||
OC_FILES.uploadIFrame.setAttribute('onload',"OC_FILES.upload_callback.call(OC_FILES,'"+dir+"')");
|
||||
OC_FILES.uploadIFrame.addEvent('onload',new callBack(OC_FILES.upload_callback,OC_FILES),dir);
|
||||
var fileSelector=document.getElementById('fileSelector');
|
||||
var max_upload=document.getElementById('max_upload').value;
|
||||
if(fileSelector.files && fileSelector.files[0].fileSize){
|
||||
var size=fileSelector.files[0].fileSize
|
||||
var size=fileSelector.files[0].fileSize;
|
||||
if(size>max_upload){
|
||||
new OCNotification('File to large',10000)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -281,38 +72,16 @@ OC_FILES.upload=function(dir){
|
|||
}
|
||||
|
||||
OC_FILES.upload_callback=function(dir){
|
||||
this.showbrowser(dir);
|
||||
this.browser.show(dir);
|
||||
}
|
||||
|
||||
OC_FILES.rename=function(dir,file){
|
||||
var item=document.getElementById(file);
|
||||
item.oldContent=Array();
|
||||
if(item.hasChildNodes()){
|
||||
while(item.childNodes.length >=1){
|
||||
item.oldContent[item.oldContent.length]=item.firstChild;
|
||||
item.removeChild(item.firstChild);
|
||||
}
|
||||
}
|
||||
var form=document.createElement('form');
|
||||
form.setAttribute('onsubmit','return OC_FILES.do_rename(\''+dir+'\',\''+file+'\')')
|
||||
var input=document.createElement('input');
|
||||
input.setAttribute('type','text');
|
||||
input.setAttribute('name','newname');
|
||||
input.setAttribute('value',file);
|
||||
input.setAttribute('id',file+'_newname')
|
||||
input.setAttribute('onblur','OC_FILES.rename_cancel(\''+file+'\')');
|
||||
form.appendChild(input);
|
||||
item.appendChild(form);
|
||||
input.focus();
|
||||
}
|
||||
|
||||
OC_FILES.do_rename=function(dir,file){
|
||||
var item=document.getElementById(file+'_newname');
|
||||
var newname=item.value;
|
||||
if(newname==''){
|
||||
return false;
|
||||
}else if(file==newname){
|
||||
OC_FILES.showbrowser(OC_FILES.dir);
|
||||
OC_FILES.browser.show(OC_FILES.dir);
|
||||
return false;
|
||||
}
|
||||
xmlloader=new OCXMLLoader();
|
||||
|
@ -321,22 +90,9 @@ OC_FILES.do_rename=function(dir,file){
|
|||
return false;
|
||||
}
|
||||
|
||||
OC_FILES.rename_callback=function(req){
|
||||
OC_FILES.showbrowser(OC_FILES.dir);
|
||||
}
|
||||
|
||||
OC_FILES.rename_cancel=function(file){
|
||||
var item=document.getElementsByName(file).item(0);
|
||||
if(item.hasChildNodes()){
|
||||
while(item.childNodes.length >=1){
|
||||
item.removeChild(item.firstChild);
|
||||
}
|
||||
}
|
||||
for(index in item.oldContent){
|
||||
if(item.oldContent[index].nodeType){
|
||||
item.appendChild(item.oldContent[index]);
|
||||
}
|
||||
}
|
||||
OC_FILES.rename_callback=function(req){
|
||||
OC_FILES.browser.show(OC_FILES.dir);
|
||||
}
|
||||
|
||||
OC_FILES.remove=function(dir,file){
|
||||
|
@ -349,7 +105,7 @@ OC_FILES.remove=function(dir,file){
|
|||
}
|
||||
|
||||
OC_FILES.remove_callback=function(req){
|
||||
OC_FILES.showbrowser(OC_FILES.dir);
|
||||
OC_FILES.browser.show(OC_FILES.dir);
|
||||
}
|
||||
|
||||
OC_FILES.getSelected=function(){
|
||||
|
@ -409,26 +165,38 @@ OC_FILES.file=function(dir,file,type){
|
|||
this.file=file;
|
||||
this.dir=dir;
|
||||
this.actions=new Object();
|
||||
this.extention=file.substr(file.indexOf('.'));
|
||||
if(file.lastIndexOf('.')){
|
||||
this.extention=file.substr(file.lastIndexOf('.')+1);
|
||||
}else{
|
||||
this.extention;
|
||||
}
|
||||
for(index in OC_FILES.fileActions.all){
|
||||
if(OC_FILES.fileActions.all[index].call){
|
||||
this.actions[index]=OC_FILES.fileActions.all[index];
|
||||
}
|
||||
}
|
||||
if(OC_FILES.fileActions[this.extention])
|
||||
if(OC_FILES.fileActions[this.type]){
|
||||
for(index in OC_FILES.fileActions[this.type]){
|
||||
if(OC_FILES.fileActions[this.type][index].call){
|
||||
this.actions[index]=OC_FILES.fileActions[this.type][index];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(OC_FILES.fileActions[this.extention]){
|
||||
for(index in OC_FILES.fileActions[this.extention]){
|
||||
if(OC_FILES.fileActions[this.extention][index].call){
|
||||
this.actions[index]=OC_FILES.fileActions[this.extention][index];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OC_FILES.file.prototype.showactions=function(){
|
||||
OC_FILES.showactions(this.file);
|
||||
OC_FILES.browser.showactions(this.file);
|
||||
}
|
||||
|
||||
OC_FILES.file.prototype.hideactions=function(){
|
||||
OC_FILES.showactions(this.file,true);
|
||||
OC_FILES.browser.showactions(this.file,true);
|
||||
}
|
||||
|
||||
OC_FILES.fileActions=new Object();
|
||||
|
@ -439,71 +207,47 @@ OC_FILES.fileActions.all.remove=function(){
|
|||
OC_FILES.remove(this.dir,this.file);
|
||||
}
|
||||
OC_FILES.fileActions.all.rename=function(){
|
||||
OC_FILES.rename(this.dir,this.file);
|
||||
OC_FILES.browser.show_rename(this.dir,this.file);
|
||||
}
|
||||
OC_FILES.fileActions.all.download=function(){
|
||||
window.location=WEBROOT+'/files/get_file.php?dir='+this.dir+'&files='+this.file;
|
||||
}
|
||||
OC_FILES.fileActions.all['default']=OC_FILES.fileActions.all.download;
|
||||
|
||||
OC_FILES.showactions=function(file,hide){
|
||||
node=document.getElementById(file);
|
||||
if(node.actionsshown || hide){
|
||||
if(node.actionsdiv){
|
||||
node.removeChild(node.actionsdiv);
|
||||
}
|
||||
node.actionsdiv=null;
|
||||
node.actionsshown=false
|
||||
}else{
|
||||
// OC_FILES.hideallactions();
|
||||
node.actionsshown=true
|
||||
div=document.createElement('div');
|
||||
node.actionsdiv=div;
|
||||
div.className='fileactionlist';
|
||||
table=document.createElement('table');
|
||||
div.appendChild(table);
|
||||
tbody=document.createElement('tbody');
|
||||
table.appendChild(tbody);
|
||||
actions=OC_FILES.files[file].actions;
|
||||
for(name in actions){
|
||||
if(actions[name].call){
|
||||
tr=document.createElement('tr');
|
||||
tbody.appendChild(tr);
|
||||
td=document.createElement('td');
|
||||
tr.appendChild(td);
|
||||
a=document.createElement('a');
|
||||
td.appendChild(a);
|
||||
a.appendChild(document.createTextNode(name));
|
||||
td.setAttribute('onclick','OC_FILES.files[\''+file+'\'].actions[\''+name+'\'].call(OC_FILES.files[\''+file+'\'])');
|
||||
}
|
||||
}
|
||||
node.appendChild(div);
|
||||
OC_FILES.hideallenabled=false;
|
||||
setTimeout('OC_FILES.hideallenabled=true',50);
|
||||
OC_FILES.fileActions.dir=new Object()
|
||||
|
||||
OC_FILES.fileActions.dir.open=function(){
|
||||
OC_FILES.browser.show(this.dir+'/'+this.file);
|
||||
}
|
||||
OC_FILES.fileActions.dir['default']=OC_FILES.fileActions.dir.open;
|
||||
|
||||
OC_FILES.fileActions.jpg=new Object()
|
||||
|
||||
OC_FILES.fileActions.jpg.show=function(){
|
||||
// window.open(WEBROOT+'/files/open_file.php?dir='+this.dir+'&file='+this.file);
|
||||
OC_FILES.browser.showImage(this.dir,this.file);
|
||||
}
|
||||
|
||||
OC_FILES.hideallactions=function(){
|
||||
if(OC_FILES.hideallenabled){
|
||||
for(name in OC_FILES.files){
|
||||
if(OC_FILES.files[name].hideactions){
|
||||
OC_FILES.files[name].hideactions.call(OC_FILES.files[name]);
|
||||
}
|
||||
}
|
||||
OC_FILES.fileActions.jpg['default']=OC_FILES.fileActions.jpg.show;
|
||||
|
||||
OC_FILES.fileActions.jpeg=OC_FILES.fileActions.jpg
|
||||
OC_FILES.fileActions.png=OC_FILES.fileActions.jpg
|
||||
OC_FILES.fileActions.gif=OC_FILES.fileActions.jpg
|
||||
OC_FILES.fileActions.bmp=OC_FILES.fileActions.jpg
|
||||
|
||||
function getStyle(el,styleProp)
|
||||
{
|
||||
// var x = document.getElementById(el);
|
||||
var x=el;
|
||||
if (x.currentStyle){
|
||||
alert(x.currentStyle);
|
||||
var y = x.currentStyle[styleProp];
|
||||
}else if (window.getComputedStyle){
|
||||
var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
OC_FILES.hideallenabled=true; //used to prevent browsers from hiding actionslists right after they are displayed;
|
||||
|
||||
sizeFormat=function(size){
|
||||
var orig=size;
|
||||
var steps=Array('B','KiB','MiB','GiB','TiB');
|
||||
var step=0;
|
||||
while(size>(1024*2)){
|
||||
step++;
|
||||
size=size/1024;
|
||||
}
|
||||
if(size.toFixed){
|
||||
size=size.toFixed(2);
|
||||
}
|
||||
return ''+size+' '+steps[step];
|
||||
Node.prototype.getStyle=function(styleProp){
|
||||
return getStyle(this,styleProp)
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* StarLight - A client side webpage framework
|
||||
*
|
||||
* @package StarLight
|
||||
* @author Icewind <icewind (at) derideal (dot) com>
|
||||
* @copyright 2009
|
||||
* @license http://www.gnu.org/licenses/gpl.html GNU Public License
|
||||
* @url http://blacklight.metalwarp.com/starlight
|
||||
* @version 0.1
|
||||
*/
|
||||
|
||||
OCNotification=function(text,time){
|
||||
this.text=text;
|
||||
this.time=(time)?time:0;
|
||||
this.notify();
|
||||
}
|
||||
|
||||
OCNotification.prototype={
|
||||
notify:function(){
|
||||
this.holder=document.getElementById('OCNotificationHolder');
|
||||
if (!this.holder){
|
||||
this.holder=document.createElement('div');
|
||||
this.holder.className='OCNotificationHolder';
|
||||
this.holder.setAttribute('class','OCNotificationHolder');
|
||||
this.holder.setAttribute('id','OCNotificationHolder');
|
||||
document.getElementsByTagName('body').item(0).appendChild(this.holder);
|
||||
}
|
||||
this.notification=document.createElement('div');
|
||||
this.notification.className='OCNotification';
|
||||
this.notification.setAttribute('class','OCNotification');
|
||||
if (document.documentElement.innerHTML){
|
||||
this.notification.innerHTML=this.text;
|
||||
}else{
|
||||
var text=document.createTextNode(this.text);
|
||||
this.notification.appendChild(text);
|
||||
}
|
||||
this.holder.insertBefore(this.notification,this.holder.firstChild);
|
||||
this.notification.addEvent('onclick',new callBack(this.removeNotification,this));
|
||||
if (this.time>0){
|
||||
this.timer = new OCTimer(this.removeNotification, this.time,false,this);
|
||||
}
|
||||
},
|
||||
removeNotification:function(){
|
||||
if(this.notification){
|
||||
this.holder.removeChild(this.notification);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* StarLight - A client side webpage framework
|
||||
*
|
||||
* @package StarLight
|
||||
* @author Icewind <icewind (at) derideal (dot) com>
|
||||
* @copyright 2009
|
||||
* @license http://www.gnu.org/licenses/gpl.html GNU Public License
|
||||
* @url http://blacklight.metalwarp.com/starlight
|
||||
* @version 0.1
|
||||
*/
|
||||
OCTimer=function(callback,time,repeat,object){
|
||||
this.object=(object)?object:false;
|
||||
this.repeat=(!(repeat===undefined))?repeat:true;
|
||||
this.callback=callback;
|
||||
this.time=time;
|
||||
this.timer=0;
|
||||
this.number=OCTimer.count;
|
||||
OCTimer.count++;
|
||||
OCTimer.timers[this.number]=this;
|
||||
if(this.time){
|
||||
this.start();
|
||||
}
|
||||
}
|
||||
|
||||
OCTimer.count=0;
|
||||
OCTimer.timers=Array();
|
||||
|
||||
OCTimer.prototype={
|
||||
start:function(){
|
||||
this.running=true;
|
||||
eval('var func=function(){OCTimer.timers['+this.number+'].run();};');
|
||||
if(this.repeat){
|
||||
this.timer = setInterval(func, this.time);
|
||||
}else{
|
||||
this.timer = setTimeout(func, this.time);
|
||||
}
|
||||
},
|
||||
run:function(){
|
||||
if (!this.repeat){
|
||||
this.stop();
|
||||
}
|
||||
if (this.object){
|
||||
this.callback.call(this.object);
|
||||
}else{
|
||||
this.callback.call();
|
||||
}
|
||||
},
|
||||
stop:function(){
|
||||
clearInterval(this.timer);
|
||||
this.running=false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue