|
|
|
1 |
/* |
2 |
* Copyright 2015 Univention GmbH |
3 |
* |
4 |
* http://www.univention.de/ |
5 |
* |
6 |
* All rights reserved. |
7 |
* |
8 |
* The source code of this program is made available |
9 |
* under the terms of the GNU Affero General Public License version 3 |
10 |
* (GNU AGPL V3) as published by the Free Software Foundation. |
11 |
* |
12 |
* Binary versions of this program provided by Univention to you as |
13 |
* well as other copyrighted, protected or trademarked materials like |
14 |
* Logos, graphics, fonts, specific documentations and configurations, |
15 |
* cryptographic keys etc. are subject to a license agreement between |
16 |
* you and Univention and not subject to the GNU AGPL V3. |
17 |
* |
18 |
* In the case you use this program under the terms of the GNU AGPL V3, |
19 |
* the program is provided in the hope that it will be useful, |
20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 |
* GNU Affero General Public License for more details. |
23 |
* |
24 |
* You should have received a copy of the GNU Affero General Public |
25 |
* License with the Debian GNU/Linux or Univention distribution in file |
26 |
* /usr/share/common-licenses/AGPL-3; if not, see |
27 |
* <http://www.gnu.org/licenses/>. |
28 |
*/ |
29 |
/*global define require console window */ |
30 |
|
31 |
define([ |
32 |
"dojo/_base/lang", |
33 |
"dojo/_base/kernel", |
34 |
"dojo/_base/array", |
35 |
"dojo/io-query", |
36 |
"dojo/query", |
37 |
"dojo/dom", |
38 |
"dojo/dom-construct", |
39 |
"dojo/dom-attr", |
40 |
"dojo/dom-style", |
41 |
"dojo/dom-class", |
42 |
"dojo/dom-geometry", |
43 |
"../ucs/text!/ucs-overview/welcome.json", |
44 |
"../ucs/i18n!welcome,ucs" |
45 |
], function(lang, kernel, array, ioQuery, query, dom, domConstruct, domAttr, domStyle, domClass, domGeometry, data, _) { |
46 |
return { |
47 |
start: function() { |
48 |
this.replaceTitle(); |
49 |
this.addApplianceLogo(); |
50 |
this.insertLinks(); |
51 |
|
52 |
}, |
53 |
|
54 |
replaceTitle: function() { |
55 |
if (data['umc/web/appliance/name']) { |
56 |
var title = _('Welcome to the {0} appliance with Univention Corporate Server', [data['umc/web/appliance/name']]); |
57 |
var titleNode = query('h1', 'title')[0]; |
58 |
domAttr.set(titleNode, 'data-i18n', title); |
59 |
titleNode.innerHTML = title; |
60 |
query('title')[0].innerHTML = title; |
61 |
} |
62 |
}, |
63 |
|
64 |
addApplianceLogo: function() { |
65 |
if (data['umc/web/appliance/logo']) { |
66 |
var path = data['umc/web/appliance/logo']; |
67 |
if (path[0] !== '/') { |
68 |
path = '/univention-management-console/js/dijit/themes/umc/' + path; |
69 |
} |
70 |
domStyle.set('welcome-appliance-logo', 'background-image', lang.replace('url({0})', [path])); |
71 |
} |
72 |
}, |
73 |
|
74 |
insertLinks: function() { |
75 |
var alternatives = dom.byId('welcome-url-alternative'); |
76 |
array.forEach(data['ip_addresses'].concat([data['hostname'] + '.' + data['domainname']]).concat(data['ip6_addresses']), function(address, i, arr) { |
77 |
address = this.formatUrl(address, data['ip6_addresses'].indexOf(address) !== -1); |
78 |
if (i == 0) { |
79 |
dom.byId('welcome-url').innerHTML = address; |
80 |
} else { |
81 |
domClass.toggle(alternatives, 'dijitHidden', false); |
82 |
domConstruct.create('span', {innerHTML: address}, alternatives); |
83 |
} |
84 |
}, this); |
85 |
|
86 |
}, |
87 |
|
88 |
formatUrl: function(url, ip6) { |
89 |
if (ip6) { |
90 |
url = '[' + url + ']'; |
91 |
} |
92 |
return 'https://' + url + '/'; |
93 |
} |
94 |
}; |
95 |
}); |