-
Notifications
You must be signed in to change notification settings - Fork 4
/
init.js
82 lines (72 loc) · 2.49 KB
/
init.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* Copyright (c) Codiad & Rafasashi, distributed
* as-is and without warranty under the MIT License.
* See http://opensource.org/licenses/MIT for more information.
* This information must remain intact.
*/
(function(global, $){
var codiad = global.codiad,
scripts = document.getElementsByTagName('script'),
path = scripts[scripts.length-1].src.split('?')[0],
curpath = path.split('/').slice(0, -1).join('/')+'/';
$(function() {
codiad.Extract.init();
});
codiad.Extract = {
path: curpath,
file: "",
init: function() {
},
//////////////////////////////////////////////////////////
//
// Show dialog to enter new epath
//
// Parameter
//
// path - {String} - File path
//
//////////////////////////////////////////////////////////
showDialog: function(path) {
this.file = path;
var epath = this.getName(path);
codiad.modal.load(400, this.path+"dialog.php?path="+path+"&epath="+epath);
},
//////////////////////////////////////////////////////////
//
// Extract file
//
// Parameter
//
// path - {String} - File path
// epath - {String} - Archive path
//
//////////////////////////////////////////////////////////
extract: function(path, epath) {
var _this = this;
if (typeof(path) == 'undefined') {
path = this.file;
}
if (typeof(epath) == 'undefined') {
epath = $('#extract_path').val();
codiad.modal.unload();
}
// console.log(_this.path+"controller.php?action=extract&path="+path+"&epath="+epath);
$.getJSON(_this.path+"controller.php?action=extract&path="+path+"&epath="+epath, function(json){
codiad.message[json.status](json.message);
codiad.filemanager.rescan(codiad.project.getCurrent());
});
},
//////////////////////////////////////////////////////////
//
// Get basename of file
//
// Parameter
//
// path - {String} - File path
//
//////////////////////////////////////////////////////////
getName: function(path) {
return path.substring(path.lastIndexOf("/")+1);
}
};
})(this, jQuery);