2019-02-01 21:42:41 +01:00
|
|
|
|
|
|
|
// scripts loader
|
|
|
|
function loadScript(url, callback) {
|
|
|
|
var script = document.createElement('script');
|
|
|
|
script.type = 'text/javascript';
|
|
|
|
script.src = url;
|
|
|
|
// There are several events for cross browser compatibility.
|
|
|
|
script.onreadystatechange = callback;
|
|
|
|
script.onload = callback;
|
|
|
|
// Fire the loading
|
|
|
|
document.head.appendChild(script);
|
|
|
|
}
|
|
|
|
|
|
|
|
// handle app links so they work both in plain info page and in the info iframe called from ynhpanel.js
|
|
|
|
function appClick (evnt, url) {
|
|
|
|
|
|
|
|
// if asked to open in new tab
|
|
|
|
if (
|
|
|
|
evnt.ctrlKey ||
|
|
|
|
evnt.shiftKey ||
|
|
|
|
evnt.metaKey ||
|
|
|
|
(evnt.button && evnt.button == 1)
|
|
|
|
) return
|
|
|
|
|
|
|
|
// if asked in current tab
|
|
|
|
else {
|
|
|
|
evnt.preventDefault();
|
|
|
|
parent.location.href= url;
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-14 01:42:31 +02:00
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
|
2014-05-14 11:14:45 +02:00
|
|
|
// Variables
|
|
|
|
var liMenu = document.querySelectorAll('#apps a')
|
2015-06-14 12:53:16 +02:00
|
|
|
, colors = ['redbg','purpledarkbg','darkbluebg','orangebg','greenbg','darkbluebg','purpledarkbg','yellowbg','lightpinkbg','pinkbg','turquoisebg','yellowbg','lightbluebg','purpledarkbg', 'bluebg']
|
2014-05-14 11:14:45 +02:00
|
|
|
, addMailAlias = document.getElementById('add-mailalias')
|
|
|
|
, addMaildrop = document.getElementById('add-maildrop')
|
|
|
|
;
|
2014-05-14 01:42:31 +02:00
|
|
|
|
2014-06-01 13:57:48 +02:00
|
|
|
liMenu && [].forEach.call(liMenu, function(el, i) {
|
2015-06-14 12:53:16 +02:00
|
|
|
// Select a color value from the App label
|
|
|
|
randomColorNumber = parseInt(el.textContent, 36) % colors.length;
|
|
|
|
//randomColorNumber = i%colors.length; // Old value
|
2014-05-14 11:14:45 +02:00
|
|
|
// Add color class.
|
2015-06-14 12:53:16 +02:00
|
|
|
el.classList.add(colors[randomColorNumber]);
|
2014-05-14 11:14:45 +02:00
|
|
|
// Set first-letter data attribute.
|
|
|
|
el.querySelector('.first-letter').setAttribute('data-first-letter',el.textContent.substring(0, 2));
|
2014-05-14 01:42:31 +02:00
|
|
|
});
|
|
|
|
|
2014-06-01 13:57:48 +02:00
|
|
|
addMailAlias && addMailAlias.addEventListener('click', function(){
|
2014-05-14 11:14:45 +02:00
|
|
|
// Clone last input.
|
|
|
|
var inputAliasClone = document.querySelector('.mailalias-input').cloneNode(true);
|
|
|
|
// Empty value.
|
|
|
|
inputAliasClone.value = '';
|
|
|
|
// Append to form-group.
|
|
|
|
addMailAlias.parentNode.insertBefore(inputAliasClone, addMailAlias);
|
2014-05-14 01:42:31 +02:00
|
|
|
});
|
|
|
|
|
2014-06-01 13:57:48 +02:00
|
|
|
addMaildrop && addMaildrop.addEventListener('click', function(){
|
2014-05-14 11:14:45 +02:00
|
|
|
// Clone last input.
|
|
|
|
var inputDropClone = document.querySelector('.maildrop-input').cloneNode(true);
|
|
|
|
// Empty value.
|
|
|
|
inputDropClone.value = '';
|
|
|
|
// Append to form-group.
|
|
|
|
addMaildrop.parentNode.insertBefore(inputDropClone, addMaildrop);
|
2014-05-14 01:42:31 +02:00
|
|
|
});
|
2014-05-14 11:14:45 +02:00
|
|
|
|
2015-06-14 12:53:16 +02:00
|
|
|
});
|