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
|
|
|
|
27
|
|
|
/** global: pico_elements */ |
28
|
|
|
/** global: pico_nav */ |
29
|
|
|
|
30
|
|
|
var pico_result = { |
31
|
|
|
|
32
|
|
|
displayWebsites: function (list) { |
33
|
|
|
|
34
|
|
|
pico_elements.cms_pico_list_websites.emptyTable(); |
35
|
|
|
|
36
|
|
|
for (var i = 0; i < list.length; i++) { |
37
|
|
|
var tmpl = pico_nav.generateTmplWebsite(list[i]); |
38
|
|
|
pico_elements.cms_pico_list_websites.append(tmpl); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
pico_result.displayWebsitesLink(); |
42
|
|
|
pico_result.displayWebsitesPath(); |
43
|
|
|
pico_result.displayWebsitesPrivate(); |
44
|
|
|
}, |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
displayWebsitesLink: function () { |
48
|
|
|
pico_elements.cms_pico_list_websites.find('TD.link').each(function () { |
49
|
|
|
var url = $(this).parent().attr('data-address'); |
50
|
|
|
$(this).css('cursor', 'pointer').on('click', function () { |
51
|
|
|
window.open(url); |
52
|
|
|
}); |
53
|
|
|
}); |
54
|
|
|
}, |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
displayWebsitesPath: function () { |
58
|
|
|
pico_elements.cms_pico_list_websites.find('TD.path').each(function () { |
59
|
|
|
var url = define.nchost + define.index + OC.appswebroots.files + '/?dir=' + |
|
|
|
|
60
|
|
|
$(this).parent().attr('data-path'); |
61
|
|
|
$(this).css('cursor', 'pointer').on('click', function () { |
62
|
|
|
window.open(url); |
63
|
|
|
}); |
64
|
|
|
}); |
65
|
|
|
}, |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
displayWebsitesPrivate: function () { |
69
|
|
|
pico_elements.cms_pico_list_websites.find('INPUT.private').each(function () { |
70
|
|
|
$(this).prop('checked', ($(this).parent().parent().attr('data-private') === '1')); |
71
|
|
|
$(this).on( |
72
|
|
|
'change', function () { |
73
|
|
|
pico_nav.updateWebsiteOption($(this).parent().parent().attr('data-id'), 'private', |
74
|
|
|
($(this).is(':checked')) ? '1' : '0'); |
75
|
|
|
}); |
76
|
|
|
}); |
77
|
|
|
}, |
78
|
|
|
|
79
|
|
|
|
80
|
|
|
createNewWebsiteResult: function (result) { |
81
|
|
|
|
82
|
|
|
if (result.status === 1) { |
83
|
|
|
OCA.notification.onSuccess('Website created'); |
|
|
|
|
84
|
|
|
pico_result.displayWebsites(result.websites); |
85
|
|
|
return; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
OCA.notification.onFail( |
89
|
|
|
t('cms_pico', "It was not possible to create your website {name}", |
90
|
|
|
{name: result.name}) + |
91
|
|
|
': ' + ((result.error) ? result.error : t('circles', 'no error message'))); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
}; |
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.