1
|
|
|
/* |
2
|
|
|
* CMS Pico - Integration of Pico within your files to create websites. |
3
|
|
|
* |
4
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
5
|
|
|
* later. See the COPYING file. |
6
|
|
|
* |
7
|
|
|
* @author Maxence Lange <[email protected]> |
8
|
|
|
* @copyright 2017 |
9
|
|
|
* @license GNU AGPL version 3 or any later version |
10
|
|
|
* |
11
|
|
|
* This program is free software: you can redistribute it and/or modify |
12
|
|
|
* it under the terms of the GNU Affero General Public License as |
13
|
|
|
* published by the Free Software Foundation, either version 3 of the |
14
|
|
|
* License, or (at your option) any later version. |
15
|
|
|
* |
16
|
|
|
* This program is distributed in the hope that it will be useful, |
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19
|
|
|
* GNU Affero General Public License for more details. |
20
|
|
|
* |
21
|
|
|
* You should have received a copy of the GNU Affero General Public License |
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
23
|
|
|
* |
24
|
|
|
*/ |
25
|
|
|
|
26
|
|
|
/** global: OC */ |
27
|
|
|
|
28
|
|
|
/** global: pico_elements */ |
29
|
|
|
/** global: pico_define */ |
30
|
|
|
|
31
|
|
|
var pico_nav = { |
32
|
|
|
|
33
|
|
|
updateNewWebsite: function (url) { |
34
|
|
|
pico_elements.cms_pico_new_url.text(pico_define.nchost + pico_define.sites + url); |
35
|
|
|
pico_nav.refreshNewFolder(); |
36
|
|
|
}, |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
pickFolderResult: function (folder) { |
40
|
|
|
pico_elements.cms_pico_new_folder_result = folder; |
41
|
|
|
pico_nav.refreshNewFolder(); |
42
|
|
|
}, |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
refreshNewFolder: function () { |
46
|
|
|
pico_elements.cms_pico_new_path.text(pico_elements.cms_pico_new_folder_result + '/' + |
47
|
|
|
pico_elements.cms_pico_new_website.val()); |
48
|
|
|
}, |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
createNewWebsite: function () { |
52
|
|
|
|
53
|
|
|
pico_nav.creatingWebsite(true); |
54
|
|
|
var data = { |
55
|
|
|
name: pico_elements.cms_pico_new_name.val(), |
56
|
|
|
website: pico_elements.cms_pico_new_website.val(), |
57
|
|
|
path: pico_elements.cms_pico_new_path.text() |
58
|
|
|
}; |
59
|
|
|
|
60
|
|
|
$.ajax({ |
61
|
|
|
method: 'PUT', |
62
|
|
|
url: OC.generateUrl('/apps/cms_pico/personal/website'), |
63
|
|
|
data: { |
64
|
|
|
data: data |
65
|
|
|
} |
66
|
|
|
}).done(function (result) { |
67
|
|
|
pico_nav.creatingWebsite(false); |
68
|
|
|
pico_result.createNewWebsiteResult(result); |
|
|
|
|
69
|
|
|
}); |
70
|
|
|
|
71
|
|
|
}, |
72
|
|
|
|
73
|
|
|
|
74
|
|
|
creatingWebsite: function (creating) { |
75
|
|
|
|
76
|
|
|
pico_elements.cms_pico_new_submit.prop('disabled', creating); |
77
|
|
|
if (creating) { |
78
|
|
|
pico_elements.cms_pico_new_submit.val(t('cms_pico', 'Creating your website')); |
79
|
|
|
} else { |
80
|
|
|
pico_elements.cms_pico_new_submit.val(t('cms_pico', 'Create a new website')); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
}, |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
updateWebsiteOption: function (site_id, key, value) { |
87
|
|
|
$.ajax({ |
88
|
|
|
method: 'POST', |
89
|
|
|
url: OC.generateUrl('/apps/cms_pico/personal/website/' + site_id + '/option/' + key), |
90
|
|
|
data: { |
91
|
|
|
value: value |
92
|
|
|
} |
93
|
|
|
}).done(function (res) { |
94
|
|
|
pico_result.displayWebsites(res.websites); |
|
|
|
|
95
|
|
|
}); |
96
|
|
|
}, |
97
|
|
|
|
98
|
|
|
|
99
|
|
|
resetFields: function () { |
100
|
|
|
pico_elements.cms_pico_new_website.val(''); |
101
|
|
|
pico_elements.cms_pico_new_name.val(''); |
102
|
|
|
pico_elements.cms_pico_new_path.text('/'); |
103
|
|
|
pico_elements.cms_pico_new_url.text(''); |
104
|
|
|
}, |
105
|
|
|
|
106
|
|
|
|
107
|
|
|
generateTmplWebsite: function (entry) { |
108
|
|
|
var tmpl = $('#tmpl_website').html(); |
109
|
|
|
|
110
|
|
|
tmpl = tmpl.replace(/%%id%%/g, entry.id); |
111
|
|
|
tmpl = tmpl.replace(/%%name%%/g, escapeHTML(entry.name)); |
112
|
|
|
tmpl = tmpl.replace(/%%address%%/g, pico_define.nchost + pico_define.sites + |
113
|
|
|
escapeHTML(entry.site)); |
114
|
|
|
tmpl = tmpl.replace(/%%path%%/g, escapeHTML(entry.path)); |
115
|
|
|
|
116
|
|
|
if (entry.options.private === '1') { |
117
|
|
|
tmpl = tmpl.replace(/%%private%%/g, escapeHTML(entry.options.private)); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
return tmpl; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
|
124
|
|
|
}; |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.