Commit 06aaf14a authored by Alain Takoudjou's avatar Alain Takoudjou

Merge branch 'slaprunner'

parents 0d97260a e97599ea
......@@ -111,17 +111,21 @@ def run():
def serve(config):
from views import app
workdir = os.path.join(config.runner_workdir, 'project')
software_link = os.path.join(config.runner_workdir, 'softwareLink')
app.config.update(**config.__dict__)
app.config.update(
software_log=config.software_root.rstrip('/') + '.log',
instance_log=config.instance_root.rstrip('/') + '.log',
workspace = workdir,
software_link=software_link,
instance_profile='instance.cfg',
software_profile='software.cfg',
SECRET_KEY="123456",
SECRET_KEY=os.urandom(24),
PERMANENT_SESSION_LIFETIME=timedelta(days=31),
)
if not os.path.exists(workdir):
os.mkdir(workdir)
if not os.path.exists(software_link):
os.mkdir(software_link)
app.run(host=config.runner_host, port=int(config.runner_port),
debug=config.debug, threaded=True)
# -*- coding: utf-8 -*-
import os
import urllib
from flask import jsonify
from werkzeug import secure_filename
import shutil
import datetime
import hashlib
from utils import realpath, tail, isText
import re
import zipfile
class fileBrowser(object):
"""This class contain all bases function for file browser"""
def __init__(self, config):
self.config = config
def listDirs(self, dir, all=False):
"""List elements of directory 'dir' taken"""
html = ''
html += 'var gsdirs = new Array();'
html += 'var gsfiles = new Array();'
dir = urllib.unquote(str(dir))
realdir = realpath(self.config, dir)
if not realdir:
raise NameError('Could not load directory %s: Permission denied' % dir)
ldir = sorted(os.listdir(realdir), key=str.lower)
for f in ldir:
if f.startswith('.') and not all: #do not display this file/folder
continue
ff = os.path.join(dir,f)
realfile = os.path.join(realdir, f)
mdate = datetime.datetime.fromtimestamp(os.path.getmtime(realfile)
).strftime("%Y-%d-%m %I:%M")
md5 = hashlib.md5(realfile).hexdigest()
if not os.path.isdir(realfile):
size = os.path.getsize(realfile)
regex = re.compile("(^.*)\.(.*)", re.VERBOSE)
ext = regex.sub(r'\2', f)
if ext == f:
ext = "unknow"
else:
ext = str.lower(ext)
html += 'gsfiles.push(new gsItem("1", "' + f + '", "' + \
ff + '", "' + str(size) + '", "' + md5 + \
'", "' + ext + '", "' + mdate + '"));';
else:
html += 'gsdirs.push(new gsItem("2", "' + f + '", "' + \
ff + '", "0", "' + md5 + '", "dir", "' + mdate + '"));';
return html
def makeDirectory(self, dir, filename):
"""Create a directory"""
realdir = realpath(self.config, urllib.unquote(dir))
if not realdir:
raise NameError('Could not load directory %s: Permission denied' % dir)
folder = os.path.join(realdir, filename)
if not os.path.exists(folder):
os.mkdir(folder, 0744)
return '{result: \'1\'}'
else:
return '{result: \'0\'}'
def makeFile(self, dir, filename):
"""Create a file in a directory dir taken"""
realdir = realpath(self.config, urllib.unquote(dir))
if not realdir:
raise NameError('Could not load directory %s: Permission denied' % dir)
file = os.path.join(realdir, filename)
if not os.path.exists(file):
open(file, 'w').write('')
return 'var responce = {result: \'1\'}'
else:
return '{result: \'0\'}'
def deleteItem(self, dir, files):
"""Delete a list of files or directories"""
realdir = realpath(self.config, urllib.unquote(dir))
if not realdir:
raise NameError('Could not load directory %s: Permission denied' % dir)
lfiles = urllib.unquote(files).split(',,,')
try:
for file in lfiles:
file = os.path.join(realdir, file)
if not os.path.exists(file):
continue #silent skip file....
details = file.split('/')
last = details[len(details) - 1]
if last and last.startswith('.'):
continue #cannot delete this file/directory, to prevent security
if os.path.isdir(file):
shutil.rmtree(file)
else:
os.unlink(file)
except Exception, e:
return str(e)
return '{result: \'1\'}'
def copyItem(self, dir, files, del_source=False):
"""Copy a list of files or directory to dir"""
realdir = realpath(self.config, urllib.unquote(dir))
if not realdir:
raise NameError('Could not load directory %s: Permission denied' % dir)
lfiles = urllib.unquote(files).split(',,,')
try:
for file in lfiles:
realfile = realpath(self.config, file)
if not realfile:
raise NameError('Could not load file or directory %s: Permission denied' % file)
#prepare destination file
details = realfile.split('/')
dest = os.path.join(realdir, details[len(details) - 1])
if os.path.exists(dest):
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
if os.path.isdir(realfile):
shutil.copytree(realfile, dest)
if del_source:
shutil.rmtree(realfile)
else:
shutil.copy(realfile, dest)
if del_source:
os.unlink(realfile)
except Exception, e:
return str(e)
return '{result: \'1\'}'
def rename(self, dir, filename, newfilename):
"""Rename file or directory to dir/filename"""
realdir = realpath(self.config, urllib.unquote(dir))
if not realdir:
raise NameError('Could not load directory %s: Permission denied' % dir)
realfile = realpath(self.config, urllib.unquote(filename))
if not realfile:
raise NameError('Could not load directory %s: Permission denied' % filename)
tofile = os.path.join(realdir, newfilename)
if not os.path.exists(tofile):
os.rename(realfile, tofile)
return '{result: \'1\'}'
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
def copyAsFile(self, dir, filename, newfilename):
"""Copy file or directory to dir/filename"""
realdir = realpath(self.config, urllib.unquote(dir))
if not realdir:
raise NameError('Could not load directory %s: Permission denied' % dir)
fromfile = os.path.join(realdir, filename)
tofile = os.path.join(realdir, newfilename)
if not os.path.exists(fromfile):
raise NameError('NOT ALLOWED OPERATION : File or directory not exist')
if not os.path.exists(tofile):
shutil.copy(fromfile, tofile)
return '{result: \'1\'}'
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
def uploadFile(self, dir, files):
"""Upload a list of file in directory dir"""
realdir = realpath(self.config, urllib.unquote(dir))
if not realdir:
raise NameError('Could not load directory %s: Permission denied' % dir)
for file in files:
if files[file]:
filename = secure_filename(files[file].filename)
if not os.path.exists(os.path.join(dir, filename)):
files[file].save(os.path.join(realdir, filename))
return '{result: \'1\'}'
def downloadFile(self, dir, filename):
"""Download file dir/filename"""
realdir = realpath(self.config, urllib.unquote(dir))
if not realdir:
raise NameError('Could not load directory %s: Permission denied' % dir)
file = os.path.join(realdir, urllib.unquote(filename))
if not os.path.exists(file):
raise NameError('NOT ALLOWED OPERATION : File or directory does not exist %s'
% os.path.join(dir, filename))
return file
def zipFile(self, dir, filename, newfilename):
"""Add filename to archive as newfilename"""
realdir = realpath(self.config, urllib.unquote(dir))
if not realdir:
raise NameError('Could not load directory %s: Permission denied' % dir)
tozip = os.path.join(realdir, newfilename)
fromzip = os.path.join(realdir, filename)
if not os.path.exists(fromzip):
raise NameError('NOT ALLOWED OPERATION : File or directory not exist')
if not os.path.exists(tozip):
zip = zipfile.ZipFile(tozip, 'w', zipfile.ZIP_DEFLATED)
if os.path.isdir(fromzip):
rootlen = len(fromzip) + 1
for base, dirs, files in os.walk(fromzip):
for file in files:
fn = os.path.join(base, file).encode("utf-8")
zip.write(fn, fn[rootlen:])
else:
zip.write(fromzip)
zip.close()
return '{result: \'1\'}'
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
def unzipFile(self, dir, filename, newfilename):
"""Extract a zipped archive"""
realdir = realpath(self.config, urllib.unquote(dir))
if not realdir:
raise NameError('Could not load directory %s: Permission denied' % dir)
target = os.path.join(realdir, newfilename)
archive = os.path.join(realdir, filename)
if not os.path.exists(archive):
raise NameError('NOT ALLOWED OPERATION : File or directory not exist')
if not os.path.exists(target):
zip = zipfile.ZipFile(archive)
#member = zip.namelist()
zip.extractall(target)
#if len(member) > 1:
# zip.extractall(target)
#else:
# zip.extract(member[0], newfilename)
return '{result: \'1\'}'
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
def readFile(self, dir, filename, truncate=0):
"""Read file dir/filename and return content"""
realfile = realpath(self.config, os.path.join(urllib.unquote(dir),
urllib.unquote(filename)))
if not realfile:
raise NameError('Could not load directory %s: Permission denied' % dir)
if not isText(realfile):
return "FILE ERROR: Cannot display binary file, please open a text file only!"
if truncate == 0:
return open(realfile, 'r').read()
else:
tail(open(realfile, 'r'), 0)
UL.jqueryFileTree {
font-family: Verdana, sans-serif;
font-size: 12px;
line-height: 18px;
padding: 0px;
margin: 0px;
}
UL.jqueryFileTree LI {
list-style: none;
padding: 0px;
padding-left: 20px;
margin: 0px;
white-space: nowrap;
}
UL.jqueryFileTree A {
color: #333;
text-decoration: none;
}
UL.jqueryFileTree A:hover {
background: #BDF;
}
.gs_dir_list{display: none;}
.gs_dir_content {
height: 100%;
width: 100%;
}
.gs_dir_content_menu {
padding: 0 0 0 5px;
margin-bottom: 5px;
border: 1px solid #BBBBBB;
background-color: white;
}
.gs_dir_content_button {
background: url("data:image/gif;base64,R0lGODlhKAAVAJEAAPn5+e7u7uPj4////yH5BAEAAAMALAAAAAAoABUAAAIxhI+py+0Po5y02ouz3rz7FoTiSJbmiabqGgruC8fyTNf2jef6zvf+DwwKh8Si8SgsAAA7") repeat-x scroll 0 0 transparent;
border: 1px outset #BBBBBB;
cursor: pointer;
margin-right: 7px;
font-weight: bold;
padding: 1px;
background-position: 0, 50;
text-decoration: none;
color: black;
}
.gs_dir_content_button:hover {
color: #EF7929;
border: 1px inset #BBBBBB;
}
.gs_dir_content_files {
min-height: 250px;
max-height: 400px;
overflow: auto;
background-color: white;
border: 1px solid #BBBBBB;
}
#curDir {
height: 30px;
line-height: 30px;
}
#gsClipBoard{display: none;}
.directory_info {
padding-left: 20px;
}
.directory_info a {
text-decoration: none;
}
#rootLink {
display: none;
}
.loadingDiv {
width: 100%;
height: 75px;
margin-top: 50px;
background: url(images/loading.gif) center center no-repeat;
}
.demoto {
width: 100%;
height: 100%;
}
.dir_index {
cursor: pointer;
}
.toggleplus {
background: url('images/toggle_plus.png') left top no-repeat;
}
.toggleminus {
background: url('images/toggle_minus.png') left top no-repeat;
}
.dirs_files_table {
width: 100%;
font-size: 12px;
}
.dirs_files_table td{padding: 0;border:none}
.gsItem {padding: 4px; padding-left: 25px;}
.file_ext_name {
font-weight: normal;
color: #FF6600;
}
.gsHeadTable {
width :100%;
}
.dirs_files_table tr:hover {background: #BDF;}
.gsHeadText {
color:#666;
height:34px;
font-weight: bold;
}
.gs_head{padding: 10px 5px 10px 0;}
.gs_title{padding-left: 10px; margin:5px 5px 0 0; background: #e4e4e4;}
.rowSelected {
color: #FFF;
background-color: #c2c2c2;
}
.rowSelected a {
color: #FFF;
}
.gs_delimiter {
height: 16px;
line-height: 16px;
}
/* Core Styles */
.directory {
background-image:url(images/directory.png);
background-repeat:no-repeat;
}
.directoryMeny a { background: url(images/directory.png) left top no-repeat; padding-left: 20px}
/*.jqueryFileTree LI.expanded { background: url(images/folder_open.png) 20px top no-repeat; }*/
.file {
background-image:url(images/file.png);
background-repeat:no-repeat;
cursor:pointer;
}
.jqueryFileTree LI.wait { background: url(images/spinner.gif) left top no-repeat; }
/* File Extensions*/
.ext_3gp {
background-image: url(images/film.png) left top no-repeat;
}
.ext_afp {
background-image: url(images/code.png); }
.ext_afpa {
background-image: url(images/code.png); }
.ext_asp {
background-image: url(images/code.png); }
.ext_aspx {
background-image: url(images/code.png); }
.ext_avi {
background-image: url(images/film.png); }
.ext_bat {
background-image: url(images/application.png); }
.ext_bmp {
background-image: url(images/picture.png); }
.ext_c {
background-image: url(images/code.png); }
.ext_cfm {
background-image: url(images/code.png); }
.ext_cgi {
background-image: url(images/code.png); }
.ext_com {
background-image: url(images/application.png); }
.ext_cpp {
background-image: url(images/code.png); }
.ext_css {
background-image: url(images/css.png); }
.ext_doc {
background-image: url(images/doc.png); }
.ext_exe {
background-image: url(images/application.png); }
.ext_gif {
background-image: url(images/picture.png);
}
.ext_fla {
background-image: url(images/flash.png); }
.ext_h {
background-image: url(images/code.png); }
.ext_htm {
background-image: url(images/html.png); }
.ext_html {
background-image: url(images/html.png); }
.ext_jar {
background-image: url(images/java.png); }
.ext_jpg {
background-image: url(images/picture.png);
}
.ext_jpeg {
background-image: url(images/picture.png); }
.ext_js {
background-image: url(images/script.png) ; }
.ext_lasso {
background-image: url(images/code.png) ; }
.ext_log {
background-image: url(images/txt.png) ; }
.ext_m4p {
background-image: url(images/music.png); }
.ext_mov {
background-image: url(images/film.png); }
.ext_mp3 {
background-image: url(images/music.png); }
.ext_mp4 {
background-image: url(images/film.png); }
.ext_mpg {
background-image: url(images/film.png); }
.ext_mpeg {
background-image: url(images/film.png); }
.ext_ogg {
background-image: url(images/music.png); }
.ext_pcx {
background-image: url(images/picture.png); }
.ext_pdf {
background-image: url(images/pdf.png); }
.ext_php {
background-image: url(images/php.png); }
.ext_png {
background-image: url(images/picture.png); }
.ext_ppt {
background-image: url(images/ppt.png); }
.ext_psd {
background-image: url(images/psd.png); }
.ext_pl {
background-image: url(images/script.png);; }
.ext_py {
background-image: url(images/script.png) ;}
.ext_rb {
background-image: url(images/ruby.png); }
.ext_rbx {
background-image: url(images/ruby.png); }
.ext_rhtml {
background-image: url(images/ruby.png); }
.ext_rpm {
background-image: url(images/linux.png); }
.ext_ruby {
background-image: url(images/ruby.png); }
.ext_sql {
background-image: url(images/db.png); }
.ext_swf {
background-image: url(images/flash.png); }
.ext_tif {
background-image: url(images/picture.png); }
.ext_tiff {
background-image: url(images/picture.png); }
.ext_txt {
background-image: url(images/txt.png) ; }
.ext_vb {
background-image: url(images/code.png) ; }
.ext_wav {
background-image: url(images/music.png) ; }
.ext_wmv {
background-image: url(images/film.png); }
.ext_xls {
background-image: url(images/xls.png) ; }
.ext_xml {
background-image: url(images/code.png) ; }
.ext_zip {
background-image: url(images/zip.png) ; }
.ext_cfg {
background-image: url(images/cfg.png) ; }
/* Generic context menu styles */
.contextMenu {
position: absolute;
width: 160px;
z-index: 99999;
border: solid 1px #CCC;
background: #EEE;
padding: 0px;
margin: 0px;
display: none;
}
.contextMenu LI {
list-style: none;
padding: 0px;
margin: 0px;
}
.contextMenu A {
color: #333;
text-decoration: none;
display: block;
line-height: 20px;
height: 20px;
background-position: 6px center;
background-repeat: no-repeat;
outline: none;
padding: 1px 5px;
padding-left: 28px;
}
.contextMenu LI.hover A {
color: #FFF;
background-color: #3399FF;
}
.contextMenu LI.disabled A {
color: #AAA;
cursor: default;
}
.contextMenu LI.hover.disabled A {
background-color: transparent;
}
.contextMenu LI.separator {
border-top: solid 1px #CCC;
}
/*
Adding Icons
You can add icons to the context menu by adding
classes to the respective LI element(s)
*/
.contextMenu LI.edit A { background-image: url(images/page_white_edit.png); }
.contextMenu LI.cut A { background-image: url(images/cut.png); }
.contextMenu LI.copy A { background-image: url(images/page_white_copy.png); }
.contextMenu LI.paste A { background-image: url(images/page_white_paste.png); }
.contextMenu LI.delete A { background-image: url(images/cross.png); }
.contextMenu LI.quit A { background-image: url(images/door.png); }
.contextMenu LI.directorymenu A { background-image: url(images/folder_open.png); }
.contextMenu LI.rename A { background-image: url(images/mfile.png); }
.contextMenu LI.download A { background-image: url(images/disk.png); }
.contextMenu LI.notepad A { background-image: url(images/page_white_edit.png); }
.contextMenu LI.picture A { background-image: url(images/mpicture.png); }
.contextMenu LI.newfile A { background-image: url(images/new_file.png); }
.contextMenu LI.newdir A { background-image: url(images/new_dir.png); }
.contextMenu LI.uploadfolder A { background-image: url(images/upload_folder.png); }
.contextMenu LI.selection A { background-image: url(images/selection-select.png); }
.contextMenu LI.zip A { background-image: url(images/mzip.png); }
\ No newline at end of file
slapos/runner/static/css/images/cfg.png

764 Bytes | W: | H:

slapos/runner/static/css/images/cfg.png

756 Bytes | W: | H:

slapos/runner/static/css/images/cfg.png
slapos/runner/static/css/images/cfg.png
slapos/runner/static/css/images/cfg.png
slapos/runner/static/css/images/cfg.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/code.png

603 Bytes | W: | H:

slapos/runner/static/css/images/code.png

655 Bytes | W: | H:

slapos/runner/static/css/images/code.png
slapos/runner/static/css/images/code.png
slapos/runner/static/css/images/code.png
slapos/runner/static/css/images/code.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/css.png

618 Bytes | W: | H:

slapos/runner/static/css/images/css.png

674 Bytes | W: | H:

slapos/runner/static/css/images/css.png
slapos/runner/static/css/images/css.png
slapos/runner/static/css/images/css.png
slapos/runner/static/css/images/css.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/db.png

579 Bytes | W: | H:

slapos/runner/static/css/images/db.png

635 Bytes | W: | H:

slapos/runner/static/css/images/db.png
slapos/runner/static/css/images/db.png
slapos/runner/static/css/images/db.png
slapos/runner/static/css/images/db.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/directory.png

427 Bytes | W: | H:

slapos/runner/static/css/images/directory.png

459 Bytes | W: | H:

slapos/runner/static/css/images/directory.png
slapos/runner/static/css/images/directory.png
slapos/runner/static/css/images/directory.png
slapos/runner/static/css/images/directory.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/doc.png

651 Bytes | W: | H:

slapos/runner/static/css/images/doc.png

743 Bytes | W: | H:

slapos/runner/static/css/images/doc.png
slapos/runner/static/css/images/doc.png
slapos/runner/static/css/images/doc.png
slapos/runner/static/css/images/doc.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/file.png

294 Bytes | W: | H:

slapos/runner/static/css/images/file.png

425 Bytes | W: | H:

slapos/runner/static/css/images/file.png
slapos/runner/static/css/images/file.png
slapos/runner/static/css/images/file.png
slapos/runner/static/css/images/file.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/film.png

653 Bytes | W: | H:

slapos/runner/static/css/images/film.png

767 Bytes | W: | H:

slapos/runner/static/css/images/film.png
slapos/runner/static/css/images/film.png
slapos/runner/static/css/images/film.png
slapos/runner/static/css/images/film.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/flash.png

582 Bytes | W: | H:

slapos/runner/static/css/images/flash.png

630 Bytes | W: | H:

slapos/runner/static/css/images/flash.png
slapos/runner/static/css/images/flash.png
slapos/runner/static/css/images/flash.png
slapos/runner/static/css/images/flash.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/html.png

734 Bytes | W: | H:

slapos/runner/static/css/images/html.png

791 Bytes | W: | H:

slapos/runner/static/css/images/html.png
slapos/runner/static/css/images/html.png
slapos/runner/static/css/images/html.png
slapos/runner/static/css/images/html.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/java.png

633 Bytes | W: | H:

slapos/runner/static/css/images/java.png

417 Bytes | W: | H:

slapos/runner/static/css/images/java.png
slapos/runner/static/css/images/java.png
slapos/runner/static/css/images/java.png
slapos/runner/static/css/images/java.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/linux.png

668 Bytes | W: | H:

slapos/runner/static/css/images/linux.png

720 Bytes | W: | H:

slapos/runner/static/css/images/linux.png
slapos/runner/static/css/images/linux.png
slapos/runner/static/css/images/linux.png
slapos/runner/static/css/images/linux.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/music.png

385 Bytes | W: | H:

slapos/runner/static/css/images/music.png

691 Bytes | W: | H:

slapos/runner/static/css/images/music.png
slapos/runner/static/css/images/music.png
slapos/runner/static/css/images/music.png
slapos/runner/static/css/images/music.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/pdf.png

591 Bytes | W: | H:

slapos/runner/static/css/images/pdf.png

639 Bytes | W: | H:

slapos/runner/static/css/images/pdf.png
slapos/runner/static/css/images/pdf.png
slapos/runner/static/css/images/pdf.png
slapos/runner/static/css/images/pdf.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/php.png

538 Bytes | W: | H:

slapos/runner/static/css/images/php.png

591 Bytes | W: | H:

slapos/runner/static/css/images/php.png
slapos/runner/static/css/images/php.png
slapos/runner/static/css/images/php.png
slapos/runner/static/css/images/php.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/picture.png

606 Bytes | W: | H:

slapos/runner/static/css/images/picture.png

715 Bytes | W: | H:

slapos/runner/static/css/images/picture.png
slapos/runner/static/css/images/picture.png
slapos/runner/static/css/images/picture.png
slapos/runner/static/css/images/picture.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/ppt.png

588 Bytes | W: | H:

slapos/runner/static/css/images/ppt.png

661 Bytes | W: | H:

slapos/runner/static/css/images/ppt.png
slapos/runner/static/css/images/ppt.png
slapos/runner/static/css/images/ppt.png
slapos/runner/static/css/images/ppt.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/psd.png

856 Bytes | W: | H:

slapos/runner/static/css/images/psd.png

918 Bytes | W: | H:

slapos/runner/static/css/images/psd.png
slapos/runner/static/css/images/psd.png
slapos/runner/static/css/images/psd.png
slapos/runner/static/css/images/psd.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/ruby.png

626 Bytes | W: | H:

slapos/runner/static/css/images/ruby.png

676 Bytes | W: | H:

slapos/runner/static/css/images/ruby.png
slapos/runner/static/css/images/ruby.png
slapos/runner/static/css/images/ruby.png
slapos/runner/static/css/images/ruby.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/script.png

859 Bytes | W: | H:

slapos/runner/static/css/images/script.png

955 Bytes | W: | H:

slapos/runner/static/css/images/script.png
slapos/runner/static/css/images/script.png
slapos/runner/static/css/images/script.png
slapos/runner/static/css/images/script.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/txt.png

342 Bytes | W: | H:

slapos/runner/static/css/images/txt.png

529 Bytes | W: | H:

slapos/runner/static/css/images/txt.png
slapos/runner/static/css/images/txt.png
slapos/runner/static/css/images/txt.png
slapos/runner/static/css/images/txt.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/xls.png

663 Bytes | W: | H:

slapos/runner/static/css/images/xls.png

714 Bytes | W: | H:

slapos/runner/static/css/images/xls.png
slapos/runner/static/css/images/xls.png
slapos/runner/static/css/images/xls.png
slapos/runner/static/css/images/xls.png
  • 2-up
  • Swipe
  • Onion skin
slapos/runner/static/css/images/zip.png

386 Bytes | W: | H:

slapos/runner/static/css/images/zip.png

590 Bytes | W: | H:

slapos/runner/static/css/images/zip.png
slapos/runner/static/css/images/zip.png
slapos/runner/static/css/images/zip.png
slapos/runner/static/css/images/zip.png
  • 2-up
  • Swipe
  • Onion skin
UL.jqueryFileTree {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12px;
line-height: 20px;
padding: 0px;
margin: 0px;
}
UL.jqueryFileTree LI {
list-style: none;
padding: 0px;
padding-left: 22px;
margin: 0px;
white-space: nowrap;
}
UL.jqueryFileTree A {
color: #333;
text-decoration: none;
display: block;
padding: 0px 2px;
}
UL.jqueryFileTree A:hover {
background: #BDF;
}
/* Core Styles */
.jqueryFileTree LI.directory { background: url(images/directory.png) left top no-repeat; }
.jqueryFileTree LI.expanded { background: url(images/folder_open.png) left top no-repeat; }
.jqueryFileTree LI.file { background: url(images/file.png) left top no-repeat; }
.jqueryFileTree LI.wait { background: url(images/spinner.gif) left top no-repeat; }
/* File Extensions*/
.jqueryFileTree LI.ext_3gp { background: url(images/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_afp { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_afpa { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_asp { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_aspx { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_avi { background: url(images/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_bat { background: url(images/application.png) left top no-repeat; }
.jqueryFileTree LI.ext_bmp { background: url(images/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_c { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_cfg { background: url(images/cfg.png) left top no-repeat; }
.jqueryFileTree LI.ext_cfm { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_cgi { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_com { background: url(images/application.png) left top no-repeat; }
.jqueryFileTree LI.ext_cpp { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_css { background: url(images/css.png) left top no-repeat; }
.jqueryFileTree LI.ext_doc { background: url(images/doc.png) left top no-repeat; }
.jqueryFileTree LI.ext_exe { background: url(images/application.png) left top no-repeat; }
.jqueryFileTree LI.ext_gif { background: url(images/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_fla { background: url(images/flash.png) left top no-repeat; }
.jqueryFileTree LI.ext_h { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_htm { background: url(images/html.png) left top no-repeat; }
.jqueryFileTree LI.ext_html { background: url(images/html.png) left top no-repeat; }
.jqueryFileTree LI.ext_jar { background: url(images/java.png) left top no-repeat; }
.jqueryFileTree LI.ext_jpg { background: url(images/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_jpeg { background: url(images/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_js { background: url(images/script.png) left top no-repeat; }
.jqueryFileTree LI.ext_lasso { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_log { background: url(images/txt.png) left top no-repeat; }
.jqueryFileTree LI.ext_m4p { background: url(images/music.png) left top no-repeat; }
.jqueryFileTree LI.ext_mov { background: url(images/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_mp3 { background: url(images/music.png) left top no-repeat; }
.jqueryFileTree LI.ext_mp4 { background: url(images/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_mpg { background: url(images/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_mpeg { background: url(images/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_ogg { background: url(images/music.png) left top no-repeat; }
.jqueryFileTree LI.ext_pcx { background: url(images/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_pdf { background: url(images/pdf.png) left top no-repeat; }
.jqueryFileTree LI.ext_php { background: url(images/php.png) left top no-repeat; }
.jqueryFileTree LI.ext_png { background: url(images/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_ppt { background: url(images/ppt.png) left top no-repeat; }
.jqueryFileTree LI.ext_psd { background: url(images/psd.png) left top no-repeat; }
.jqueryFileTree LI.ext_pl { background: url(images/script.png) left top no-repeat; }
.jqueryFileTree LI.ext_py { background: url(images/script.png) left top no-repeat; }
.jqueryFileTree LI.ext_rb { background: url(images/ruby.png) left top no-repeat; }
.jqueryFileTree LI.ext_rbx { background: url(images/ruby.png) left top no-repeat; }
.jqueryFileTree LI.ext_rhtml { background: url(images/ruby.png) left top no-repeat; }
.jqueryFileTree LI.ext_rpm { background: url(images/linux.png) left top no-repeat; }
.jqueryFileTree LI.ext_ruby { background: url(images/ruby.png) left top no-repeat; }
.jqueryFileTree LI.ext_sql { background: url(images/db.png) left top no-repeat; }
.jqueryFileTree LI.ext_swf { background: url(images/flash.png) left top no-repeat; }
.jqueryFileTree LI.ext_tif { background: url(images/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_tiff { background: url(images/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_txt { background: url(images/txt.png) left top no-repeat; }
.jqueryFileTree LI.ext_vb { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_wav { background: url(images/music.png) left top no-repeat; }
.jqueryFileTree LI.ext_wmv { background: url(images/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_xls { background: url(images/xls.png) left top no-repeat; }
.jqueryFileTree LI.ext_xml { background: url(images/code.png) left top no-repeat; }
UL.jqueryFileTree {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12px;
line-height: 20px;
padding: 0px;
margin: 0px;
}
UL.jqueryFileTree LI {
list-style: none;
padding: 0px;
padding-left: 25px;
margin: 0px;
white-space: nowrap;
}
UL.jqueryFileTree A {
color: #333;
text-decoration: none;
display: block;
padding: 0px 2px;
}
UL.jqueryFileTree A:hover {
background: #BDF;
}
/* Core Styles */
.jqueryFileTree LI.directory { background: url(images/directory.png) left top no-repeat; }
.jqueryFileTree LI.expanded { background: url(images/folder_open.png) left top no-repeat; }
.jqueryFileTree LI.file { background: url(images/file.png) left top no-repeat; }
.jqueryFileTree LI.wait { background: url(images/spinner.gif) left top no-repeat; }
/* File Extensions*/
.jqueryFileTree LI.ext_3gp { background: url(images/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_afp { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_afpa { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_asp { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_aspx { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_avi { background: url(images/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_bat { background: url(images/application.png) left top no-repeat; }
.jqueryFileTree LI.ext_bmp { background: url(images/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_c { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_cfg { background: url(images/cfg.png) left top no-repeat; }
.jqueryFileTree LI.ext_cfm { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_cgi { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_com { background: url(images/application.png) left top no-repeat; }
.jqueryFileTree LI.ext_cpp { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_css { background: url(images/css.png) left top no-repeat; }
.jqueryFileTree LI.ext_doc { background: url(images/doc.png) left top no-repeat; }
.jqueryFileTree LI.ext_exe { background: url(images/application.png) left top no-repeat; }
.jqueryFileTree LI.ext_gif { background: url(images/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_fla { background: url(images/flash.png) left top no-repeat; }
.jqueryFileTree LI.ext_h { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_htm { background: url(images/html.png) left top no-repeat; }
.jqueryFileTree LI.ext_html { background: url(images/html.png) left top no-repeat; }
.jqueryFileTree LI.ext_jar { background: url(images/java.png) left top no-repeat; }
.jqueryFileTree LI.ext_jpg { background: url(images/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_jpeg { background: url(images/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_js { background: url(images/script.png) left top no-repeat; }
.jqueryFileTree LI.ext_lasso { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_log { background: url(images/txt.png) left top no-repeat; }
.jqueryFileTree LI.ext_m4p { background: url(images/music.png) left top no-repeat; }
.jqueryFileTree LI.ext_mov { background: url(images/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_mp3 { background: url(images/music.png) left top no-repeat; }
.jqueryFileTree LI.ext_mp4 { background: url(images/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_mpg { background: url(images/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_mpeg { background: url(images/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_ogg { background: url(images/music.png) left top no-repeat; }
.jqueryFileTree LI.ext_pcx { background: url(images/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_pdf { background: url(images/pdf.png) left top no-repeat; }
.jqueryFileTree LI.ext_php { background: url(images/php.png) left top no-repeat; }
.jqueryFileTree LI.ext_png { background: url(images/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_ppt { background: url(images/ppt.png) left top no-repeat; }
.jqueryFileTree LI.ext_psd { background: url(images/psd.png) left top no-repeat; }
.jqueryFileTree LI.ext_pl { background: url(images/script.png) left top no-repeat; }
.jqueryFileTree LI.ext_py { background: url(images/script.png) left top no-repeat; }
.jqueryFileTree LI.ext_rb { background: url(images/ruby.png) left top no-repeat; }
.jqueryFileTree LI.ext_rbx { background: url(images/ruby.png) left top no-repeat; }
.jqueryFileTree LI.ext_rhtml { background: url(images/ruby.png) left top no-repeat; }
.jqueryFileTree LI.ext_rpm { background: url(images/linux.png) left top no-repeat; }
.jqueryFileTree LI.ext_ruby { background: url(images/ruby.png) left top no-repeat; }
.jqueryFileTree LI.ext_sql { background: url(images/db.png) left top no-repeat; }
.jqueryFileTree LI.ext_swf { background: url(images/flash.png) left top no-repeat; }
.jqueryFileTree LI.ext_tif { background: url(images/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_tiff { background: url(images/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_txt { background: url(images/txt.png) left top no-repeat; }
.jqueryFileTree LI.ext_vb { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_wav { background: url(images/music.png) left top no-repeat; }
.jqueryFileTree LI.ext_wmv { background: url(images/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_xls { background: url(images/xls.png) left top no-repeat; }
.jqueryFileTree LI.ext_xml { background: url(images/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_zip { background: url(images/zip.png) left top no-repeat; }
\ No newline at end of file
#tabContaier{
background: #e4e4e4;
padding:3px;
position:relative;
/*position:relative;*/
width:757px;
font-size: 14px;
border-radius: 4px 4px 0 0;
......
......@@ -243,12 +243,12 @@ overflow-y: scroll;
color: #4c6172;
text-shadow: 0px 1px 1px #fff;
}
.dsblebutton{color:#9C9C9C; padding: 5px 10px;display: inline;background: #eee;
font-weight: bold; border:1px solid #000; margin-top:10px;}
.button {
padding: 5px 10px;
display: inline;
background: #eee;
border: none;
color: #000;
cursor: pointer;
font-weight: bold;
......
/**
* Free Web File Manager is free software released under MIT License.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* George Sarafov
* http://freewebfilemanager.com
*/
var gsItem = function (type, name, path, size, id, exta, lastMod) {
this.path = path;
this.type = type;
this.name = name;
this.size = size;
this.id = id;
this.exta = exta.toLowerCase();
this.lastMod = lastMod;
this.getSize = function () {
if (this.size < 1000000) {
return Math.ceil(this.size / 1000) + ' KB';
} else {
return Math.ceil(this.size / 1000000) + ' MB';
}
};
this.getExt = function () {
return this.exta;
};
this.getLastMod = function () {
return this.lastMod;
};
this.isEditable = function(){
return !this.isPicture() && !this.isArchive();
};
this.isPicture = function(){
return typeof(gs_ext_pictures[this.exta]) != 'undefined';
};
this.isArchive = function(){
return typeof(gs_ext_arhives[this.exta]) != 'undefined';
};
this.getType = function(){
type = 'unknown';
if (this.isPicture()) {
type = 'picture';
} else if (this.isEditable()) {
type = 'editable';
} else if (this.isArchive()) {
type = 'archive';
}
return type;
};
};
var editor;
function setupEditor(){
editor = ace.edit("editor");
editor.setTheme("ace/theme/crimson_editor");
var CurentMode = require("ace/mode/text").Mode;
editor.getSession().setMode(new CurentMode());
editor.getSession().setTabSize(2);
editor.getSession().setUseSoftTabs(true);
editor.renderer.setHScrollBarAlwaysVisible(false);
editor.setReadOnly(true);
}
function updateCoords(c){
jQuery('#gs_jcrop_x').val(c.x);
jQuery('#gs_jcrop_y').val(c.y);
jQuery('#gs_jcrop_w').val(c.w);
jQuery('#gs_jcrop_h').val(c.h);
}
function gs_get_cur_item(id){
result = null;
if (typeof(gs_cur_items[id]) != 'undefined') {
result = gs_cur_items[id];
}
return result;
}
function gs_show_loading() {
jQuery("#gs_dir_content").html('<div class="loadingDiv">&nbsp;</div>');
}
function gsGetSelectedItemsPath() {
var arr = new Array();
for (var x in gs_clipboard) {
arr.push(gs_clipboard[x].path);
}
if (arr.length > 0) {
return arr.join(',,,');
}
return null;
}
function gsGetSelectedItems(){
var arr = new Array();
jQuery("#gs_content_table div.rowSelected").each(function(){
var id = jQuery(this).attr('rel');
if (typeof(gs_cur_items[id]) != 'undefined') {
arr.push(gs_cur_items[id].name);
}
});
if (arr.length > 0) {
return arr.join(',,,');
}
return null;
}
function gsCheckResponce (data) {
if (typeof(data) == 'undefined') {
return;
}
if (data.substr(0 , 9) == '{result: ') {
eval('var my_responce = ' + data + ';');
if (typeof(my_responce.result != 'undefined')) {
if (my_responce.result == '1') {
//alert('OK');
} else if (typeof(my_responce.gserror) != 'undefined') {
alert(my_responce.gserror);
} else {
alert('Error');
}
}
delete my_responce;
}
}
function gs_storeSelectedItems(){
gs_clipboard = new Array();
jQuery("#gs_content_table div.rowSelected").each(function(){
var id = jQuery(this).attr('rel');
if (typeof(gs_cur_items[id]) != 'undefined') {
gs_clipboard.push(gs_cur_items[id]);
} else {
alert('Uknown item selected');
}
});
}
function gs_showClipboardContent(){
var diva = jQuery('#gsclipboardContent');
var divaHtml = '';
for (var xx in gs_clipboard) {
var clasa = 'file';
if (gs_clipboard[xx].getExt() == 'dir') {
clasa = 'directory';
}
divaHtml += '<div class="'+ clasa +'">&nbsp;&nbsp;&nbsp;' + gs_clipboard[xx].path + '<div>';
}
diva.html(divaHtml);
diva.dialog({
title: 'Clipboard',
modal: true,
buttons: {
"Clear": function() {
gs_clipboard = new Array();
jQuery('#gsclipboardContent').html('');
jQuery("#gsClipBoard").html('0 items');
jQuery(this).dialog('close');
}
}
});
return false;
}
function gs_makeUrl(root, params){
if (root.indexOf('?') !=-1) {
return root + '&' + params;
} else {
return root + '?' + params;
}
}
var gs_filemanager_languages = new Array();
gs_filemanager_languages['en'] = new Array();
gs_filemanager_languages['en'][1] = 'Current Dir';
gs_filemanager_languages['en'][2] = 'Clipboard';
gs_filemanager_languages['en'][3] = 'Upload';
gs_filemanager_languages['en'][4] = 'New File';
gs_filemanager_languages['en'][5] = 'New Directory';
gs_filemanager_languages['en'][6] = 'Paste';
gs_filemanager_languages['en'][7] = 'Name';
gs_filemanager_languages['en'][8] = 'Type';
gs_filemanager_languages['en'][9] = 'Size';
gs_filemanager_languages['en'][10] = 'Last Modified';
gs_filemanager_languages['en'][11] = 'Open with';
gs_filemanager_languages['en'][12] = 'View file';
gs_filemanager_languages['en'][13] = 'Open in editor';
gs_filemanager_languages['en'][14] = 'Copy';
gs_filemanager_languages['en'][15] = 'Cut';
gs_filemanager_languages['en'][16] = 'Rename';
gs_filemanager_languages['en'][17] = 'Copy AS';
gs_filemanager_languages['en'][18] = 'Download';
gs_filemanager_languages['en'][19] = 'Delete';
gs_filemanager_languages['en'][20] = 'Open';
gs_filemanager_languages['en'][21] = 'CKeditor';
gs_filemanager_languages['en'][22] = 'JCrop';
gs_filemanager_languages['en'][23] = 'Select all';
gs_filemanager_languages['en'][24] = 'Deselect all';
gs_filemanager_languages['en'][25] = 'Invert selection';
gs_filemanager_languages['en'][26] = 'Width';
gs_filemanager_languages['en'][27] = 'Height';
gs_filemanager_languages['en'][28] = 'Cancel';
gs_filemanager_languages['en'][29] = 'Upload File';
gs_filemanager_languages['en'][30] = 'Items';
gs_filemanager_languages['en'][31] = 'Save';
gs_filemanager_languages['en'][32] = 'Resize';
gs_filemanager_languages['en'][33] = 'Crop';
gs_filemanager_languages['en'][34] = 'As name';
gs_filemanager_languages['en'][35] = 'New name';
gs_filemanager_languages['en'][36] = 'File name';
gs_filemanager_languages['en'][37] = 'Directory name';
gs_filemanager_languages['en'][38] = 'Are you sure that you want to deleted selected items?';
gs_filemanager_languages['en'][39] = 'Zip directory';
gs_filemanager_languages['en'][40] = 'Zip file';
gs_filemanager_languages['en'][41] = 'Zip archive name';
gs_filemanager_languages['en'][42] = 'UnZip';
gs_filemanager_languages['en'][43] = 'UnZip Name';
gs_filemanager_languages['en'][44] = 'Lock sizes';
function gs_getTranslation(lg, code){
result = null;
if (typeof(gs_filemanager_languages[lg]) != 'undefined') {
if (typeof(gs_filemanager_languages[lg][code]) != 'undefined') {
result = gs_filemanager_languages[lg][code];
}
}
return result;
}
var gs_cur_items = new Array();
var gs_clipboard = new Array();
var gs_ext_pictures = new Array();
gs_ext_pictures['png'] = '1';
gs_ext_pictures['jpg'] = '1';
gs_ext_pictures['jpeg'] = '1';
gs_ext_pictures['gif'] = '1';
gs_ext_pictures['pdf'] = '1';
gs_ext_pictures['ico'] = '1';
var gs_ext_arhives = new Array();
gs_ext_arhives['zip'] = '1';
var gs_forbitten_ext_mapping = new Array();
gs_forbitten_ext_mapping['editable'] = '16,17,23';
gs_forbitten_ext_mapping['picture'] = '12,18,23';
gs_forbitten_ext_mapping['unknown'] = '12,15,16,17,18,23';
gs_forbitten_ext_mapping['archive'] = '12,15,16,17,18,19';
if (jQuery) (function(jQuery){
jQuery.extend(jQuery.fn, {
gsFileManager: function(o) {
if( !o ) var o = {};
if( o.root == undefined ) o.root = '/';
if( o.language == undefined ) o.language = 'en';
if( o.script == undefined ) o.script = 'jqueryFileTree.php';
if( o.expandSpeed == undefined ) o.expandSpeed= 500;
if( o.collapseSpeed == undefined ) o.collapseSpeed= 500;
if( o.expandEasing == undefined ) o.expandEasing = null;
if( o.collapseEasing == undefined ) o.collapseEasing = null;
if( o.loadMessage == undefined ) o.loadMessage = 'Loading...';
var menuHtml = '<div class="gs_title"><span class=\'gsHeadText\'> ' + gs_getTranslation(o.language, 1)+ ': </span><span id=\'curDir\'></span></div>';
menuHtml += '<div class="gs_head"><a id="gs_uploadbutton" class=\'lshare no-right-border\'>&nbsp;' + gs_getTranslation(o.language, 3)+ '&nbsp;</a>';
menuHtml += '<a id="gs_newfilebutton" class=\'lshare no-right-border\'>&nbsp;' + gs_getTranslation(o.language, 4)+ '&nbsp;</a>';
menuHtml += '<a id="gs_newdirbutton" class=\'lshare no-right-border\'>&nbsp;' + gs_getTranslation(o.language, 5)+ '&nbsp;</a>';
menuHtml += '<a id="gs_pastebutton" class=\'lshare no-right-border\'>&nbsp;' + gs_getTranslation(o.language, 6)+ '&nbsp;</a>';
menuHtml += '<a id="gs_selectallbutton" class=\'lshare no-right-border\'>&nbsp;' + gs_getTranslation(o.language, 23)+ '&nbsp;</a>';
menuHtml += '<a id="gs_deselectbutton" class=\'lshare\'>&nbsp;' + gs_getTranslation(o.language, 24)+ '&nbsp;</a></div>';
menuHtml += '<span id=\'gsClipBoard\'>0 items</span>';
var wrapperHtml = '<div id=\'gs_dir_list\' class=\'gs_dir_list\' onClick="jQuery(this).doGSAction({action: 21})"></div>';
wrapperHtml += '<div class=\'gs_dir_content\' onClick="jQuery(this).doGSAction({action: 21})">'
+ '<div class=\'gs_dir_content_menu\'>';
wrapperHtml += menuHtml;
wrapperHtml += ' </div>';
wrapperHtml += '<div id=\'gs_dir_content\' class=\'gs_dir_content_files\'></div>';
wrapperHtml += '</div></div>';
var contexMenus = '<ul id="gsFileMenu" class="contextMenu">';
contexMenus += '<li class="edit"><a href="#edit">' + gs_getTranslation(o.language, 11)+ '</a>';
contexMenus += ' <ul class="contextMenu subContextMenu">';
contexMenus += ' <li class="picture"><a href="#notepad" rel="12">' + gs_getTranslation(o.language, 12)+ '</a></li>';
contexMenus += ' <li class="notepad separator"><a href="#imageviewer" rel="15">' + gs_getTranslation(o.language, 13)+ '</a></li>';
contexMenus += ' </ul>';
contexMenus += '</li>';
contexMenus += '<li class="copy separator"><a href="#Copy" rel="7">' + gs_getTranslation(o.language, 14)+ '</a></li>';
contexMenus += '<li class="cut"><a href="#Cut" rel="8">' + gs_getTranslation(o.language, 15)+ '</a></li>';
contexMenus += '<li class="rename"><a href="#Rename" rel="10">' + gs_getTranslation(o.language, 16)+ '</a></li>';
contexMenus += '<li class="rename"><a href="#Copy As" rel="13">' + gs_getTranslation(o.language, 17)+ '</a></li>';
contexMenus += '<li class="zip"><a href="#zip" rel="19">' + gs_getTranslation(o.language, 40)+ '</a></li>';
contexMenus += '<li class="zip"><a href="#zip" rel="23">' + gs_getTranslation(o.language, 42)+ '</a></li>';
contexMenus += '<li class="download separator"><a href="#Download" rel="11">' + gs_getTranslation(o.language, 18)+ '</a></li>';
contexMenus += '<li class="delete"><a href="#Delete" rel="6">' + gs_getTranslation(o.language, 19)+ '</a></li>';
contexMenus += '</ul>';
contexMenus += '<ul id="gsDirMenu" class="contextMenu">';
contexMenus += '<li class="directorymenu"><a href="#Open" rel="5">' + gs_getTranslation(o.language, 20)+ '</a></li>';
contexMenus += '<li class="copy separator"><a href="#Copy" rel="7">' + gs_getTranslation(o.language, 14)+ '</a></li>';
contexMenus += '<li class="cut"><a href="#Cut" rel="8">' + gs_getTranslation(o.language, 15)+ '</a></li>';
contexMenus += '<li class="rename"><a href="#Rename" rel="10">' + gs_getTranslation(o.language, 16)+ '</a></li>';
contexMenus += '<li class="zip"><a href="#zip" rel="19">' + gs_getTranslation(o.language, 39)+ '</a></li>';
contexMenus += '<li class="zip"><a href="#zip" rel="23">' + gs_getTranslation(o.language, 42)+ '</a></li>';
contexMenus += '<li class="delete"><a href="#Delete" rel="4">' + gs_getTranslation(o.language, 19)+ '</a></li>';
contexMenus += '</ul>';
contexMenus += '<ul id="gsContentMenu" class="contextMenu">';
contexMenus += '<li class="paste separator"><a href="#Paste" rel="9">' + gs_getTranslation(o.language, 6)+ '</a></li>';
contexMenus += '<li class="newfile separator"><a href="#New File" rel="2">' + gs_getTranslation(o.language, 4)+ '</a></li>';
contexMenus += '<li class="newdir"><a href="#New Directory" rel="3">' + gs_getTranslation(o.language, 5)+ '</a></li>';
contexMenus += '<li class="uploadfolder separator"><a href="#Upload" rel="14">' + gs_getTranslation(o.language, 3)+ '</a></li>';
contexMenus += '<li class="selection separator"><a href="#Select All" rel="20">' + gs_getTranslation(o.language, 23)+ '</a></li>';
contexMenus += '<li class="selection"><a href="#>Deselect all" rel="21">' + gs_getTranslation(o.language, 24)+ '</a></li>';
contexMenus += '<li class="selection"><a href="#Invert selection" rel="22">' + gs_getTranslation(o.language, 25)+ '</a></li>';
contexMenus += '</ul>';
wrapperHtml += contexMenus;
var hiddenElements = '<div id=\'gsclipboardContent\' style=\'display: none\'></div>';
hiddenElements += '<a id="showfile" style="display:none" href="#sfile_content">File content</a>';
hiddenElements += '<div style="display:none">';
hiddenElements += '<div id="sfile_content" style="padding:10px; background:#fff;"></div></div>';
hiddenElements += '<a class="inline" style="display:none" href="#inline_content">Inline HTML</a>';
hiddenElements += '<div style="display:none">';
hiddenElements += '<div id="inline_content" style="padding:10px; background:#fff;"><h2 style="color: #4c6172; font: 18px \'Helvetica Neue\', Helvetica, Arial, sans-serif;">';
hiddenElements += 'Upload Files</h2><p id="xmllog" class="message"><br/></p>';
hiddenElements += '<form action="' + o.script +'" id="gsUploadForm" enctype="multipart/form-data"><input type="hidden" name="opt" value="11"><input type="hidden" name="dir" value="">';
hiddenElements += '<div class="fileinputs"><input type="file" name="filename" size="30" id="gsUploadButton">';
hiddenElements += '<br/><input type=submit value="Load" id="submit_inline" class="button"></div></form></div></div>';
wrapperHtml += hiddenElements;
jQuery(this).html(wrapperHtml);
jQuery('#gs_dir_content').contextMenu({
menu: 'gsContentMenu',
addSelectedClass: false
},
function(action, el, pos) {
jQuery(el).doGSAction({
action: action,
script: o.script,
type: 'context',
lg: o.language
});
});
jQuery('#gs_uploadbutton').click(function (e){
e.stopPropagation();
jQuery(this).doGSAction({
action: 14,
script: o.script,
type: 'file',
lg: o.language
});
});
jQuery('#gs_newfilebutton').click(function (e){
e.stopPropagation();
jQuery(this).doGSAction({
action: 2,
script: o.script,
type: 'file',
lg: o.language
});
});
jQuery('#gs_newdirbutton').click(function (e){
e.stopPropagation();
jQuery(this).doGSAction({
action: 3,
script: o.script,
type: 'dir',
lg: o.language
});
});
jQuery('#gs_pastebutton').click(function (e){
e.stopPropagation();
jQuery(this).doGSAction({
script: o.script,
action: 9,
lg: o.language
});
});
jQuery('#gs_selectallbutton').click(function (e){
e.stopPropagation();
jQuery(this).doGSAction({
action: 20,
script: o.script,
type: 'context',
lg: o.language
});
});
jQuery('#gs_deselectbutton').click(function (e){
e.stopPropagation();
jQuery(this).doGSAction({
action: 21,
script: o.script,
type: 'context',
lg: o.language
});
});
jQuery('#gs_invertselectbutton').click(function (e){
e.stopPropagation();
return jQuery(this).doGSAction({
action: 22,
script: o.script,
type: 'context',
lg: o.language
});
});
jQuery('#gsUploadForm').ajaxForm({
beforeSubmit: function () {
jQuery('#gsuploadfiles').append('<div class="loadingDiv">&nbsp;</div>');
},
success: function (responseText, statusText, xhr, $form) {
gsCheckResponce(responseText);
jQuery('#'+jQuery("#curDir").attr('rel')).trigger('click');
jQuery('#gsuploadfiles').find('div.loadingDiv').remove();
},
dataType: 'script'
});
function showFiles (gsfiless) {
var fileshtml = '';
if (gsfiless.length > 0) {
for (var num in gsfiless) {
var curItem = gsfiless[num];
gs_cur_items[curItem.id] = curItem;
fileshtml += "<tr><td class='first'><div class='file gsItem directory_info ext_" + curItem.getExt() + "' rel=\'" + curItem.id + "\'>" + curItem.name + "</div></td><td align='center'><span class=\'file_ext_name\'>" + curItem.getExt() + "</span></td><td align='center'>" + curItem.getSize() + "</td><td align='center'>"+curItem.getLastMod()+"</td></tr>";
}
}
return fileshtml;
}
function manageGsMenu (srcElement, menu){
if (srcElement.attr('rel') == 'up') {
return false;
}
gs_item = gs_cur_items[srcElement.attr('rel')];
type = gs_item.getType();
if (typeof(gs_forbitten_ext_mapping[type]) != 'undefined') {
menu.disableContextMenuItems(gs_forbitten_ext_mapping[type]);
}
return true;
}
function showDirs (gsfiless) {
var fileshtml = '';
var gs_lastparent = jQuery('#' + jQuery("#curDir").attr('rel')).parent().parent().parent().children('a');
if (gs_lastparent.length > 0) {
fileshtml += "<tr><td class='first'><div class='directory directory_info gsItem' rel=\'up\'><a href='javascript:void(0)' onclick=\"jQuery('#" + jQuery("#curDir").attr('rel')+ "').parent().parent().parent().children('a').trigger('click'); return false\"> parent...</a></div></td align='center'><td align='center'>Folder</td><td align='center'>-</td><td align='center'>-</td></tr>";
}
if (gsfiless.length > 0) {
for (var numf in gsfiless) {
var curItem = gsfiless[numf];
gs_cur_items[curItem.id] = curItem;
fileshtml += "<tr><td class='first'><div class='directory directory_info gsItem' rel=\'" + curItem.id + "\'><a href='javascript:void(0)' onclick=\"jQuery('#"+curItem.id+"').trigger('click'); return false\">" + curItem.name + "</a></div></td><td align='center'>Folder</td><td align='center'>-</td><td align='center'>"+curItem.getLastMod()+"</td></tr>";
}
}
return fileshtml;
}
function showContent (gsdirss, gsfiless) {
var dirshtml = showDirs (gsdirss);
var fileshtml = showFiles (gsfiless);
var tableheader = '<table class=\'dirs_files_table\' cellpadding=0 cellspacing=2 id="gs_content_table"><tr><th>' + gs_getTranslation(o.language, 7)+ '</th><th width=\'10%\'>' + gs_getTranslation(o.language, 8)+ '</th><th width=\'10%\'>' + gs_getTranslation(o.language, 9)+ '</th><th width=\'20%\'>' + gs_getTranslation(o.language, 10)+ '</th></tr>';
jQuery('#gs_dir_content').html(tableheader + dirshtml + fileshtml + "</table>");
jQuery('div.file').contextMenu({
menu: 'gsFileMenu'
},
function(action, el, pos) {
jQuery(el).doGSAction({
action: action,
script: o.script,
type: 'file',
lg: o.language
});
},
manageGsMenu);
jQuery('table.dirs_files_table tr').find('div.gsItem').bind('click', function(e){
var cur_element = jQuery(this);
var rel = jQuery(this).attr('rel');
if (rel != 'up') {
if (cur_element.hasClass('rowSelected')) {
cur_element.removeClass('rowSelected');
} else {
cur_element.addClass('rowSelected');
}
}
jQuery(".contextMenu").hide();
return false;
});
jQuery('div.directory').contextMenu({
menu: 'gsDirMenu'
},
function(action, el, pos) {
jQuery(el).doGSAction({
action: action,
script: o.script,
type: 'dir',
lg: o.language
});
},
manageGsMenu);
}
function showTree(c, t) {
var cObject = jQuery(c);
cObject.addClass('wait');
gs_show_loading();
jQuery(".jqueryFileTree.start").remove();
jQuery.ajax({
type: 'POST',
url: o.script,
data: {
dir: t
},
dataType: 'script',
contentType : 'application/x-www-form-urlencoded; charset=utf-8',
success: function(data) {
//remember current dir id
jQuery("#curDir").html(unescape(t));
jQuery("#curDir").attr('rel', jQuery('a', cObject).attr('id'));
gs_cur_items = new Array();
var dirhtml = '';
if (typeof(gsdirs) != 'undefined' && gsdirs.length > 0) {
dirhtml += "<ul class=\"jqueryFileTree\" style=\"display: none;\">";
for (var num in gsdirs) {
var curItem = gsdirs[num];
dirhtml += "<li class=\"directoryMeny collapsed\"><span class='dir_index toggleplus'>&nbsp;&nbsp;&nbsp;&nbsp;</span><a href=\"#\" rel=\"" + curItem.path + "/\" id=\"" + curItem.id + "\">" + curItem.name + "</a></li>";
}
dirhtml += "</ul>";
} else {
gsdirs = new Array();
}
if (typeof(gsfiles) == 'undefined') {
gsfiles = new Array();
}
cObject.find('.start').html('');
cObject.find('UL').remove();
cObject.removeClass('wait').append(dirhtml);
showContent(gsdirs, gsfiles, unescape(t));
if( o.root == t ) {
cObject.find('UL:hidden').show();
} else {
cObject.find('UL:hidden').slideDown({
duration: o.expandSpeed,
easing: o.expandEasing
});
}
setHandlers(cObject);
}
});
}
function setHandlers(t) {
//jQuery(t).find('LI').droppable();
jQuery(t).find('LI > A').bind('click', function () {
showTree (jQuery(this).parent(), encodeURIComponent(jQuery(this).attr('rel').match( /.*\// )));
});
}
function showRoot(){
showTree( jQuery('#gs_dir_list'), escape(o.root));
}
var cusElement = jQuery('#gs_dir_list');
// Loading message
cusElement.html('<ul class="jqueryFileTree start"><li class="wait">' + o.loadMessage + '<li></ul>');
// Get the initial file list
cusElement.prepend('<a href="#" id="rootLink">root</a>');
cusElement.find('#rootLink').bind('click', showRoot);
showRoot();
},
doGSAction: function(o) {
if (o.action == '20') { // select
jQuery("#gs_content_table div.gsItem").each(function(){
if (jQuery(this).attr('rel') != 'up') {
jQuery(this).addClass('rowSelected');
}
});
return false;
}
if (o.action == '21') { // deselect
jQuery("#gs_content_table div.gsItem").each(function(){
jQuery(this).removeClass('rowSelected');
});
return false;
}
if (o.action == '22') { // invert select
jQuery("#gs_content_table div.gsItem").each(function(){
if (jQuery(this).attr('rel') != 'up') {
if (jQuery(this).hasClass('rowSelected')) {
jQuery(this).removeClass('rowSelected');
} else {
jQuery(this).addClass('rowSelected');
}
}
});
return false;
}
var curDir = jQuery("#curDir").html();
var dataForSend = null;
var gsitem = gs_get_cur_item(jQuery(this).attr('rel'));
if (gsitem == null) {
//alert('no gsitem');
}
if (o.action == '23') { // zip
unZipItem(o, curDir, gsitem);
return;
}
if (o.action == '12') { // show notepad
showNotePad(o, curDir, gsitem);
return;
}
if (o.action == '13') { // copy as
copyAs(o, curDir, gsitem);
return;
}
if (o.action == '14') { // show upload
$.colorbox.remove();
$(".inline").colorbox({inline:true, width: "480px", height: "200px", onComplete:function(){
//nothing
}});
$(".inline").click();
$("#submit_inline").click(function(){
jQuery("#inline_content").find("input[name=dir]").val(curDir);
jQuery('#gsUploadForm').submit();
$("#cboxClose").click();
return false;
});
}
if (o.action == '15') { // Edit file in nex windows
var url = $SCRIPT_ROOT+"/editFile?profile="+encodeURIComponent(curDir+"/"+gsitem.name)+"&filename="+encodeURIComponent(gsitem.name);
window.open(url, '_blank');
window.focus();
return;
}
if (o.action == '19') { // zip
zipItem(o, curDir, gsitem);
return;
}
if (o.action == '7') { // copy
var clipBoard = jQuery("#gsClipBoard");
gs_storeSelectedItems();
clipBoard.html('(Copy) ' + gs_clipboard.length + ' ' + gs_getTranslation(o.lg, 30));
clipBoard.attr('rel', o.action);
return;
}
if (o.action == '8') { // cut
var clipBoard = jQuery("#gsClipBoard");
gs_storeSelectedItems();
clipBoard.html('(Cut) ' + gs_clipboard.length + ' ' + gs_getTranslation(o.lg, 30));
clipBoard.attr('rel', o.action);
return;
}
if (o.action == '9') { //paste
pasteItems(o, curDir, gsitem);
return;
}
if (o.action == '10') { //rename
renameItem(o, curDir, gsitem);
return;
}
if (o.action == '11') { //download
dataForSend = {
opt: 8,
filename: gsitem.name,
dir: curDir
};
location.href= gs_makeUrl(o.script, jQuery.param(dataForSend));
return;
}
if (o.action == '2') { //new file
newFile(o, curDir, gsitem);
return;
}
if (o.action == '3') { //new dir
newDir(o, curDir, gsitem);
return;
}
if (o.action == '4' || o.action == '6') { //delete item
deleteItem(o, curDir, gsitem);
return;
}
if (o.action == '5') { //open dir
jQuery('#' + gsitem.id).trigger('click');
return;
}
function showNotePad(o, curDir, gsitem){
$.colorbox.remove();
$("#sfile_content").empty();
$("#sfile_content").append('<br/><br/><br/><div class="loadingDiv">&nbsp;</div>');
dataForSend = {
opt: 9,
filename: encodeURIComponent(gsitem.name),
dir: curDir
};
sendAndRefresh(o, dataForSend, false, function(data) {
$("#sfile_content").empty();
$("#sfile_content").append('<h2 style="color: #4c6172; font: 18px \'Helvetica Neue\', Helvetica, Arial, sans-serif;">Content of file: ' +
gsitem.name +'</h2>');
$("#sfile_content").append('<br/><div class="main_content"><pre id="editor"></pre></div>');
setupEditor();
$("#showfile").colorbox({inline:true, width: "847px", onComplete:function(){
editor.getSession().setValue(data);
}});
$("#showfile").click();
});
}
function pasteItems(o, curDir, gsitem){
var clipBoard = jQuery("#gsClipBoard");
var opt = null;
var selectedFiles = gsGetSelectedItemsPath();
if (clipBoard.attr('rel') == '7') { //copy
opt = 5;
} else if (clipBoard.attr('rel') == '8') { // paste
gs_clipboard = new Array();
clipBoard.html('0 items');
jQuery('#gsclipboardContent').html('');
clipBoard.attr('rel', '');
opt = 7;
} else {
return;
}
if (selectedFiles != null) {
dataForSend = {
opt: opt,
files: selectedFiles,
dir: curDir
};
sendAndRefresh(o, dataForSend, true);
}
if (opt == 7) {
for (var xx in gs_clipboard) {
if (gs_clipboard[xx].getExt() == 'dir') {
jQuery("#" + gs_clipboard[xx].id).parent().remove();
}
}
}
}
function copyAs(o, curDir, gsitem){
var newName = window.prompt(gs_getTranslation(o.lg, 34) + ': ', gsitem.name);
if (newName == null) {
return;
}
dataForSend = {
opt: 14,
filename: gsitem.name,
dir: curDir,
newfilename: newName
};
sendAndRefresh(o, dataForSend, true);
}
function unZipItem(o, curDir, gsitem){
var newName = window.prompt(gs_getTranslation(o.lg, 43) + ': ', 'unzipped_' + gsitem.name);
if (newName == null) {
return;
}
dataForSend = {
opt: 17,
filename: gsitem.name,
dir: curDir,
newfilename: newName
};
sendAndRefresh(o, dataForSend, true);
}
function zipItem(o, curDir, gsitem){
var newName = window.prompt(gs_getTranslation(o.lg, 41) + ': ', gsitem.name + '.zip');
if (newName == null) {
return;
}
dataForSend = {
opt: 16,
filename: gsitem.name,
dir: curDir,
newfilename: newName
};
sendAndRefresh(o, dataForSend, true);
}
function renameItem(o, curDir, gsitem){
var newName = window.prompt(gs_getTranslation(o.lg, 35) + ': ', gsitem.name);
if (newName == null) {
return;
}
dataForSend = {
opt: 6,
filename: curDir+gsitem.name,
dir: curDir,
newfilename: newName
};
sendAndRefresh(o, dataForSend, true);
}
function newFile(o, curDir, gsitem){
var newName = window.prompt(gs_getTranslation(o.lg, 36) + ': ');
if (newName == null || newName.length < 1) {
return;
}
dataForSend = {
opt: 2,
filename: newName,
dir: curDir
};
sendAndRefresh(o, dataForSend, true);
}
function newDir(o, curDir, gsitem){
var newName = window.prompt(gs_getTranslation(o.lg, 37) + ': ');
if (newName == null || newName.length < 1) {
return;
}
dataForSend = {
opt: 3,
filename: newName,
dir: curDir
};
sendAndRefresh(o, dataForSend, true);
}
function deleteItem(o, curDir, gsitem){
if(!window.confirm(gs_getTranslation(o.lg, 38))){
return;
}
var selectedFiles = gsGetSelectedItems();
//alert('sel ' + selectedFiles);
if (selectedFiles != null) {
dataForSend = {
opt: 4,
files: encodeURIComponent(selectedFiles),
dir: curDir
};
}
sendAndRefresh(o, dataForSend, true);
}
function sendAndRefresh(o, dataForSend, refresh, callback, type) {
if (refresh) {
gs_show_loading();
}
if (typeof(type) == 'undefined') {
type = 'text';
}
dataForSend.dir = encodeURIComponent(dataForSend.dir);
jQuery.ajax({
type: 'POST',
url: o.script,
data: jQuery.param(dataForSend) + '&time='+ new Date().getTime(),
dataType: type,
contentType : 'application/x-www-form-urlencoded; charset=utf-8',
success: function(data) {
gsCheckResponce(data);
if (refresh) {
jQuery('#'+jQuery("#curDir").attr('rel')).trigger('click');
}
if (callback) {
callback(data);
}
}
});
}
}
});
})(jQuery);
//jQuery Context Menu Plugin
//
// Version 1.01
//
// Cory S.N. LaViska
// A Beautiful Site (http://abeautifulsite.net/)
//
// More info: http://abeautifulsite.net/2008/09/jquery-context-menu-plugin/
//
// Terms of Use
//
// This plugin is dual-licensed under the GNU General Public License
// and the MIT License and is copyright A Beautiful Site, LLC.
//
if(jQuery)( function() {
jQuery.extend(jQuery.fn, {
contextMenu: function(o, callback, onShowMenu) {
// Defaults
if( o.menu == undefined ) return false;
if( o.inSpeed == undefined ) o.inSpeed = 150;
if( o.addSelectedClass == undefined ) o.addSelectedClass = true;
if( o.outSpeed == undefined ) o.outSpeed = 75;
// 0 needs to be -1 for expected results (no fade)
if( o.inSpeed == 0 ) o.inSpeed = -1;
if( o.outSpeed == 0 ) o.outSpeed = -1;
// Loop each context menu
jQuery(this).each( function() {
var el = jQuery(this);
var offset = jQuery(el).offset();
// Add contextMenu class
jQuery('#' + o.menu).addClass('contextMenu');
// Simulate a true right click
jQuery(this).mousedown( function(e) {
var evt = e;
evt.stopPropagation();
jQuery(this).mouseup( function(e) {
e.stopPropagation();
var srcElement = jQuery(this);
srcElement.unbind('mouseup');
if( evt.button == 2 ) {
// Hide context menus that may be showing
jQuery(".contextMenu").hide();
// Get this context menu
var menu = jQuery('#' + o.menu);
menu.enableContextMenuItems();
if (onShowMenu) {
if (!onShowMenu( srcElement, menu )) {
return false;
}
}
if (!srcElement.hasClass('rowSelected')){
jQuery("#gs_content_table div.gsItem").each(function(){
jQuery(this).removeClass('rowSelected');
});
if (o.addSelectedClass) {
srcElement.addClass('rowSelected');
}
}
var jmenu = jQuery(menu);
if( jQuery(el).hasClass('disabled')) {
return false;
}
// Detect mouse position
var d = {}, x, y;
if( self.innerHeight ) {
d.pageYOffset = self.pageYOffset;
d.pageXOffset = self.pageXOffset;
d.innerHeight = self.innerHeight;
d.innerWidth = self.innerWidth;
} else if( document.documentElement &&
document.documentElement.clientHeight ) {
d.pageYOffset = document.documentElement.scrollTop;
d.pageXOffset = document.documentElement.scrollLeft;
d.innerHeight = document.documentElement.clientHeight;
d.innerWidth = document.documentElement.clientWidth;
} else if( document.body ) {
d.pageYOffset = document.body.scrollTop;
d.pageXOffset = document.body.scrollLeft;
d.innerHeight = document.body.clientHeight;
d.innerWidth = document.body.clientWidth;
}
(e.pageX) ? x = e.pageX : x = e.clientX + d.scrollLeft;
(e.pageY) ? y = e.pageY : y = e.clientY + d.scrollTop;
// Show the menu
jQuery(document).unbind('click');
jmenu.css({
top: y,
left: x
}).fadeIn(o.inSpeed);
// Hover events
jmenu.find('A').mouseover( function() {
jmenu.find('LI.hover').removeClass('hover');
if (!jQuery(this).parent().parent().hasClass('subContextMenu')) {
jmenu.find('UL.subContextMenu').hide();
}
jQuery(this).parent().addClass('hover');
jQuery(this).parent().find('UL').css({
top: 0,
left: 120
}).fadeIn(o.inSpeed);
}).mouseout( function() {
jmenu.find('LI.hover').removeClass('hover');
});
// When items are selected
menu.find('A').unbind('click');
menu.find('A').bind('click', function() {
if(jQuery(this).parent().hasClass('disabled')){
return false;
}
jQuery(".contextMenu").hide();
// Callback
if (callback) {
callback( jQuery(this).attr('rel'), jQuery(srcElement), {
x: x - offset.left,
y: y - offset.top,
docX: x,
docY: y
} );
}
return false;
});
// Hide bindings
setTimeout( function() { // Delay for Mozilla
jQuery(document).click( function() {
jQuery(menu).fadeOut(o.outSpeed);
});
}, 0);
}
});
});
// Disable text selection
if( jQuery.browser.mozilla ) {
jQuery('#' + o.menu).each( function() {
jQuery(this).css({
'MozUserSelect' : 'none'
});
});
} else if( jQuery.browser.msie ) {
jQuery('#' + o.menu).each( function() {
jQuery(this).bind('selectstart.disableTextSelect', function() {
return false;
});
});
} else {
jQuery('#' + o.menu).each(function() {
jQuery(this).bind('mousedown.disableTextSelect', function() {
return false;
});
});
}
// Disable browser context menu (requires both selectors to work in IE/Safari + FF/Chrome)
jQuery(el).add(jQuery('UL.contextMenu')).bind('contextmenu', function() {
return false;
});
});
return jQuery(this);
},
// Disable context menu items on the fly
disableContextMenuItems: function(o) {
if( o == undefined ) {
// Disable all
jQuery(this).find('LI').addClass('disabled');
return( jQuery(this) );
}
jQuery(this).each( function() {
if( o != undefined ) {
var d = o.split(',');
for( var i = 0; i < d.length; i++ ) {
//alert(d[i]);
jQuery(this).find('A[rel="' + d[i] + '"]').parent().addClass('disabled');
}
}
});
return( jQuery(this) );
},
// Enable context menu items on the fly
enableContextMenuItems: function(o) {
if( o == undefined ) {
// Enable all
jQuery(this).find('LI.disabled').removeClass('disabled');
return( jQuery(this) );
}
jQuery(this).each( function() {
if( o != undefined ) {
var d = o.split(',');
for( var i = 0; i < d.length; i++ ) {
jQuery(this).find('A[rel="' + d[i] + '"]').parent().removeClass('disabled');
}
}
});
return( jQuery(this) );
},
// Disable context menu(s)
disableContextMenu: function() {
jQuery(this).each( function() {
jQuery(this).addClass('disabled');
});
return( jQuery(this) );
},
// Enable context menu(s)
enableContextMenu: function() {
jQuery(this).each( function() {
jQuery(this).removeClass('disabled');
});
return( jQuery(this) );
},
// Destroy context menu(s)
destroyContextMenu: function() {
// Destroy specified context menus
jQuery(this).each( function() {
// Disable action
jQuery(this).unbind('mousedown').unbind('mouseup');
});
return( jQuery(this) );
}
});
})(jQuery);
\ No newline at end of file
/*!
* jQuery Form Plugin
* version: 3.15 (09-SEP-2012)
* @requires jQuery v1.3.2 or later
*
* Examples and documentation at: http://malsup.com/jquery/form/
* Project repository: https://github.com/malsup/form
* Dual licensed under the MIT and GPL licenses:
* http://malsup.github.com/mit-license.txt
* http://malsup.github.com/gpl-license-v2.txt
*/
/*global ActiveXObject alert */
;(function($) {
"use strict";
/*
Usage Note:
-----------
Do not use both ajaxSubmit and ajaxForm on the same form. These
functions are mutually exclusive. Use ajaxSubmit if you want
to bind your own submit handler to the form. For example,
$(document).ready(function() {
$('#myForm').on('submit', function(e) {
e.preventDefault(); // <-- important
$(this).ajaxSubmit({
target: '#output'
});
});
});
Use ajaxForm when you want the plugin to manage all the event binding
for you. For example,
$(document).ready(function() {
$('#myForm').ajaxForm({
target: '#output'
});
});
You can also use ajaxForm with delegation (requires jQuery v1.7+), so the
form does not have to exist when you invoke ajaxForm:
$('#myForm').ajaxForm({
delegation: true,
target: '#output'
});
When using ajaxForm, the ajaxSubmit function will be invoked for you
at the appropriate time.
*/
/**
* Feature detection
*/
var feature = {};
feature.fileapi = $("<input type='file'/>").get(0).files !== undefined;
feature.formdata = window.FormData !== undefined;
/**
* ajaxSubmit() provides a mechanism for immediately submitting
* an HTML form using AJAX.
*/
$.fn.ajaxSubmit = function(options) {
/*jshint scripturl:true */
// fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
if (!this.length) {
log('ajaxSubmit: skipping submit process - no element selected');
return this;
}
var method, action, url, $form = this;
if (typeof options == 'function') {
options = { success: options };
}
method = this.attr('method');
action = this.attr('action');
url = (typeof action === 'string') ? $.trim(action) : '';
url = url || window.location.href || '';
if (url) {
// clean url (don't include hash vaue)
url = (url.match(/^([^#]+)/)||[])[1];
}
options = $.extend(true, {
url: url,
success: $.ajaxSettings.success,
type: method || 'GET',
iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
}, options);
// hook for manipulating the form data before it is extracted;
// convenient for use with rich editors like tinyMCE or FCKEditor
var veto = {};
this.trigger('form-pre-serialize', [this, options, veto]);
if (veto.veto) {
log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
return this;
}
// provide opportunity to alter form data before it is serialized
if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
log('ajaxSubmit: submit aborted via beforeSerialize callback');
return this;
}
var traditional = options.traditional;
if ( traditional === undefined ) {
traditional = $.ajaxSettings.traditional;
}
var elements = [];
var qx, a = this.formToArray(options.semantic, elements);
if (options.data) {
options.extraData = options.data;
qx = $.param(options.data, traditional);
}
// give pre-submit callback an opportunity to abort the submit
if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
log('ajaxSubmit: submit aborted via beforeSubmit callback');
return this;
}
// fire vetoable 'validate' event
this.trigger('form-submit-validate', [a, this, options, veto]);
if (veto.veto) {
log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
return this;
}
var q = $.param(a, traditional);
if (qx) {
q = ( q ? (q + '&' + qx) : qx );
}
if (options.type.toUpperCase() == 'GET') {
options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
options.data = null; // data is null for 'get'
}
else {
options.data = q; // data is the query string for 'post'
}
var callbacks = [];
if (options.resetForm) {
callbacks.push(function() { $form.resetForm(); });
}
if (options.clearForm) {
callbacks.push(function() { $form.clearForm(options.includeHidden); });
}
// perform a load on the target only if dataType is not provided
if (!options.dataType && options.target) {
var oldSuccess = options.success || function(){};
callbacks.push(function(data) {
var fn = options.replaceTarget ? 'replaceWith' : 'html';
$(options.target)[fn](data).each(oldSuccess, arguments);
});
}
else if (options.success) {
callbacks.push(options.success);
}
options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
var context = options.context || this ; // jQuery 1.4+ supports scope context
for (var i=0, max=callbacks.length; i < max; i++) {
callbacks[i].apply(context, [data, status, xhr || $form, $form]);
}
};
// are there files to upload?
var fileInputs = $('input:file:enabled[value]', this); // [value] (issue #113)
var hasFileInputs = fileInputs.length > 0;
var mp = 'multipart/form-data';
var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
var fileAPI = feature.fileapi && feature.formdata;
log("fileAPI :" + fileAPI);
var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI;
// options.iframe allows user to force iframe mode
// 06-NOV-09: now defaulting to iframe mode if file input is detected
if (options.iframe !== false && (options.iframe || shouldUseFrame)) {
// hack to fix Safari hang (thanks to Tim Molendijk for this)
// see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
if (options.closeKeepAlive) {
$.get(options.closeKeepAlive, function() {
fileUploadIframe(a);
});
}
else {
fileUploadIframe(a);
}
}
else if ((hasFileInputs || multipart) && fileAPI) {
fileUploadXhr(a);
}
else {
$.ajax(options);
}
// clear element array
for (var k=0; k < elements.length; k++)
elements[k] = null;
// fire 'notify' event
this.trigger('form-submit-notify', [this, options]);
return this;
// utility fn for deep serialization
function deepSerialize(extraData){
var serialized = $.param(extraData).split('&');
var len = serialized.length;
var result = {};
var i, part;
for (i=0; i < len; i++) {
part = serialized[i].split('=');
result[decodeURIComponent(part[0])] = decodeURIComponent(part[1]);
}
return result;
}
// XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz)
function fileUploadXhr(a) {
var formdata = new FormData();
for (var i=0; i < a.length; i++) {
formdata.append(a[i].name, a[i].value);
}
if (options.extraData) {
var serializedData = deepSerialize(options.extraData);
for (var p in serializedData)
if (serializedData.hasOwnProperty(p))
formdata.append(p, serializedData[p]);
}
options.data = null;
var s = $.extend(true, {}, $.ajaxSettings, options, {
contentType: false,
processData: false,
cache: false,
type: 'POST'
});
if (options.uploadProgress) {
// workaround because jqXHR does not expose upload property
s.xhr = function() {
var xhr = jQuery.ajaxSettings.xhr();
if (xhr.upload) {
xhr.upload.onprogress = function(event) {
var percent = 0;
var position = event.loaded || event.position; /*event.position is deprecated*/
var total = event.total;
if (event.lengthComputable) {
percent = Math.ceil(position / total * 100);
}
options.uploadProgress(event, position, total, percent);
};
}
return xhr;
};
}
s.data = null;
var beforeSend = s.beforeSend;
s.beforeSend = function(xhr, o) {
o.data = formdata;
if(beforeSend)
beforeSend.call(this, xhr, o);
};
$.ajax(s);
}
// private function for handling file uploads (hat tip to YAHOO!)
function fileUploadIframe(a) {
var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle;
var useProp = !!$.fn.prop;
if ($(':input[name=submit],:input[id=submit]', form).length) {
// if there is an input with a name or id of 'submit' then we won't be
// able to invoke the submit fn on the form (at least not x-browser)
alert('Error: Form elements must not have name or id of "submit".');
return;
}
if (a) {
// ensure that every serialized input is still enabled
for (i=0; i < elements.length; i++) {
el = $(elements[i]);
if ( useProp )
el.prop('disabled', false);
else
el.removeAttr('disabled');
}
}
s = $.extend(true, {}, $.ajaxSettings, options);
s.context = s.context || s;
id = 'jqFormIO' + (new Date().getTime());
if (s.iframeTarget) {
$io = $(s.iframeTarget);
n = $io.attr('name');
if (!n)
$io.attr('name', id);
else
id = n;
}
else {
$io = $('<iframe name="' + id + '" src="'+ s.iframeSrc +'" />');
$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
}
io = $io[0];
xhr = { // mock object
aborted: 0,
responseText: null,
responseXML: null,
status: 0,
statusText: 'n/a',
getAllResponseHeaders: function() {},
getResponseHeader: function() {},
setRequestHeader: function() {},
abort: function(status) {
var e = (status === 'timeout' ? 'timeout' : 'aborted');
log('aborting upload... ' + e);
this.aborted = 1;
// #214
if (io.contentWindow.document.execCommand) {
try { // #214
io.contentWindow.document.execCommand('Stop');
} catch(ignore) {}
}
$io.attr('src', s.iframeSrc); // abort op in progress
xhr.error = e;
if (s.error)
s.error.call(s.context, xhr, e, status);
if (g)
$.event.trigger("ajaxError", [xhr, s, e]);
if (s.complete)
s.complete.call(s.context, xhr, e);
}
};
g = s.global;
// trigger ajax global events so that activity/block indicators work like normal
if (g && 0 === $.active++) {
$.event.trigger("ajaxStart");
}
if (g) {
$.event.trigger("ajaxSend", [xhr, s]);
}
if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
if (s.global) {
$.active--;
}
return;
}
if (xhr.aborted) {
return;
}
// add submitting element to data if we know it
sub = form.clk;
if (sub) {
n = sub.name;
if (n && !sub.disabled) {
s.extraData = s.extraData || {};
s.extraData[n] = sub.value;
if (sub.type == "image") {
s.extraData[n+'.x'] = form.clk_x;
s.extraData[n+'.y'] = form.clk_y;
}
}
}
var CLIENT_TIMEOUT_ABORT = 1;
var SERVER_ABORT = 2;
function getDoc(frame) {
var doc = frame.contentWindow ? frame.contentWindow.document : frame.contentDocument ? frame.contentDocument : frame.document;
return doc;
}
// Rails CSRF hack (thanks to Yvan Barthelemy)
var csrf_token = $('meta[name=csrf-token]').attr('content');
var csrf_param = $('meta[name=csrf-param]').attr('content');
if (csrf_param && csrf_token) {
s.extraData = s.extraData || {};
s.extraData[csrf_param] = csrf_token;
}
// take a breath so that pending repaints get some cpu time before the upload starts
function doSubmit() {
// make sure form attrs are set
var t = $form.attr('target'), a = $form.attr('action');
// update form attrs in IE friendly way
form.setAttribute('target',id);
if (!method) {
form.setAttribute('method', 'POST');
}
if (a != s.url) {
form.setAttribute('action', s.url);
}
// ie borks in some cases when setting encoding
if (! s.skipEncodingOverride && (!method || /post/i.test(method))) {
$form.attr({
encoding: 'multipart/form-data',
enctype: 'multipart/form-data'
});
}
// support timout
if (s.timeout) {
timeoutHandle = setTimeout(function() { timedOut = true; cb(CLIENT_TIMEOUT_ABORT); }, s.timeout);
}
// look for server aborts
function checkState() {
try {
var state = getDoc(io).readyState;
log('state = ' + state);
if (state && state.toLowerCase() == 'uninitialized')
setTimeout(checkState,50);
}
catch(e) {
log('Server abort: ' , e, ' (', e.name, ')');
cb(SERVER_ABORT);
if (timeoutHandle)
clearTimeout(timeoutHandle);
timeoutHandle = undefined;
}
}
// add "extra" data to form if provided in options
var extraInputs = [];
try {
if (s.extraData) {
for (var n in s.extraData) {
if (s.extraData.hasOwnProperty(n)) {
// if using the $.param format that allows for multiple values with the same name
if($.isPlainObject(s.extraData[n]) && s.extraData[n].hasOwnProperty('name') && s.extraData[n].hasOwnProperty('value')) {
extraInputs.push(
$('<input type="hidden" name="'+s.extraData[n].name+'">').attr('value',s.extraData[n].value)
.appendTo(form)[0]);
} else {
extraInputs.push(
$('<input type="hidden" name="'+n+'">').attr('value',s.extraData[n])
.appendTo(form)[0]);
}
}
}
}
if (!s.iframeTarget) {
// add iframe to doc and submit the form
$io.appendTo('body');
if (io.attachEvent)
io.attachEvent('onload', cb);
else
io.addEventListener('load', cb, false);
}
setTimeout(checkState,15);
form.submit();
}
finally {
// reset attrs and remove "extra" input elements
form.setAttribute('action',a);
if(t) {
form.setAttribute('target', t);
} else {
$form.removeAttr('target');
}
$(extraInputs).remove();
}
}
if (s.forceSync) {
doSubmit();
}
else {
setTimeout(doSubmit, 10); // this lets dom updates render
}
var data, doc, domCheckCount = 50, callbackProcessed;
function cb(e) {
if (xhr.aborted || callbackProcessed) {
return;
}
try {
doc = getDoc(io);
}
catch(ex) {
log('cannot access response document: ', ex);
e = SERVER_ABORT;
}
if (e === CLIENT_TIMEOUT_ABORT && xhr) {
xhr.abort('timeout');
return;
}
else if (e == SERVER_ABORT && xhr) {
xhr.abort('server abort');
return;
}
if (!doc || doc.location.href == s.iframeSrc) {
// response not received yet
if (!timedOut)
return;
}
if (io.detachEvent)
io.detachEvent('onload', cb);
else
io.removeEventListener('load', cb, false);
var status = 'success', errMsg;
try {
if (timedOut) {
throw 'timeout';
}
var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
log('isXml='+isXml);
if (!isXml && window.opera && (doc.body === null || !doc.body.innerHTML)) {
if (--domCheckCount) {
// in some browsers (Opera) the iframe DOM is not always traversable when
// the onload callback fires, so we loop a bit to accommodate
log('requeing onLoad callback, DOM not available');
setTimeout(cb, 250);
return;
}
// let this fall through because server response could be an empty document
//log('Could not access iframe DOM after mutiple tries.');
//throw 'DOMException: not available';
}
//log('response detected');
var docRoot = doc.body ? doc.body : doc.documentElement;
xhr.responseText = docRoot ? docRoot.innerHTML : null;
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
if (isXml)
s.dataType = 'xml';
xhr.getResponseHeader = function(header){
var headers = {'content-type': s.dataType};
return headers[header];
};
// support for XHR 'status' & 'statusText' emulation :
if (docRoot) {
xhr.status = Number( docRoot.getAttribute('status') ) || xhr.status;
xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText;
}
var dt = (s.dataType || '').toLowerCase();
var scr = /(json|script|text)/.test(dt);
if (scr || s.textarea) {
// see if user embedded response in textarea
var ta = doc.getElementsByTagName('textarea')[0];
if (ta) {
xhr.responseText = ta.value;
// support for XHR 'status' & 'statusText' emulation :
xhr.status = Number( ta.getAttribute('status') ) || xhr.status;
xhr.statusText = ta.getAttribute('statusText') || xhr.statusText;
}
else if (scr) {
// account for browsers injecting pre around json response
var pre = doc.getElementsByTagName('pre')[0];
var b = doc.getElementsByTagName('body')[0];
if (pre) {
xhr.responseText = pre.textContent ? pre.textContent : pre.innerText;
}
else if (b) {
xhr.responseText = b.textContent ? b.textContent : b.innerText;
}
}
}
else if (dt == 'xml' && !xhr.responseXML && xhr.responseText) {
xhr.responseXML = toXml(xhr.responseText);
}
try {
data = httpData(xhr, dt, s);
}
catch (e) {
status = 'parsererror';
xhr.error = errMsg = (e || status);
}
}
catch (e) {
log('error caught: ',e);
status = 'error';
xhr.error = errMsg = (e || status);
}
if (xhr.aborted) {
log('upload aborted');
status = null;
}
if (xhr.status) { // we've set xhr.status
status = (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) ? 'success' : 'error';
}
// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
if (status === 'success') {
if (s.success)
s.success.call(s.context, data, 'success', xhr);
if (g)
$.event.trigger("ajaxSuccess", [xhr, s]);
}
else if (status) {
if (errMsg === undefined)
errMsg = xhr.statusText;
if (s.error)
s.error.call(s.context, xhr, status, errMsg);
if (g)
$.event.trigger("ajaxError", [xhr, s, errMsg]);
}
if (g)
$.event.trigger("ajaxComplete", [xhr, s]);
if (g && ! --$.active) {
$.event.trigger("ajaxStop");
}
if (s.complete)
s.complete.call(s.context, xhr, status);
callbackProcessed = true;
if (s.timeout)
clearTimeout(timeoutHandle);
// clean up
setTimeout(function() {
if (!s.iframeTarget)
$io.remove();
xhr.responseXML = null;
}, 100);
}
var toXml = $.parseXML || function(s, doc) { // use parseXML if available (jQuery 1.5+)
if (window.ActiveXObject) {
doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = 'false';
doc.loadXML(s);
}
else {
doc = (new DOMParser()).parseFromString(s, 'text/xml');
}
return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null;
};
var parseJSON = $.parseJSON || function(s) {
/*jslint evil:true */
return window['eval']('(' + s + ')');
};
var httpData = function( xhr, type, s ) { // mostly lifted from jq1.4.4
var ct = xhr.getResponseHeader('content-type') || '',
xml = type === 'xml' || !type && ct.indexOf('xml') >= 0,
data = xml ? xhr.responseXML : xhr.responseText;
if (xml && data.documentElement.nodeName === 'parsererror') {
if ($.error)
$.error('parsererror');
}
if (s && s.dataFilter) {
data = s.dataFilter(data, type);
}
if (typeof data === 'string') {
if (type === 'json' || !type && ct.indexOf('json') >= 0) {
data = parseJSON(data);
} else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
$.globalEval(data);
}
}
return data;
};
}
};
/**
* ajaxForm() provides a mechanism for fully automating form submission.
*
* The advantages of using this method instead of ajaxSubmit() are:
*
* 1: This method will include coordinates for <input type="image" /> elements (if the element
* is used to submit the form).
* 2. This method will include the submit element's name/value data (for the element that was
* used to submit the form).
* 3. This method binds the submit() method to the form for you.
*
* The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
* passes the options argument along after properly binding events for submit elements and
* the form itself.
*/
$.fn.ajaxForm = function(options) {
options = options || {};
options.delegation = options.delegation && $.isFunction($.fn.on);
// in jQuery 1.3+ we can fix mistakes with the ready state
if (!options.delegation && this.length === 0) {
var o = { s: this.selector, c: this.context };
if (!$.isReady && o.s) {
log('DOM not ready, queuing ajaxForm');
$(function() {
$(o.s,o.c).ajaxForm(options);
});
return this;
}
// is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
return this;
}
if ( options.delegation ) {
$(document)
.off('submit.form-plugin', this.selector, doAjaxSubmit)
.off('click.form-plugin', this.selector, captureSubmittingElement)
.on('submit.form-plugin', this.selector, options, doAjaxSubmit)
.on('click.form-plugin', this.selector, options, captureSubmittingElement);
return this;
}
return this.ajaxFormUnbind()
.bind('submit.form-plugin', options, doAjaxSubmit)
.bind('click.form-plugin', options, captureSubmittingElement);
};
// private event handlers
function doAjaxSubmit(e) {
/*jshint validthis:true */
var options = e.data;
if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
e.preventDefault();
$(this).ajaxSubmit(options);
}
}
function captureSubmittingElement(e) {
/*jshint validthis:true */
var target = e.target;
var $el = $(target);
if (!($el.is(":submit,input:image"))) {
// is this a child element of the submit el? (ex: a span within a button)
var t = $el.closest(':submit');
if (t.length === 0) {
return;
}
target = t[0];
}
var form = this;
form.clk = target;
if (target.type == 'image') {
if (e.offsetX !== undefined) {
form.clk_x = e.offsetX;
form.clk_y = e.offsetY;
} else if (typeof $.fn.offset == 'function') {
var offset = $el.offset();
form.clk_x = e.pageX - offset.left;
form.clk_y = e.pageY - offset.top;
} else {
form.clk_x = e.pageX - target.offsetLeft;
form.clk_y = e.pageY - target.offsetTop;
}
}
// clear form vars
setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100);
}
// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
$.fn.ajaxFormUnbind = function() {
return this.unbind('submit.form-plugin click.form-plugin');
};
/**
* formToArray() gathers form element data into an array of objects that can
* be passed to any of the following ajax functions: $.get, $.post, or load.
* Each object in the array has both a 'name' and 'value' property. An example of
* an array for a simple login form might be:
*
* [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
*
* It is this array that is passed to pre-submit callback functions provided to the
* ajaxSubmit() and ajaxForm() methods.
*/
$.fn.formToArray = function(semantic, elements) {
var a = [];
if (this.length === 0) {
return a;
}
var form = this[0];
var els = semantic ? form.getElementsByTagName('*') : form.elements;
if (!els) {
return a;
}
var i,j,n,v,el,max,jmax;
for(i=0, max=els.length; i < max; i++) {
el = els[i];
n = el.name;
if (!n) {
continue;
}
if (semantic && form.clk && el.type == "image") {
// handle image inputs on the fly when semantic == true
if(!el.disabled && form.clk == el) {
a.push({name: n, value: $(el).val(), type: el.type });
a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
}
continue;
}
v = $.fieldValue(el, true);
if (v && v.constructor == Array) {
if (elements)
elements.push(el);
for(j=0, jmax=v.length; j < jmax; j++) {
a.push({name: n, value: v[j]});
}
}
else if (feature.fileapi && el.type == 'file' && !el.disabled) {
if (elements)
elements.push(el);
var files = el.files;
if (files.length) {
for (j=0; j < files.length; j++) {
a.push({name: n, value: files[j], type: el.type});
}
}
else {
// #180
a.push({ name: n, value: '', type: el.type });
}
}
else if (v !== null && typeof v != 'undefined') {
if (elements)
elements.push(el);
a.push({name: n, value: v, type: el.type, required: el.required});
}
}
if (!semantic && form.clk) {
// input type=='image' are not found in elements array! handle it here
var $input = $(form.clk), input = $input[0];
n = input.name;
if (n && !input.disabled && input.type == 'image') {
a.push({name: n, value: $input.val()});
a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
}
}
return a;
};
/**
* Serializes form data into a 'submittable' string. This method will return a string
* in the format: name1=value1&amp;name2=value2
*/
$.fn.formSerialize = function(semantic) {
//hand off to jQuery.param for proper encoding
return $.param(this.formToArray(semantic));
};
/**
* Serializes all field elements in the jQuery object into a query string.
* This method will return a string in the format: name1=value1&amp;name2=value2
*/
$.fn.fieldSerialize = function(successful) {
var a = [];
this.each(function() {
var n = this.name;
if (!n) {
return;
}
var v = $.fieldValue(this, successful);
if (v && v.constructor == Array) {
for (var i=0,max=v.length; i < max; i++) {
a.push({name: n, value: v[i]});
}
}
else if (v !== null && typeof v != 'undefined') {
a.push({name: this.name, value: v});
}
});
//hand off to jQuery.param for proper encoding
return $.param(a);
};
/**
* Returns the value(s) of the element in the matched set. For example, consider the following form:
*
* <form><fieldset>
* <input name="A" type="text" />
* <input name="A" type="text" />
* <input name="B" type="checkbox" value="B1" />
* <input name="B" type="checkbox" value="B2"/>
* <input name="C" type="radio" value="C1" />
* <input name="C" type="radio" value="C2" />
* </fieldset></form>
*
* var v = $(':text').fieldValue();
* // if no values are entered into the text inputs
* v == ['','']
* // if values entered into the text inputs are 'foo' and 'bar'
* v == ['foo','bar']
*
* var v = $(':checkbox').fieldValue();
* // if neither checkbox is checked
* v === undefined
* // if both checkboxes are checked
* v == ['B1', 'B2']
*
* var v = $(':radio').fieldValue();
* // if neither radio is checked
* v === undefined
* // if first radio is checked
* v == ['C1']
*
* The successful argument controls whether or not the field element must be 'successful'
* (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
* The default value of the successful argument is true. If this value is false the value(s)
* for each element is returned.
*
* Note: This method *always* returns an array. If no valid value can be determined the
* array will be empty, otherwise it will contain one or more values.
*/
$.fn.fieldValue = function(successful) {
for (var val=[], i=0, max=this.length; i < max; i++) {
var el = this[i];
var v = $.fieldValue(el, successful);
if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
continue;
}
if (v.constructor == Array)
$.merge(val, v);
else
val.push(v);
}
return val;
};
/**
* Returns the value of the field element.
*/
$.fieldValue = function(el, successful) {
var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
if (successful === undefined) {
successful = true;
}
if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
(t == 'checkbox' || t == 'radio') && !el.checked ||
(t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
tag == 'select' && el.selectedIndex == -1)) {
return null;
}
if (tag == 'select') {
var index = el.selectedIndex;
if (index < 0) {
return null;
}
var a = [], ops = el.options;
var one = (t == 'select-one');
var max = (one ? index+1 : ops.length);
for(var i=(one ? index : 0); i < max; i++) {
var op = ops[i];
if (op.selected) {
var v = op.value;
if (!v) { // extra pain for IE...
v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
}
if (one) {
return v;
}
a.push(v);
}
}
return a;
}
return $(el).val();
};
/**
* Clears the form data. Takes the following actions on the form's input fields:
* - input text fields will have their 'value' property set to the empty string
* - select elements will have their 'selectedIndex' property set to -1
* - checkbox and radio inputs will have their 'checked' property set to false
* - inputs of type submit, button, reset, and hidden will *not* be effected
* - button elements will *not* be effected
*/
$.fn.clearForm = function(includeHidden) {
return this.each(function() {
$('input,select,textarea', this).clearFields(includeHidden);
});
};
/**
* Clears the selected form elements.
*/
$.fn.clearFields = $.fn.clearInputs = function(includeHidden) {
var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list
return this.each(function() {
var t = this.type, tag = this.tagName.toLowerCase();
if (re.test(t) || tag == 'textarea') {
this.value = '';
}
else if (t == 'checkbox' || t == 'radio') {
this.checked = false;
}
else if (tag == 'select') {
this.selectedIndex = -1;
}
else if (includeHidden) {
// includeHidden can be the value true, or it can be a selector string
// indicating a special test; for example:
// $('#myForm').clearForm('.special:hidden')
// the above would clean hidden inputs that have the class of 'special'
if ( (includeHidden === true && /hidden/.test(t)) ||
(typeof includeHidden == 'string' && $(this).is(includeHidden)) )
this.value = '';
}
});
};
/**
* Resets the form data. Causes all form elements to be reset to their original value.
*/
$.fn.resetForm = function() {
return this.each(function() {
// guard against an input with the name of 'reset'
// note that IE reports the reset function as an 'object'
if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
this.reset();
}
});
};
/**
* Enables or disables any matching elements.
*/
$.fn.enable = function(b) {
if (b === undefined) {
b = true;
}
return this.each(function() {
this.disabled = !b;
});
};
/**
* Checks/unchecks any matching checkboxes or radio buttons and
* selects/deselects and matching option elements.
*/
$.fn.selected = function(select) {
if (select === undefined) {
select = true;
}
return this.each(function() {
var t = this.type;
if (t == 'checkbox' || t == 'radio') {
this.checked = select;
}
else if (this.tagName.toLowerCase() == 'option') {
var $sel = $(this).parent('select');
if (select && $sel[0] && $sel[0].type == 'select-one') {
// deselect all other options
$sel.find('option').selected(false);
}
this.selected = select;
}
});
};
// expose debug var
$.fn.ajaxSubmit.debug = false;
// helper fn for console logging
function log() {
if (!$.fn.ajaxSubmit.debug)
return;
var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
if (window.console && window.console.log) {
window.console.log(msg);
}
else if (window.opera && window.opera.postError) {
window.opera.postError(msg);
}
}
})(jQuery);
......@@ -3,7 +3,7 @@ $(document).ready(function(){
var hashes = window.location.href.split('#');
var fromheight = 0;
var previoustab = null;
if (hashes.length == 2 && hashes[1] != ""){
if (hashes.length == 2 && hashes[1] !== ''){
$("#tabContaier>ul li").each(function() {
var $tab = $(this).find("a");
if($tab.hasClass("active")){
......@@ -20,7 +20,7 @@ $(document).ready(function(){
else{$(".tabContents:first").show(); previoustab = ".tabContents:first";} // Show the first div of tab content by default
$("#tabContaier ul li a").click(function(){ //Fire the click event
if($(this).hasClass('active')){
return;
return false;
}
fromheight = $(previoustab).height();
var activeTab = $(this).attr("href"); // Catch the click link
......@@ -38,5 +38,6 @@ $(document).ready(function(){
});}
previoustab = activeTab;
$("#tabContaier .tabDetails").css("height", $("#tabContaier .tabDetails").height());
return false;//this reinitialize tab index when reload page
});
});
\ No newline at end of file
......@@ -3,33 +3,48 @@ String.prototype.toHtmlChar = function(){
var c = {'<':'&lt;', '>':'&gt;', '&':'&amp;', '"':'&quot;', "'":'&#039;',
'#':'&#035;' };
return this.replace( /[<&>'"#]/g, function(s) { return c[s]; } );
}
};
String.prototype.trim = function () {
return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
};
/****************************************/
function setInput($elt) {
if(!$elt){var $elt = $('input[type="text"], input[type="password"]');}
if(!$elt){$elt = $('input[type="text"], input[type="password"]');}
$elt.addClass("idleField");
$elt.focus(function() {
$(this).removeClass("idleField").addClass("focusField");
if (this.value == this.defaultValue){
this.value = '';
}
if(this.value != this.defaultValue){
this.select();
}
$elt.focus(function() {
$(this).removeClass("idleField").addClass("focusField");
if (this.value == this.defaultValue){
this.value = '';
}
if(this.value != this.defaultValue){
this.select();
}
});
$elt.blur(function() {
$(this).removeClass("focusField").addClass("idleField");
if ($.trim(this.value) == ''){
this.value = (this.defaultValue ? this.defaultValue : '');
if ($.trim(this.value) === ''){
this.value = (this.defaultValue ? this.defaultValue : '');
}
});
}
/*******************Bind remove all button*******************/
function bindRemove(){
$("a#removeSr").click(function(){
if(!window.confirm("Do you really want to remove all software release?")){
return false;
}
location.href = $SCRIPT_ROOT + '/removeSoftware';
});
$("a#removeIst").click(function(){
if(!window.confirm("Do you really want to remove all computer partition?")){
return false;
}
location.href = $SCRIPT_ROOT + '/removeInstance';
});
}
/**************************/
(function ($, document, window) {
$.extend($.fn, {
......
$(document).ready( function() {
var send = false;
var cloneRequest;
$('#fileTree').fileTree({ root: $("input#workdir").val(), script: $SCRIPT_ROOT + '/readFolder', folderEvent: 'click', expandSpeed: 750, collapseSpeed: 750, multiFolder: false }, function(file) {
selectFile(file);
});
$('#fileNavigator').gsFileManager({ script: $SCRIPT_ROOT+"/fileBrowser", root: "workspace/"});
configRadio();
$("input#nothing").change(function(){
configRadio();
......@@ -25,20 +23,20 @@ $(document).ready( function() {
}
var repo_url = $("input#repo").val();
var email = "";
var name = ""
var name = "";
/* /^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s<>\#%"\,\{\}\\|\\\^\[\]`]+)?$/ */
if($("input#repo").val() == "" || !repo_url.match(/^[\w\d\.\/:~@_-]+$/)){
if($("input#repo").val() === '' || !repo_url.match(/^[\w\d\.\/:~@_-]+$/)){
$("#error").Popup("Invalid url for the repository", {type:'alert', duration:3000});
return false;
}
if($("input#name").val() == "" || !$("input#name").val().match(/^[\w\d\._-]+$/)){
if($("input#name").val() === '' || !$("input#name").val().match(/^[\w\d\._-]+$/)){
$("#error").Popup("Invalid project name", {type:'alert', duration:3000});
return false;
}
if($("input#user").val() !== ""){
name = $("input#user").val();
}
if($("input#email").val() != "" && $("input#email").val() != "Enter your email adress..."){
if($("input#email").val() !== '' && $("input#email").val() !== "Enter your email adress..."){
if(!$("input#email").val().match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)){
$("#error").Popup("Please enter a valid email adress!", {type:'alert', duration:3000});
return false;
......@@ -77,8 +75,8 @@ $(document).ready( function() {
cloneRequest = $.ajax({
type: "POST",
url: $SCRIPT_ROOT + '/cloneRepository',
data: {repo: repo_url, name: ($("input#workdir").val() + "/"
+ $("input#name").val()), email:email,
data: {repo: repo_url, name: ($("input#workdir").val() + "/" +
$("input#name").val()), email:email,
user:name},
success: function(data){
if(data.code == 1){
......@@ -86,9 +84,7 @@ $(document).ready( function() {
$("#error").Popup("Your repository is cloned!", {type:'confirm', duration:3000});
$("input#repo").val("Enter the url of your repository...");
$("input#name").val("Enter the project name...");
$('#fileTree').fileTree({ root: $("input#workdir").val(), script: $SCRIPT_ROOT + '/readFolder', folderEvent: 'click', expandSpeed: 750, collapseSpeed: 750, multiFolder: false }, function(file) {
selectFile(file);
});
$('#fileNavigator').gsFileManager({ script: $SCRIPT_ROOT+"/fileBrowser", root: "workspace"});
}
else{
$("#error").Popup(data.result, {type:'error'});
......@@ -101,7 +97,7 @@ $(document).ready( function() {
error: function(request,error) {
$("#error").Popup("unable to clone your project, please check your internet connection", {type:'error', duration:3000});
$("#imgwaitting").hide();
$("#clone").empty();
$("#clone").empty();
$("#clone").append("Clone");
}
});
......
......@@ -63,15 +63,15 @@ $(document).ready(function() {
$.ajax({
type: 'GET',
url: $SCRIPT_ROOT + '/getParameterXml/xml',
success: function(data) {
if (data.code == 1) {
$('#inline_content').html(content);
success: function(data){
if(data.code == 1){
$("#inline_instance").html(content);
setupEditor(true);
$('.inline').colorbox({inline: true, width: '600px', height: '410px', onComplete: function() {
$("a#inlineInstance").colorbox({inline:true, width: "600px", height: "410px", onComplete:function(){
editor.getSession().setValue(data.result);
}});
$('.inline').click();
$('#loadxml').click(function() {
$("a#inlineInstance").click();
$("#loadxml").click(function(){
//Parse XML file
try {
var xmlDoc = $.parseXML(editor.getSession().getValue()), $xml = $(xmlDoc);
......@@ -109,32 +109,20 @@ $(document).ready(function() {
}
});
function setupFileTree(path) {
var root = $('input#root').val();
if (root == '') return;
if (path) {
root += '/' + path;
$('#tab4>h2').html('File content for <strong>' + path + '</strong>');
function setupFileTree(path){
var root = $("input#root").val();
if (root === '') return;
if (path){
root += '/' + path + '/';
}
else {$('#tab4>h2').html('File content for all your partitions');}
$('#fileTree').empty();
$('#fileTree').fileTree({ root: root, script: $SCRIPT_ROOT + '/readFolder', folderEvent: 'click', expandSpeed: 750,
collapseSpeed: 750, multiFolder: false, selectFolder: false }, function(file) {
}, function(file) {
//User have double click on file in to the fileTree
viewFile(file);
});
else{root += '/';}
$('#fileNavigator').gsFileManager({ script: $SCRIPT_ROOT+"/fileBrowser", root: root});
}
function viewFile(file) {
//User have double click on file in to the fileTree
loadFileContent(file);
}
$('#parameter').load($SCRIPT_ROOT + '/getParameterXml');
$('#update').click(function() {
if ($('#parameter').val() == '') {
$('#error').Popup('Can not save empty value!', {type: 'alert', duration: 3000});
$("#parameter").load($SCRIPT_ROOT + '/getParameterXml');
$("#update").click(function(){
if($("#parameter").val() === ''){
$("#error").Popup("Can not save empty value!", {type:'alert', duration:3000});
}
$.ajax({
type: 'POST',
......@@ -151,47 +139,6 @@ $(document).ready(function() {
});
});
function loadFileContent(file) {
$.ajax({
type: 'POST',
url: $SCRIPT_ROOT + '/checkFileType',
data: 'path=' + file,
success: function(data) {
if (data.code == 1) {
if (data.result == 'text') {
$.ajax({
type: 'POST',
url: $SCRIPT_ROOT + '/getFileContent',
data: {file: file, truncate: 1500},
success: function(data) {
if (data.code == 1) {
$('#inline_content').empty();
$('#inline_content').append('<h2 style="color: #4c6172; font: 18px \'Helvetica Neue\', Helvetica, Arial, sans-serif;">Inspect Instance Content: ' +
file + '</h2>');
$('#inline_content').append('<br/><div class="main_content"><pre id="editor"></pre></div>');
setupEditor();
$('.inline').colorbox({inline: true, width: '847px', onComplete: function() {
editor.getSession().setValue(data.result);
}});
$('.inline').click();
}
else {
$('#error').Popup('Can not load your file, please make sure that you have selected a Software Release', {type: 'alert', duration: 5000});
}
}
});
}
else {
//Can not displays binary file
$('#error').Popup(data.result, {type: 'alert', duration: 5000});
}
}
else {
$('#error').Popup(data.result, {type: 'alert', duration: 5000});
}
}
});
}
function updateParameter() {
var xml = '<?xml version="1.0" encoding="utf-8"?>\n',
software_type = '',
......@@ -233,7 +180,9 @@ $(document).ready(function() {
$txt.keyup(function() {
content = $txt.val().replace(/\n/g, '<br>');
hiddenDiv.html(content);
if (hiddenDiv.height() > $txt.height() && hiddenDiv.height() > 120) {return}
if (hiddenDiv.height() > $txt.height() && hiddenDiv.height() > 120) {
return;
}
$txt.css('height', hiddenDiv.height() + 'px');
});
}
......@@ -241,15 +190,15 @@ $(document).ready(function() {
$.ajax({
type: 'GET',
url: $SCRIPT_ROOT + '/getParameterXml/dict',
success: function(data) {
if (data.code == 1) {
success: function(data){
if(data.code == 1){
var dict = data.result['instance'];
for (propertie in dict) {
$('#add_attribute').click();
var size = Number($('#partitionParameter > tbody > tr').last().attr('id').split('_')[1]);
$('input#txt_' + size).val(propertie);
$('textarea#value_' + size).val(dict[propertie]);
$('textarea#value_' + size).keyup();
for (var propertie in dict){
$("#add_attribute").click();
var size = Number($("#partitionParameter > tbody > tr").last().attr('id').split('_')[1]);
$("input#txt_"+size).val(propertie);
$("textarea#value_"+size).val(dict[propertie]);
$("textarea#value_"+size).keyup();
}
}
else {
......@@ -302,10 +251,10 @@ $(document).ready(function() {
for (var i = 0; i < partitionAmount; i++) {
var elt = $('#slappart' + i + 'Parameter');
var fileId = $('#slappart' + i + 'Files');
if (elt && elt != undefined) elt.click(function() {
if (elt && elt !== undefined) elt.click(function() {
alert($(this).html());
});
if (fileId && fileId != undefined) fileId.click(function() {
if (fileId && fileId !== undefined) fileId.click(function() {
$('#instancetabfiles').click();
setupFileTree($(this).attr('rel'));
});
......
......@@ -2,35 +2,16 @@ $(document).ready( function() {
var editor;
var send = false;
var runnerDir = $("input#runnerdir").val();
var ajaxRun;
$("#reloadfiles").click(function(){
fillContent();
});
fillContent();
$("#softwarelist").change(function(){
$("#info").empty();
$("#info").append("Please select your file or folder into the box...");
fillContent();
});
function selectFile(file){
var relativeFile = file.replace(runnerDir + "/" + $("#softwarelist").val(), "");
$("#info").empty();
$("#info").append("Selection: " + relativeFile);
return;
}
function fillContent(){
var folder = $("#softwarelist").val();
var elt = $("option:selected", $("#softwarelist"));
if(elt.val() !== "No Software Release found"){
$('#fileTree').fileTree({ root: runnerDir + "/" + folder, script: $SCRIPT_ROOT + '/readFolder',
folderEvent: 'click', expandSpeed: 750, collapseSpeed: 750, multiFolder: false, selectFolder: true }, function(file) {
selectFile(file);
}, function(file){ viewFile(file)});
$("#softcontent").empty();
$("#softcontent").append("File content: " + elt.attr('title'));
}
$('#fileNavigator').gsFileManager({ script: $SCRIPT_ROOT+"/fileBrowser", root: runnerDir});
}
$("#open").click(function(){
$("#open").click(function(){
var elt = $("option:selected", $("#softwarelist"));
if(elt.val() === "No Software Release found"){
$("#error").Popup("Please select your Software Release", {type:'alert', duration:5000});
......@@ -58,34 +39,28 @@ $(document).ready( function() {
return false;
}
if(send) return;
if(!window.confirm("Do you really want to delete this software release?")){
return;
}
send = false;
var elt = $("option:selected", $("#softwarelist"));
$.ajax({
type: "POST",
url: $SCRIPT_ROOT + '/removeSoftwareDir',
data: "name=" + $("#softwarelist").val(),
data: {md5:$("#softwarelist").val(), title:elt.attr('title')},
success: function(data){
if(data.code == 1){
var folder = $("#softwarelist").val();
$("input#file").val("");
$("#info").empty();
$("#info").append("Please select your file or folder into the box...");
$("#softwarelist").empty();
for(i=0; i<data.result.length; i++){
$("#softwarelist").append('<option value="' + data.result[i]["md5"] +
'" title="' + data.result[i]["title"] +'" rel="' +
data.result[i]["path"] +'">' + data.result[i]["title"] + '</option>');
for(var i=0; i<data.result.length; i++){
$("#softwarelist").append('<option value="' + data.result[i]['md5'] +
'" title="' + data.result[i]['title'] +'" rel="' +
data.result[i]['path'] +'">' + data.result[i]['title'] + '</option>');
}
if(data.result.length < 1){
$("#softwarelist").append('<option>No Software Release found</option>');
$('#fileTree').empty();
}
else{
folder = $("#softwarelist").val();
$('#fileTree').fileTree({ root: runnerDir + "/" + folder, script: $SCRIPT_ROOT + '/readFolder', folderEvent: 'click', expandSpeed: 750,
collapseSpeed: 750, multiFolder: false, selectFolder: true }, function(file) {
selectFile(file);
}, function(file){ viewFile(file)});
}
fillContent();
$("#error").Popup("Operation complete, Selected Software Release has been delete!", {type:'confirm', duration:5000});
}
else{
......@@ -97,54 +72,6 @@ $(document).ready( function() {
return false;
});
function viewFile(file){
//User have double click on file in to the fileTree
var name = file.replace(runnerDir + "/" + $("#softwarelist").val(), "/software");
loadFileContent(file, name);
}
function loadFileContent(file, filename){
$.ajax({
type: "POST",
url: $SCRIPT_ROOT + '/checkFileType',
data: "path=" + file,
success: function(data){
if(data.code == 1){
if (data.result=="text"){
$.ajax({
type: "POST",
url: $SCRIPT_ROOT + '/getFileContent',
data: {file:file, truncate:1500},
success: function(data){
if(data.code == 1){
$("#inline_content").empty();
$("#inline_content").append('<h2 style="color: #4c6172; font: 18px \'Helvetica Neue\', Helvetica, Arial, sans-serif;">Inspect Software Content: ' +
filename +'</h2>');
$("#inline_content").append('<br/><div class="main_content"><pre id="editor"></pre></div>');
setupEditor();
$(".inline").colorbox({inline:true, width: "847px", onComplete:function(){
editor.getSession().setValue(data.result);
}});
$(".inline").click();
}
else{
$("#error").Popup("Can not load your file, please make sure that you have selected a Software Release", {type:'alert', duration:5000});
}
}
});
}
else{
//Can not displays binary file
$("#error").Popup(data.result, {type:'alert', duration:5000});
}
}
else{
$("#error").Popup(data.result, {type:'alert', duration:5000});
}
}
});
}
function setupEditor(){
editor = ace.edit("editor");
editor.setTheme("ace/theme/crimson_editor");
......
......@@ -15,6 +15,7 @@ $(document).ready( function() {
send = true;
var param = {clogin:$("input#clogin").val(), cpwd:$("input#cpwd").val()};
var url = $SCRIPT_ROOT + "/doLogin";
$("#login").removeClass("button").addClass("dsblebutton");
$.post(url, param, function(data) {
if (data.code==1){
location.href = $SCRIPT_ROOT + '/';
......@@ -23,9 +24,11 @@ $(document).ready( function() {
$("#error").Popup(data.result, {type:'alert', duration:3000});
}
})
.error(function() {$("#error").Popup("Cannot send your account identifier please try again!!",
.error(function() {
$("#error").Popup("Cannot send your account identifier please try again!!",
{type:'alert', duration:3000});})
.complete(function() {
$("#login").removeClass('dsblebutton').addClass('button');
send = false;
});
return false;
......
{% extends "layout.html" %}
{% block title %}Adding new repository{% endblock %}
{% block title %}Adding new project{% endblock %}
{% block head %}
{{ super() }}
<link href="{{ url_for('static', filename='css/jqueryFileTree.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<link href="{{ url_for('static', filename='css/gsFileManager.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<link href="{{ url_for('static', filename='css/jqueryTabs.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<script src="{{ url_for('static', filename='js/jquery/jqueryFileTree.js') }}" type="text/javascript" charset="utf-8"></script>
<link href="{{ url_for('static', filename='css/colorbox.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<script src="{{ url_for('static', filename='js/jquery/gsFileManager.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/scripts/folder.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/jquery/jqueryTabs.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/jquery/jquery.colorbox-min.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/ace/ace.js') }}" type="text/javascript" charset="utf-8"></script>
{% endblock %}
{% block body %}
<h2>Clone a repository into your workspace</h2><br/>
<h2>Clone a project repository into your workspace</h2><br/>
<div id="tabContaier">
<ul>
<li><a href="#tab1" class="active">Clone your repository</a></li>
......@@ -71,9 +74,8 @@
<!--Fin tab1-->
</div>
<div id="tab2" class="tabContents">
<h2>Content of your cloned project</h2><br/>
<div id="fileTree" class="file_tree_tabs"></div>
<div id="fileNavigator"></div>
</div>
</div>
</div>
</div>
{% endblock %}
{% extends "layout.html" %}
{% block title %}Edit {{filename}}{% endblock %}
{% block head %}
{{ super() }}
<script src="{{ url_for('static', filename='js/ace/ace.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/ace/theme-crimson_editor.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/ace/mode-buildout.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/scripts/editor.js') }}" type="text/javascript" charset="utf-8"></script>
{% endblock %}
{% block body %}
<form method=post class=add-entry>
<dl>
<dd><h2>Edit file {{ profile|safe }} <a href='#' id="editOption" rel="tooltip" title='Show more option'>[More]</a>:</h2></dd>
<dd><div class='md5sum' id='md5sum'></div></dd>
<dd>
<div class="main_content">
<pre id="editor"></pre>
<input type="hidden" name="profile" id="profile" value="{{ profile|safe }}" />
<input type="hidden" name="workdir" id="workdir" value="{{workDir}}"/>
</div>
</dd>
<dd><input type=submit value=Save id="save" class="button"></dd>
</dl>
</form>
<div id="tooltip-editOption" style="display:none">
<span class="list">MD5 SUM for the current file</span>
<div style="margin-top:3px; margin-bottom:5px;border-bottom: 1px dashed #666666; heigth:1px"></div>
<a id='getmd5' href="#">Get or Update md5sum</a>
<br/><span class="list">Add Project to Develop</span><br/>
<div style="margin-top:3px;border-bottom: 1px dashed #666666; heigth:1px"></div>
<ul id="plist">
{% for name in projectList%}
<li><input type="checkbox" name="develop" value="{{name}}" id="{{name}}">
<label>{{name}}</label></li>
{% endfor %}
</ul>
<br/>
<a href="#" id="adddevelop" class="lshare">Add to profile</a>
</div>
{% endblock %}
......@@ -2,8 +2,6 @@
{% block title %}Instance inspection{% endblock %}
{% block head %}
{{ super() }}
<link href="{{ url_for('static', filename='css/jqueryFileTree.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<script src="{{ url_for('static', filename='js/jquery/jqueryFileTree.js') }}" type="text/javascript" charset="utf-8"></script>
<link href="{{ url_for('static', filename='css/jqueryTabs.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<script src="{{ url_for('static', filename='js/jquery/jqueryTabs.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/ace/ace.js') }}" type="text/javascript" charset="utf-8"></script>
......@@ -11,6 +9,8 @@
<link href="{{ url_for('static', filename='css/colorbox.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<script src="{{ url_for('static', filename='js/jquery/jquery.colorbox-min.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/scripts/inspectInstance.js') }}" type="text/javascript" charset="utf-8"></script>
<link href="{{ url_for('static', filename='css/gsFileManager.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<script src="{{ url_for('static', filename='js/jquery/gsFileManager.js') }}" type="text/javascript" charset="utf-8"></script>
{% endblock %}
{% block body %}
<input type='hidden' name='root' id='root' value='{%if file_path != "" %}{{file_path}}{%endif%}' />
......@@ -97,7 +97,7 @@
</div><!-- end tab2 -->
<div id="tab3" class="tabContents">
<div id="softwareType">
<h2 class='hight'>Software Type of main instance</h2>
<h2 class='title'>Software Type of main instance</h2>
<input style="margin-top:5px;" type="text" name="software_type" id="software_type" size="35" value="Software Type here..." />
</div>
<br/>
......@@ -121,17 +121,25 @@
<div class="clear"></div>
</div><!-- end tab3 -->
<div id="tab4" class="tabContents">
<h2>File content for all your partitions</h2>
<div id="fileTree" class="file_tree_tabs" title="Double click to open file"></div>
<br/>
<a href="#" id="reloadfiles" class="lshare simple">Reload Files</a>
<!--<h2>File content for all your partitions</h2>
<div id="fileTree" class="file_tree_tabs" title="Double click to open file"></div>-->
{%if file_path != "" %}
<div id="fileNavigator"></div>
<br/>
<a href="#" id="reloadfiles" class="lshare simple">Reload Files</a>
{%else%}
<h2>Your partitions content is empty yet!
<br/>please run your software instance
and look for file result here.
</h2>
{%endif%}
</div><!-- end tab4 -->
</div>
</div>
<!-- This contains the hidden content for inline calls -->
<a class='inline' style='display:none' href="#inline_content">Inline HTML</a>
<a id='inlineInstance' style='display:none' href="#inline_instance">Inline HTML</a>
<div style='display:none'>
<div id='inline_content' style='padding:10px; background:#fff;'>
<div id='inline_instance' style='padding:10px; background:#fff;'>
</div>
</div>
......
......@@ -14,8 +14,9 @@
<link href="{{ url_for('static', filename='css/styles.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<script src="{{ url_for('static', filename='js/jquery/jquery-1.8.0.min.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/jquery/popup.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/jquery/jqueryToolTip.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/jquery/jquery.form.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/jquery/popup.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/jquery/jqueryToolTip.js') }}" type="text/javascript" charset="utf-8"></script>
<script type=text/javascript>
$SCRIPT_ROOT = {{ request.script_root|tojson|safe }};
</script>
......@@ -24,6 +25,7 @@
<script type="text/javascript">
$(document).ready(function() {
setInput();
bindRemove();
});
</script>
{% if request.path != '/login' %}
......@@ -67,14 +69,14 @@
<li><a href="{{ url_for('runSoftwareProfile') }}" id="softrun">Run</a></li>
<li><a href="{{ url_for('viewSoftwareLog') }}">Build log</a></li>
<li><a href="{{ url_for('inspectSoftware') }}">Inspect</a></li>
<li><a href="{{ url_for('removeSoftware') }}">Remove all</a></li>
<li><a id="removeSr" href="#">Remove all</a></li>
<li class="space"><span class="title_instance">Instance</span></li>
<li><a href="{{ url_for('editInstanceProfile') }}">Edit</a></li>
<li><a href="{{ url_for('runInstanceProfile') }}" id="instrun">Run</a></li>
<li><a href="{{ url_for('viewInstanceLog') }}">Build log</a></li>
<li><a href="{{ url_for('inspectInstance') }}">Inspect</a></li>
<li><a href="{{ url_for('removeInstance') }}">Remove all</a></li>
<li><a id="removeIst" href="#">Remove all</a></li>
</ul>
</div>
<div class="clear"></div>
......
......@@ -2,19 +2,19 @@
{% block title %}Webrunner software Inspection{% endblock %}
{% block head %}
{{ super() }}
<link href="{{ url_for('static', filename='css/jqueryFileTree.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<script src="{{ url_for('static', filename='js/jquery/jqueryFileTree.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/ace/ace.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/ace/theme-crimson_editor.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/scripts/inspectSoftware.js') }}" type="text/javascript" charset="utf-8"></script>
<link href="{{ url_for('static', filename='css/colorbox.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<script src="{{ url_for('static', filename='js/jquery/jquery.colorbox-min.js') }}" type="text/javascript" charset="utf-8"></script>
<link href="{{ url_for('static', filename='css/gsFileManager.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<script src="{{ url_for('static', filename='js/jquery/gsFileManager.js') }}" type="text/javascript" charset="utf-8"></script>
{% endblock %}
{% block body %}
<h2>Inspect software</h2>
<h2>Inspect software release</h2>
<input type="hidden" name="runnerdir" id="runnerdir" value="{{softwareRoot}}" />
<label for='softwarelist'>Select software: </label>
<label for='softwarelist'>Software Release: </label>
<select name="softwarelist" id="softwarelist">
{%if not softwares %}<option >No Software Release found</option>{% endif %}
{%for soft in softwares %}
......@@ -24,16 +24,8 @@
&nbsp;&nbsp;<button id ="delete" class="button" title="Remove this software">Remove</button>
&nbsp;&nbsp;<button id ="open" class="button" title="Set this software as current software release">Open</button>
<br/><br/>
<h2 id="softcontent">No file or folder to display</h2>
<div id="fileTree" class="file_tree" style='height:200px;' title="Double click to open file"></div>
<div id="file_info" class="file_info">
<span id="info">Please select your file or folder into the box...</span></div>
<!-- This contains the hidden content for inline calls -->
<a class='inline' style='display:none' href="#inline_content">Inline HTML</a>
<div style='display:none'>
<div id='inline_content' style='padding:10px; background:#fff;'>
</div>
</div>
<div id="fileNavigator"></div>
<br/>
<a href="#" id="reloadfiles" class="lshare simple">Reload Files</a>
<br/>
{% endblock %}
......@@ -275,27 +275,58 @@ def runSoftwareWithLock(config):
writePid(slapgrid_pid, slapgrid.pid)
slapgrid.wait()
#Saves the current compile software for re-use
#This uses the new folder create by slapgrid (if not exits yet)
data = loadSoftwareData(config['etc_dir'])
md5 = ""
for path in os.listdir(config['software_root']):
exist = False
for val in data:
if val['md5'] == path:
exist = True
conf = os.path.join(config['etc_dir'], ".project")
if not exist: #save this compile software folder
if os.path.exists(conf):
data.append({"title":getProjectTitle(config), "md5":path,
"path": open(os.path.join(config['etc_dir'],
".project"), 'r').read()})
writeSoftwareData(config['etc_dir'], data)
else:
shutil.rmtree(os.path.join(config['software_root'], path))
break
config_SR_folder(config)
return True
return False
def config_SR_folder(config):
"""Create a symbolik link for each folder in software folder. That allow
user to customize software release folder"""
list = []
config_name = 'slaprunner.config'
for path in os.listdir(config['software_link']):
cfg_path = os.path.join(config['software_link'], path, config_name)
if os.path.exists(cfg_path):
cfg = open(cfg_path, 'r').read().split("#")
if len(cfg) != 2:
continue #there is a broken config file
list.append(cfg[1])
folder_list = os.listdir(config['software_root'])
if len(folder_list) < 1:
return
curent_project = open(os.path.join(config['etc_dir'], ".project"),
'r').read()
projects = curent_project.split("/")
name = projects[len(projects) - 2]
for folder in folder_list:
if folder in list:
continue #this folder is already registered
else:
if not os.path.exists(os.path.join(config['software_link'], name)):
destination = os.path.join(config['software_link'], name)
else:
destination = os.path.join(config['software_link'], folder)
source = os.path.join(config['software_root'], folder)
cfg = os.path.join(destination, config_name)
#create symlink
os.symlink(source, destination)
#write config file
cf = open(cfg, 'w')
cf.write(curent_project+"#"+folder)
cf.close()
def loadSoftwareRList(config):
"""Return list (of dict) of Software Release from symbolik SR folder"""
list = []
config_name = 'slaprunner.config'
for path in os.listdir(config['software_link']):
cfg_path = os.path.join(config['software_link'], path, config_name)
if os.path.exists(cfg_path):
cfg = open(cfg_path, 'r').read().split("#")
if len(cfg) != 2:
continue #there is a broken config file
list.append(dict(md5=cfg[1], path=cfg[0], title=path))
return list
def isInstanceRunning(config):
"""
......@@ -535,7 +566,8 @@ def getProjectList(folder):
project = []
project_list = sorted(os.listdir(folder), key=str.lower)
for elt in project_list:
project.append(elt)
if os.path.isdir(os.path.join(folder, elt)):
project.append(elt)
return project
def configNewSR(config, projectpath):
......@@ -627,59 +659,26 @@ def getSoftwareReleaseName(config):
return software.replace(' ', '_')
return "No_name"
def loadSoftwareData(basedir):
"""Get All Compiled Softwares Releases name and directory
Agrs:
basedir: base directory of slapos web runner.
Returns:
a dictionnary that contains all compiled Software Release with path"""
import pickle
file_path = os.path.join(basedir, '.softdata')
if not os.path.exists(file_path):
return []
pkl_file = open(file_path, 'rb')
data = pickle.load(pkl_file)
pkl_file.close()
return data
def writeSoftwareData(basedir, data):
"""Save the list of compiled Software Release into a file
Args:
basedir: base directory of slapos web runner.
data: dictionnary data about real name and directory of each software release
"""
import pickle
file_path = os.path.join(basedir, '.softdata')
pkl_file = open(file_path, 'wb')
# Pickle dictionary using protocol 0.
pickle.dump(data, pkl_file)
pkl_file.close()
def removeSoftwareByName(config, folderName):
"""Remove all content of the specified software release
def removeSoftwareByName(config, md5, folderName):
"""Remove all content of the software release specified by md5
Args:
config: slaprunner configuration
foldername: the name given to the software release"""
foldername: the link name given to the software release
md5: the md5 filename given by slapgrid to SR folder"""
if isSoftwareRunning(config) or isInstanceRunning(config):
raise Exception("Software installation or instantiation in progress, cannot remove")
path = os.path.join(config['software_root'], folderName)
path = os.path.join(config['software_root'], md5)
linkpath = os.path.join(config['software_link'], folderName)
if not os.path.exists(path):
raise Exception("Cannot remove software Release: No such file or directory")
if not os.path.exists(linkpath):
raise Exception("Cannot remove software Release: No such file or directory %s" %
('software_root/'+folderName))
svcStopAll(config)
os.unlink(linkpath)
shutil.rmtree(path)
#update compiled software list
data = loadSoftwareData(config['etc_dir'])
i = 0
for p in data:
if p['md5'] == folderName:
del data[i]
writeSoftwareData(config['etc_dir'], data)
break
i = i+1
return data
return loadSoftwareRList(config)
def tail(f, lines=20):
"""
......@@ -775,7 +774,8 @@ def realpath(config, path, check_exist=True):
split_path = path.split('/')
key = split_path[0]
allow_list = {'software_root':config['software_root'], 'instance_root':
config['instance_root'], 'workspace': config['workspace']}
config['instance_root'], 'workspace': config['workspace'],
'software_link':config['software_link']}
if allow_list.has_key(key):
del split_path[0]
path = os.path.join(allow_list[key], *split_path)
......
# -*- coding: utf-8 -*-
from flask import Flask, request, redirect, url_for, \
render_template, g, flash, jsonify, session
render_template, g, flash, jsonify, session, abort, send_file
from utils import *
import os
import shutil
......@@ -9,10 +9,14 @@ import md5
from gittools import cloneRepo, gitStatus, switchBranch, addBranch, getDiff, \
gitPush, gitPull
from flaskext.auth import Auth, AuthUser, login_required, logout
from fileBrowser import fileBrowser
import urllib
app = Flask(__name__)
app.config['MAX_CONTENT_LENGTH'] = 20 * 1024 * 1024
auth = Auth(app, login_url_name='login')
auth.user_timeout = 0
file_request = fileBrowser(app.config)
# Setup default flask (werkzeug) parser
import logging
......@@ -95,19 +99,19 @@ def inspectSoftware():
result = ""
else:
result = app.config['software_root']
return render_template('runResult.html', softwareRoot='software_root',
softwares=loadSoftwareData(app.config['etc_dir']))
return render_template('runResult.html', softwareRoot='software_link/',
softwares=loadSoftwareRList(app.config))
#remove content of compiled software release
@login_required()
def removeSoftware():
file_config = os.path.join(app.config['etc_dir'], ".softdata")
if isSoftwareRunning(app.config) or isInstanceRunning(app.config):
flash('Software installation or instantiation in progress, cannot remove')
elif os.path.exists(file_config):
elif os.path.exists(app.config['software_root']):
svcStopAll(app.config)
shutil.rmtree(app.config['software_root'])
os.remove(file_config)
for link in os.listdir(app.config['software_link']):
os.remove(os.path.join(app.config['software_link'], link))
flash('Software removed')
return redirect(url_for('inspectSoftware'))
......@@ -147,7 +151,8 @@ def inspectInstance():
if len(result) == 0:
result = []
return render_template('instanceInspect.html',
file_path=file_content, supervisor=result, slap_status=getSlapStatus(app.config),
file_path=file_content, supervisor=result,
slap_status=getSlapStatus(app.config),
supervisore=result, partition_amount=app.config['partition_amount'])
#Reload instance process ans returns new value to ajax
......@@ -304,7 +309,8 @@ def removeFile():
@login_required()
def removeSoftwareDir():
try:
data = removeSoftwareByName(app.config, request.form['name'])
data = removeSoftwareByName(app.config, request.form['md5'],
request.form['title'])
return jsonify(code=1, result=data)
except Exception, e:
return jsonify(code=0, result=str(e))
......@@ -505,7 +511,8 @@ def configAccount():
account.append(request.form['email'].strip())
account.append(request.form['name'].strip())
code = request.form['rcode'].strip()
recovery_code = open(os.path.join(app.config['etc_dir'], ".rcode"), "r").read()
recovery_code = open(os.path.join(app.config['etc_dir'], ".rcode"),
"r").read()
if code != recovery_code:
return jsonify(code=0, result="Your password recovery code is not valid!")
result = saveSession(app.config, account)
......@@ -515,6 +522,78 @@ def configAccount():
return jsonify(code=1, result="")
return jsonify(code=0, result="Unable to respond to your request, permission denied.")
#Global File Manager
@login_required()
def fileBrowser():
if request.method == 'POST':
filename = request.form.get('filename', '').encode('utf-8')
dir = request.form['dir'].encode('utf-8')
newfilename = request.form.get('newfilename', '').encode('utf-8')
files = request.form.get('files', '').encode('utf-8')
if not request.form.has_key('opt') or not request.form['opt']:
opt = 1
else:
opt = int(request.form['opt'])
else:
opt = int(request.args.get('opt'))
try:
if opt == 1:
#list files and directories
result = file_request.listDirs(dir)
elif opt == 2:
#Create file
result = file_request.makeFile(dir, filename)
elif opt == 3:
#Create directory
result = file_request.makeDirectory(dir, filename)
elif opt == 4:
#Delete a list of files or/and directories
result = file_request.deleteItem(dir, files)
elif opt == 5:
#copy a lis of files or/and directories
result = file_request.copyItem(dir, files)
elif opt == 6:
#rename file or directory
result = file_request.rename(dir, filename, newfilename)
elif opt == 7:
result = file_request.copyItem(dir, files, del_source=True)
elif opt == 8:
#donwload file
filename = request.args.get('filename').encode('utf-8')
result = file_request.downloadFile(request.args.get('dir').encode('utf-8'),
filename)
try:
return send_file(result, attachment_filename=filename, as_attachment=True)
except:
abort(404)
elif opt == 9:
truncateTo = int(request.form.get('truncate', '0'))
result = file_request.readFile(dir, filename)
elif opt == 11:
#Upload file
result = file_request.uploadFile(dir, request.files)
elif opt == 14:
#Copy file or directory as ...
result = file_request.copyAsFile(dir, filename, newfilename)
elif opt == 16:
#zip file
result = file_request.zipFile(dir, filename, newfilename)
elif opt == 17:
#zip file
result = file_request.unzipFile(dir, filename, newfilename)
else:
result = "ARGS PARSE ERROR: Bad option..."
except Exception, e:
return str(e)
return result
@login_required()
def editFile():
return render_template('editFile.html', workDir='workspace',
profile=urllib.unquote(request.args.get('profile', '')),
projectList=getProjectList(app.config['workspace']),
filename=urllib.unquote(request.args.get('filename', '')))
#Setup List of URLs
app.add_url_rule('/', 'home', home)
app.add_url_rule('/editSoftwareProfile', 'editSoftwareProfile', editSoftwareProfile)
......@@ -561,3 +640,5 @@ app.add_url_rule("/saveParameterXml", 'saveParameterXml', saveParameterXml, meth
app.add_url_rule("/getPath", 'getPath', getPath, methods=['POST'])
app.add_url_rule("/myAccount", 'myAccount', myAccount)
app.add_url_rule("/updateAccount", 'updateAccount', updateAccount, methods=['POST'])
app.add_url_rule("/fileBrowser", 'fileBrowser', fileBrowser, methods=['GET', 'POST'])
app.add_url_rule("/editFile", 'editFile', editFile, methods=['GET'])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment