Passed
Push — master ( 5322e3...8b6067 )
by Maxence
01:51
created

js/personal.navigation.js   A

Complexity

Total Complexity 9
Complexity/F 1.13

Size

Lines of Code 71
Function Count 8

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
c 1
b 0
f 0
dl 0
loc 71
rs 10
cc 0
nc 1
mnd 1
bc 9
fnc 8
bpm 1.125
cpm 1.125
noi 6

6 Functions

Rating   Name   Duplication   Size   Complexity  
A pico_nav.pickFolderResult 0 4 1
A pico_nav.generateTmplWebsite 0 14 2
A pico_nav.createNewWebsite 0 19 1
A pico_nav.updateWebsiteOption 0 11 1
A pico_nav.refreshNewFolder 0 4 1
A pico_nav.updateNewWebsite 0 4 1
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
29
var pico_nav = {
30
31
	updateNewWebsite: function (url) {
32
		pico_elements.cms_pico_new_url.text(define.nchost + define.sites + url);
0 ignored issues
show
Bug introduced by
The variable define seems to be never declared. If this is a global, consider adding a /** global: define */ comment.

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.

Loading history...
33
		pico_nav.refreshNewFolder();
34
	},
35
36
37
	pickFolderResult: function (folder) {
38
		pico_elements.cms_pico_new_folder_result = folder;
39
		pico_nav.refreshNewFolder();
40
	},
41
42
43
	refreshNewFolder: function () {
44
		pico_elements.cms_pico_new_path.text(pico_elements.cms_pico_new_folder_result + '/' +
45
			pico_elements.cms_pico_new_website.val());
46
	},
47
48
49
	createNewWebsite: function () {
50
51
		var data = {
52
			name: pico_elements.cms_pico_new_name.val(),
53
			website: pico_elements.cms_pico_new_website.val(),
54
			path: pico_elements.cms_pico_new_path.text()
55
		};
56
57
		$.ajax({
58
			method: 'PUT',
59
			url: OC.generateUrl('/apps/cms_pico/personal/website'),
0 ignored issues
show
Bug introduced by
The variable OC seems to be never declared. If this is a global, consider adding a /** global: OC */ comment.

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.

Loading history...
60
			data: {
61
				data: data
62
			}
63
		}).done(function (result) {
64
			pico_result.createNewWebsiteResult(result);
0 ignored issues
show
Bug introduced by
The variable pico_result seems to be never declared. If this is a global, consider adding a /** global: pico_result */ comment.

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.

Loading history...
65
		});
66
67
	},
68
69
70
	updateWebsiteOption: function (site_id, key, value) {
71
		$.ajax({
72
			method: 'POST',
73
			url: OC.generateUrl('/apps/cms_pico/personal/website/' + site_id + '/option/' + key),
0 ignored issues
show
Bug introduced by
The variable OC seems to be never declared. If this is a global, consider adding a /** global: OC */ comment.

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.

Loading history...
74
			data: {
75
				value: value
76
			}
77
		}).done(function (res) {
78
			pico_result.displayWebsites(res.websites);
0 ignored issues
show
Bug introduced by
The variable pico_result seems to be never declared. If this is a global, consider adding a /** global: pico_result */ comment.

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.

Loading history...
79
		});
80
	},
81
82
83
	generateTmplWebsite: function (entry) {
84
		var tmpl = $('#tmpl_website').html();
85
86
		tmpl = tmpl.replace(/%%id%%/g, entry.id);
87
		tmpl = tmpl.replace(/%%name%%/g, escapeHTML(entry.name));
88
		tmpl = tmpl.replace(/%%address%%/g, define.nchost + define.sites + escapeHTML(entry.site));
0 ignored issues
show
Bug introduced by
The variable define seems to be never declared. If this is a global, consider adding a /** global: define */ comment.

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.

Loading history...
89
		tmpl = tmpl.replace(/%%path%%/g, escapeHTML(entry.path));
90
91
		if (entry.options.private === '1') {
92
			tmpl = tmpl.replace(/%%private%%/g, escapeHTML(entry.options.private));
93
		}
94
95
		return tmpl;
96
	}
97
98
99
};