Edit File by line
/home/barbar84/www/extracte.../pafm/pafm-fil...
File: js.js
/*
[0] Fix | Delete
@filename: js.js
[1] Fix | Delete
[2] Fix | Delete
Copyright (C) 2007-2013 mustafa
[3] Fix | Delete
This program is free software; you can redistribute it and/or modify it under the terms of the
[4] Fix | Delete
GNU General Public License as published by the Free Software Foundation.
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
function $(element) {
[8] Fix | Delete
return document.getElementById(element);
[9] Fix | Delete
}
[10] Fix | Delete
var popup, fOp, edit, upload, shell, __AJAX_ACTIVE,
[11] Fix | Delete
__CODEMIRROR, __CODEMIRROR_MODE, __CODEMIRROR_LOADED, __CODEMIRROR_PATH = "_cm",
[12] Fix | Delete
__CODEMIRROR_MODES = {
[13] Fix | Delete
"html": "htmlmixed",
[14] Fix | Delete
"js": "javascript",
[15] Fix | Delete
"py": "python",
[16] Fix | Delete
"rb": "ruby",
[17] Fix | Delete
"md": "markdown"
[18] Fix | Delete
//TODO: complete list
[19] Fix | Delete
};
[20] Fix | Delete
[21] Fix | Delete
function ajax(url, method, data, handler, upload, uploadProgressHandler) {
[22] Fix | Delete
__AJAX_ACTIVE = true;
[23] Fix | Delete
if (!upload) {
[24] Fix | Delete
json2markup([
[25] Fix | Delete
"div",
[26] Fix | Delete
{
[27] Fix | Delete
attributes : {
[28] Fix | Delete
"id" : "ajaxOverlay"
[29] Fix | Delete
}
[30] Fix | Delete
},
[31] Fix | Delete
"img",
[32] Fix | Delete
{
[33] Fix | Delete
attributes : {
[34] Fix | Delete
"src" : "pafm-files/images/ajax.gif",
[35] Fix | Delete
"id" : "ajaxImg",
[36] Fix | Delete
"title" : "Loading",
[37] Fix | Delete
"alt" : "Loading"
[38] Fix | Delete
}
[39] Fix | Delete
}], document.body);
[40] Fix | Delete
$("ajaxOverlay").style.height = document.body.offsetHeight + "px";
[41] Fix | Delete
fade($("ajaxOverlay"), 0, 6, 25, "in");
[42] Fix | Delete
}
[43] Fix | Delete
var xhr = window.ActiveXObject ? new ActiveXObject("MSXML2.XMLHTTP.3.0") : new XMLHttpRequest();
[44] Fix | Delete
uploadProgressHandler && xhr.upload.addEventListener("progress", uploadProgressHandler, false);
[45] Fix | Delete
xhr.open(method, url, true);
[46] Fix | Delete
xhr.onreadystatechange = function(){
[47] Fix | Delete
if (xhr.readyState != 4)
[48] Fix | Delete
return;
[49] Fix | Delete
__AJAX_ACTIVE = false;
[50] Fix | Delete
upload || fade($("ajaxOverlay"), 6, 0, 25, "out", function(){
[51] Fix | Delete
document.body.removeChild($("ajaxOverlay"));
[52] Fix | Delete
document.body.removeChild($("ajaxImg"));
[53] Fix | Delete
});
[54] Fix | Delete
if (xhr.status == 200 || xhr.statusText == "OK") {
[55] Fix | Delete
if (xhr.responseText == "Please refresh the page and login")
[56] Fix | Delete
alert(xhr.responseText);
[57] Fix | Delete
else
[58] Fix | Delete
handler(xhr.responseText);
[59] Fix | Delete
}
[60] Fix | Delete
else
[61] Fix | Delete
alert("AJAX request unsuccessful."
[62] Fix | Delete
+ "\nStatus Code: " + xhr.status
[63] Fix | Delete
+ "\nStatus Text: " + xhr.statusText
[64] Fix | Delete
+ "\nParameters: " + url);
[65] Fix | Delete
xhr = null;
[66] Fix | Delete
};
[67] Fix | Delete
if (method.toLowerCase() == "post" && !upload)
[68] Fix | Delete
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
[69] Fix | Delete
xhr.send(data);
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
/*
[73] Fix | Delete
* Structure:
[74] Fix | Delete
*
[75] Fix | Delete
* [
[76] Fix | Delete
* "element",
[77] Fix | Delete
* {
[78] Fix | Delete
* attributes:{},
[79] Fix | Delete
* events:{},
[80] Fix | Delete
* style: {},
[81] Fix | Delete
* text: ""
[82] Fix | Delete
* }
[83] Fix | Delete
* [
[84] Fix | Delete
* "childElement",
[85] Fix | Delete
* {
[86] Fix | Delete
* ...
[87] Fix | Delete
* }
[88] Fix | Delete
* [
[89] Fix | Delete
* ...
[90] Fix | Delete
* ]
[91] Fix | Delete
* ],
[92] Fix | Delete
* "..."
[93] Fix | Delete
* ]
[94] Fix | Delete
*
[95] Fix | Delete
*/
[96] Fix | Delete
function json2markup(json, path) {
[97] Fix | Delete
var i = 0, l = json.length, el, attrib, event;
[98] Fix | Delete
for ( ; i < l; i++) {
[99] Fix | Delete
if (json[i].constructor == Array)
[100] Fix | Delete
json2markup(json[i], el);
[101] Fix | Delete
else if (json[i].constructor == Object){
[102] Fix | Delete
if (json[i].attributes)
[103] Fix | Delete
for (attrib in json[i].attributes)
[104] Fix | Delete
switch (attrib.toLowerCase()){
[105] Fix | Delete
case "class":
[106] Fix | Delete
el.className = json[i].attributes[attrib];
[107] Fix | Delete
break;
[108] Fix | Delete
case "style":
[109] Fix | Delete
el.style.cssText = json[i].attributes[attrib];
[110] Fix | Delete
break;
[111] Fix | Delete
case "for":
[112] Fix | Delete
el.htmlFor = json[i].attributes[attrib];
[113] Fix | Delete
break;
[114] Fix | Delete
default:
[115] Fix | Delete
el.setAttribute(attrib, json[i].attributes[attrib]);
[116] Fix | Delete
}
[117] Fix | Delete
if (json[i].events)
[118] Fix | Delete
for (event in json[i].events)
[119] Fix | Delete
el.addEventListener(event, json[i].events[event], false);
[120] Fix | Delete
if (json[i].preText)
[121] Fix | Delete
path.appendChild(document.createTextNode(json[i].preText));
[122] Fix | Delete
if (json[i].text)
[123] Fix | Delete
el.appendChild(document.createTextNode(json[i].text));
[124] Fix | Delete
switch (json[i].insert){
[125] Fix | Delete
case "before":
[126] Fix | Delete
path.parentNode.insertBefore(el, path);
[127] Fix | Delete
break;
[128] Fix | Delete
case "after":
[129] Fix | Delete
path.parentNode.insertBefore(el, path.nextSibling);
[130] Fix | Delete
break;
[131] Fix | Delete
case "under":
[132] Fix | Delete
default:
[133] Fix | Delete
path.appendChild(el);
[134] Fix | Delete
}
[135] Fix | Delete
if (json[i].postText)
[136] Fix | Delete
path.appendChild(document.createTextNode(json[i].postText));
[137] Fix | Delete
}
[138] Fix | Delete
else
[139] Fix | Delete
el = document.createElement(json[i]);
[140] Fix | Delete
}
[141] Fix | Delete
}
[142] Fix | Delete
function fade(element, fadeFrom, fadeTo, speed, type, callback) {
[143] Fix | Delete
var which = element.style.opacity != undefined, condition, interval;
[144] Fix | Delete
element.style[which ? "opacity" : "filter"] = which ? fadeFrom / 10 : "alpha(opacity="+ fadeFrom * 10 +")";
[145] Fix | Delete
interval = setInterval(function(){
[146] Fix | Delete
if (type == "in") {
[147] Fix | Delete
fadeFrom++;
[148] Fix | Delete
condition = fadeFrom <= fadeTo;
[149] Fix | Delete
}
[150] Fix | Delete
else if (type == "out"){
[151] Fix | Delete
fadeFrom--;
[152] Fix | Delete
condition = fadeFrom >= fadeTo;
[153] Fix | Delete
}
[154] Fix | Delete
if (condition)
[155] Fix | Delete
element.style[which ? "opacity" : "filter"] = which ? fadeFrom / 10 : "alpha(opacity="+ fadeFrom * 10 +")";
[156] Fix | Delete
else {
[157] Fix | Delete
clearInterval(interval);
[158] Fix | Delete
if (callback)
[159] Fix | Delete
callback();
[160] Fix | Delete
}
[161] Fix | Delete
}, speed);
[162] Fix | Delete
}
[163] Fix | Delete
popup = {
[164] Fix | Delete
init : function(title, content) {
[165] Fix | Delete
json2markup([
[166] Fix | Delete
"div",
[167] Fix | Delete
{
[168] Fix | Delete
attributes : {
[169] Fix | Delete
"id" : "popOverlay"
[170] Fix | Delete
},
[171] Fix | Delete
events : {
[172] Fix | Delete
"click" : popup.close
[173] Fix | Delete
}
[174] Fix | Delete
}], document.body);
[175] Fix | Delete
json2markup([
[176] Fix | Delete
"div",
[177] Fix | Delete
{
[178] Fix | Delete
attributes : {
[179] Fix | Delete
"id" : "popup"
[180] Fix | Delete
}
[181] Fix | Delete
},
[182] Fix | Delete
[
[183] Fix | Delete
"div",
[184] Fix | Delete
{
[185] Fix | Delete
attributes : {
[186] Fix | Delete
"id" : "head"
[187] Fix | Delete
}
[188] Fix | Delete
},
[189] Fix | Delete
[
[190] Fix | Delete
"a",
[191] Fix | Delete
{
[192] Fix | Delete
attributes : {
[193] Fix | Delete
"id" : "x",
[194] Fix | Delete
"href" : "#"
[195] Fix | Delete
},
[196] Fix | Delete
events : {
[197] Fix | Delete
click : function(e){
[198] Fix | Delete
popup.close();
[199] Fix | Delete
e.preventDefault ? e.preventDefault() : e.returnValue = false;
[200] Fix | Delete
}
[201] Fix | Delete
},
[202] Fix | Delete
text : "[x]"
[203] Fix | Delete
},
[204] Fix | Delete
"span",
[205] Fix | Delete
{
[206] Fix | Delete
text : title
[207] Fix | Delete
}
[208] Fix | Delete
],
[209] Fix | Delete
"div",
[210] Fix | Delete
{
[211] Fix | Delete
attributes : {
[212] Fix | Delete
"id" : "body"
[213] Fix | Delete
}
[214] Fix | Delete
}
[215] Fix | Delete
]
[216] Fix | Delete
], document.body);
[217] Fix | Delete
var popupEl = $("popup"), popOverlayEl = $("popOverlay"), mlEl;
[218] Fix | Delete
json2markup(content, $("body"));
[219] Fix | Delete
if (mlEl = $('moveListUL')) {
[220] Fix | Delete
if (mlEl.offsetHeight > (document.body.offsetHeight - 150))
[221] Fix | Delete
mlEl.style.height = document.body.offsetHeight - 150 + "px";
[222] Fix | Delete
}
[223] Fix | Delete
popupEl.style.marginTop = "-" + parseInt(popupEl.offsetHeight) / 2 + "px";
[224] Fix | Delete
popupEl.style.marginLeft = "-" + parseInt(popupEl.offsetWidth) / 2 + "px";
[225] Fix | Delete
fade(popOverlayEl, 0, 6, 25, "in");
[226] Fix | Delete
document.onkeydown = function(e) {
[227] Fix | Delete
if ((e || window.event).keyCode == 27) {
[228] Fix | Delete
popup.close();
[229] Fix | Delete
return false;
[230] Fix | Delete
}
[231] Fix | Delete
};
[232] Fix | Delete
},
[233] Fix | Delete
close : function() {
[234] Fix | Delete
if (__AJAX_ACTIVE)
[235] Fix | Delete
return;
[236] Fix | Delete
if ($("popup")){
[237] Fix | Delete
var popOverlayEl = $("popOverlay");
[238] Fix | Delete
fade(popOverlayEl, 6, 0, 25, "out", function(){
[239] Fix | Delete
document.body.removeChild(popOverlayEl);
[240] Fix | Delete
});
[241] Fix | Delete
document.body.removeChild($("popup"));
[242] Fix | Delete
}
[243] Fix | Delete
document.onkeydown = null;
[244] Fix | Delete
}
[245] Fix | Delete
};
[246] Fix | Delete
fOp = {
[247] Fix | Delete
rename : function(subject, path) {
[248] Fix | Delete
popup.init("Rename:", [
[249] Fix | Delete
"form",
[250] Fix | Delete
{
[251] Fix | Delete
attributes : {
[252] Fix | Delete
"action" : "?do=rename&subject=" + subject + "&path=" + path + "&nonce=" + nonce,
[253] Fix | Delete
"method" : "post"
[254] Fix | Delete
}
[255] Fix | Delete
},
[256] Fix | Delete
[
[257] Fix | Delete
"input",
[258] Fix | Delete
{
[259] Fix | Delete
attributes : {
[260] Fix | Delete
"title" : "Rename To",
[261] Fix | Delete
"type" : "text",
[262] Fix | Delete
"name" : "rename",
[263] Fix | Delete
"value" : subject
[264] Fix | Delete
}
[265] Fix | Delete
},
[266] Fix | Delete
"input",
[267] Fix | Delete
{
[268] Fix | Delete
attributes : {
[269] Fix | Delete
"title" : "Ok",
[270] Fix | Delete
"type" : "submit",
[271] Fix | Delete
"value" : "\u2713"
[272] Fix | Delete
}
[273] Fix | Delete
}
[274] Fix | Delete
]
[275] Fix | Delete
]);
[276] Fix | Delete
},
[277] Fix | Delete
create : function(type, path) {
[278] Fix | Delete
popup.init("Create " + type + ":", [
[279] Fix | Delete
"form",
[280] Fix | Delete
{
[281] Fix | Delete
attributes : {
[282] Fix | Delete
"method" : "post",
[283] Fix | Delete
"action" : "?do=create&path=" + path + "&f_type=" + type + "&nonce=" + nonce
[284] Fix | Delete
}
[285] Fix | Delete
},
[286] Fix | Delete
[
[287] Fix | Delete
"input",
[288] Fix | Delete
{
[289] Fix | Delete
attributes : {
[290] Fix | Delete
"title" : "Filename",
[291] Fix | Delete
"type" : "text",
[292] Fix | Delete
"name" : "f_name"
[293] Fix | Delete
}
[294] Fix | Delete
},
[295] Fix | Delete
"input",
[296] Fix | Delete
{
[297] Fix | Delete
attributes : {
[298] Fix | Delete
"title" : "Ok",
[299] Fix | Delete
"type" : "submit",
[300] Fix | Delete
"value" : "\u2713"
[301] Fix | Delete
}
[302] Fix | Delete
}
[303] Fix | Delete
]
[304] Fix | Delete
]);
[305] Fix | Delete
},
[306] Fix | Delete
chmod : function(path, subject, chmod){
[307] Fix | Delete
popup.init("Chmod " + unescape(subject) + ":", [
[308] Fix | Delete
"form",
[309] Fix | Delete
{
[310] Fix | Delete
attributes : {
[311] Fix | Delete
"method" : "post",
[312] Fix | Delete
"action" : "?do=chmod&subject=" + subject + "&path=" + path + "&nonce=" + nonce
[313] Fix | Delete
}
[314] Fix | Delete
},
[315] Fix | Delete
[
[316] Fix | Delete
"input",
[317] Fix | Delete
{
[318] Fix | Delete
attributes : {
[319] Fix | Delete
"title" : "chmod",
[320] Fix | Delete
"type" : "text",
[321] Fix | Delete
"name" : "mod",
[322] Fix | Delete
"value" : chmod
[323] Fix | Delete
}
[324] Fix | Delete
},
[325] Fix | Delete
"input",
[326] Fix | Delete
{
[327] Fix | Delete
attributes : {
[328] Fix | Delete
"title" : "Ok",
[329] Fix | Delete
"type" : "submit",
[330] Fix | Delete
"value" : "\u2713"
[331] Fix | Delete
}
[332] Fix | Delete
}
[333] Fix | Delete
]
[334] Fix | Delete
]);
[335] Fix | Delete
},
[336] Fix | Delete
copy : function(subject, path){
[337] Fix | Delete
popup.init("Copy " + unescape(subject) + ":", [
[338] Fix | Delete
"form",
[339] Fix | Delete
{
[340] Fix | Delete
attributes : {
[341] Fix | Delete
"method" : "post",
[342] Fix | Delete
"action" : "?do=copy&subject=" + subject + "&path=" + path + "&nonce=" + nonce
[343] Fix | Delete
}
[344] Fix | Delete
},
[345] Fix | Delete
[
[346] Fix | Delete
"input",
[347] Fix | Delete
{
[348] Fix | Delete
attributes : {
[349] Fix | Delete
"title" : "copy to",
[350] Fix | Delete
"type" : "text",
[351] Fix | Delete
"name" : "to",
[352] Fix | Delete
"value" : "copy-" + subject
[353] Fix | Delete
}
[354] Fix | Delete
},
[355] Fix | Delete
"input",
[356] Fix | Delete
{
[357] Fix | Delete
attributes : {
[358] Fix | Delete
"title" : "Ok",
[359] Fix | Delete
"type" : "submit",
[360] Fix | Delete
"value" : "\u2713"
[361] Fix | Delete
}
[362] Fix | Delete
}
[363] Fix | Delete
]
[364] Fix | Delete
]);
[365] Fix | Delete
},
[366] Fix | Delete
moveList : function(subject, path, to){
[367] Fix | Delete
ajax(("?do=moveList&subject=" + subject + "&path=" + path + "&to=" + to), "get", null, function (response) {
[368] Fix | Delete
if (!$("popup"))
[369] Fix | Delete
popup.init("Move " + unescape(subject) + " to:", Function("return " + response)());
[370] Fix | Delete
else {
[371] Fix | Delete
var popupEl = $("popup"), mlEl;
[372] Fix | Delete
$("body").innerHTML = "";
[373] Fix | Delete
json2markup(Function("return " + response)(), $("body"));
[374] Fix | Delete
if ((mlEl = $('moveListUL')).offsetHeight > (document.body.offsetHeight - 150))
[375] Fix | Delete
mlEl.style.height = document.body.offsetHeight - 150 + "px";
[376] Fix | Delete
popupEl.style.marginTop = "-" + parseInt(popupEl.offsetHeight) / 2 + "px";
[377] Fix | Delete
popupEl.style.marginLeft = "-" + parseInt(popupEl.offsetWidth) / 2 + "px";
[378] Fix | Delete
}
[379] Fix | Delete
});
[380] Fix | Delete
},
[381] Fix | Delete
remoteCopy : function(path){
[382] Fix | Delete
popup.init("Remote Copy:", [
[383] Fix | Delete
"form",
[384] Fix | Delete
{
[385] Fix | Delete
attributes : {
[386] Fix | Delete
"method" : "post",
[387] Fix | Delete
"action" : "?do=remoteCopy&path=" + path + "&nonce=" + nonce,
[388] Fix | Delete
"id": "remote-copy"
[389] Fix | Delete
}
[390] Fix | Delete
},
[391] Fix | Delete
[
[392] Fix | Delete
"legend",
[393] Fix | Delete
{text: "Location: "},
[394] Fix | Delete
[
[395] Fix | Delete
"br", {},
[396] Fix | Delete
"input",
[397] Fix | Delete
{
[398] Fix | Delete
attributes: {
[399] Fix | Delete
"title": "Remote Copy",
[400] Fix | Delete
"type": "text",
[401] Fix | Delete
"name": "location"
[402] Fix | Delete
},
[403] Fix | Delete
events: {
[404] Fix | Delete
change: function(e){
[405] Fix | Delete
$('remoteCopyName').value = this.value.substring(this.value.lastIndexOf('/') + 1);
[406] Fix | Delete
}
[407] Fix | Delete
}
[408] Fix | Delete
}
[409] Fix | Delete
],
[410] Fix | Delete
"legend",
[411] Fix | Delete
{text: "Name: "},
[412] Fix | Delete
[
[413] Fix | Delete
"br", {},
[414] Fix | Delete
"input",
[415] Fix | Delete
{
[416] Fix | Delete
attributes: {
[417] Fix | Delete
"id": "remoteCopyName",
[418] Fix | Delete
"title": "Name",
[419] Fix | Delete
"type": "text",
[420] Fix | Delete
"name": "to"
[421] Fix | Delete
}
[422] Fix | Delete
}
[423] Fix | Delete
],
[424] Fix | Delete
"input",
[425] Fix | Delete
{
[426] Fix | Delete
attributes: {
[427] Fix | Delete
"title": "Ok",
[428] Fix | Delete
"type": "submit",
[429] Fix | Delete
"value": "\u2713"
[430] Fix | Delete
}
[431] Fix | Delete
}
[432] Fix | Delete
]
[433] Fix | Delete
]);
[434] Fix | Delete
}
[435] Fix | Delete
};
[436] Fix | Delete
edit = {
[437] Fix | Delete
init : function(subject, path, mode, codeMirrorInstalled) {
[438] Fix | Delete
__CODEMIRROR_MODE = mode;
[439] Fix | Delete
json2markup([
[440] Fix | Delete
"div",
[441] Fix | Delete
{
[442] Fix | Delete
attributes: {"id": "editOverlay"}
[443] Fix | Delete
}
[444] Fix | Delete
], document.body)
[445] Fix | Delete
$("editOverlay").style.height = "100%";
[446] Fix | Delete
json2markup([
[447] Fix | Delete
"div",
[448] Fix | Delete
{
[449] Fix | Delete
attributes : {"id": "ea"}
[450] Fix | Delete
},
[451] Fix | Delete
[
[452] Fix | Delete
"textarea",
[453] Fix | Delete
{
[454] Fix | Delete
attributes: {
[455] Fix | Delete
"id": "ta",
[456] Fix | Delete
"rows": "30",
[457] Fix | Delete
"cols": "90"
[458] Fix | Delete
},
[459] Fix | Delete
events: {
[460] Fix | Delete
change: function(){
[461] Fix | Delete
window.__FILECHANGED = true;
[462] Fix | Delete
}
[463] Fix | Delete
}
[464] Fix | Delete
},
[465] Fix | Delete
"br",
[466] Fix | Delete
{},
[467] Fix | Delete
"input",
[468] Fix | Delete
{
[469] Fix | Delete
attributes: {
[470] Fix | Delete
"type": "text",
[471] Fix | Delete
"value": unescape(subject),
[472] Fix | Delete
"readonly": ""
[473] Fix | Delete
}
[474] Fix | Delete
},
[475] Fix | Delete
"input",
[476] Fix | Delete
{
[477] Fix | Delete
attributes : {
[478] Fix | Delete
"type" : "button",
[479] Fix | Delete
"value" : "CodeMirror"
[480] Fix | Delete
},
[481] Fix | Delete
events : {
[482] Fix | Delete
click : function(){
[483] Fix | Delete
if (codeMirrorInstalled)
[484] Fix | Delete
edit.codeMirrorLoad();
[485] Fix | Delete
else if (confirm("Install CodeMirror?"))
[486] Fix | Delete
ajax("?do=installCodeMirror", "get", null, function(response){
[487] Fix | Delete
if (response == "")
[488] Fix | Delete
edit.codeMirrorLoad();
[489] Fix | Delete
else
[490] Fix | Delete
alert("Install failed. Manually upload CodeMirror"
[491] Fix | Delete
+ "and place it in _codemirror, in the same directory as pafm");
[492] Fix | Delete
});
[493] Fix | Delete
this.disabled = true;
[494] Fix | Delete
}
[495] Fix | Delete
}
[496] Fix | Delete
},
[497] Fix | Delete
"input",
[498] Fix | Delete
{
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function