2018-12-10 21:14:30 +01:00
|
|
|
// Generated by CoffeeScript 1.12.7
|
2016-01-21 12:36:23 +01:00
|
|
|
|
2016-05-20 19:09:32 +02:00
|
|
|
/*
|
|
|
|
LemonLDAP::NG Portal jQuery scripts
|
|
|
|
*/
|
2016-01-21 12:36:23 +01:00
|
|
|
|
2016-05-20 19:09:32 +02:00
|
|
|
(function() {
|
2018-06-20 21:38:26 +02:00
|
|
|
var datas, delKey, getCookie, getValues, isHiddenFormValueSet, ping, removeOidcConsent, restoreOrder, setCookie, setKey, setOrder, setSelector, translate, translatePage, translationFields,
|
2016-05-20 19:09:32 +02:00
|
|
|
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
2016-01-21 12:36:23 +01:00
|
|
|
|
2016-05-21 08:52:16 +02:00
|
|
|
translationFields = {};
|
|
|
|
|
2016-05-20 19:09:32 +02:00
|
|
|
translatePage = function(lang) {
|
2016-05-21 08:52:16 +02:00
|
|
|
return $.getJSON(window.staticPrefix + "languages/" + lang + ".json", function(data) {
|
2018-10-17 10:49:00 +02:00
|
|
|
var k, ref, ref1, v;
|
2016-05-21 08:52:16 +02:00
|
|
|
translationFields = data;
|
2018-10-17 10:49:00 +02:00
|
|
|
ref = window.datas.trOver.all;
|
|
|
|
for (k in ref) {
|
|
|
|
v = ref[k];
|
|
|
|
translationFields[k] = v;
|
|
|
|
}
|
|
|
|
if (window.datas.trOver[lang]) {
|
|
|
|
ref1 = window.datas.trOver[lang];
|
|
|
|
for (k in ref1) {
|
|
|
|
v = ref1[k];
|
|
|
|
translationFields[k] = v;
|
|
|
|
}
|
|
|
|
}
|
2016-05-22 08:58:03 +02:00
|
|
|
$("[trspan]").each(function() {
|
2018-10-17 10:49:00 +02:00
|
|
|
var args, i, len, txt;
|
2017-02-15 20:13:03 +01:00
|
|
|
args = $(this).attr('trspan').split(',');
|
2017-02-16 08:37:47 +01:00
|
|
|
txt = translate(args.shift());
|
2017-02-15 20:13:03 +01:00
|
|
|
for (i = 0, len = args.length; i < len; i++) {
|
|
|
|
v = args[i];
|
2017-06-28 17:49:59 +02:00
|
|
|
txt = txt.replace(/%[sd]/, v);
|
2017-02-15 20:13:03 +01:00
|
|
|
}
|
|
|
|
return $(this).text(txt);
|
2016-05-21 08:52:16 +02:00
|
|
|
});
|
2017-03-14 12:04:05 +01:00
|
|
|
$("[trmsg]").each(function() {
|
2016-05-22 08:58:03 +02:00
|
|
|
return $(this).text(translate("PE" + ($(this).attr('trmsg'))));
|
|
|
|
});
|
2017-03-15 22:20:10 +01:00
|
|
|
$("[trplaceholder]").each(function() {
|
2017-03-14 12:04:05 +01:00
|
|
|
return $(this).attr('placeholder', translate($(this).attr('trplaceholder')));
|
|
|
|
});
|
2017-03-15 22:20:10 +01:00
|
|
|
return $("[localtime]").each(function() {
|
|
|
|
var d;
|
|
|
|
d = new Date($(this).attr('localtime') * 1000);
|
|
|
|
return $(this).text(d.toLocaleString());
|
|
|
|
});
|
2016-01-21 12:36:23 +01:00
|
|
|
});
|
2016-05-20 19:09:32 +02:00
|
|
|
};
|
2016-01-21 12:36:23 +01:00
|
|
|
|
2016-05-21 08:52:16 +02:00
|
|
|
translate = function(str) {
|
|
|
|
if (translationFields[str]) {
|
|
|
|
return translationFields[str];
|
|
|
|
} else {
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
};
|
2012-12-04 17:31:12 +01:00
|
|
|
|
2017-02-08 19:10:06 +01:00
|
|
|
window.translate = translate;
|
|
|
|
|
2017-01-19 07:09:20 +01:00
|
|
|
getValues = function() {
|
|
|
|
var values;
|
|
|
|
values = {};
|
|
|
|
$("script[type='application/init']").each(function() {
|
2018-04-04 22:26:50 +02:00
|
|
|
var e, k, results, tmp;
|
2017-01-19 07:09:20 +01:00
|
|
|
try {
|
2017-01-19 13:13:36 +01:00
|
|
|
tmp = JSON.parse($(this).text());
|
2017-01-19 07:09:20 +01:00
|
|
|
results = [];
|
|
|
|
for (k in tmp) {
|
|
|
|
results.push(values[k] = tmp[k]);
|
|
|
|
}
|
|
|
|
return results;
|
2018-06-20 06:56:32 +02:00
|
|
|
} catch (error1) {
|
|
|
|
e = error1;
|
2017-01-19 13:13:36 +01:00
|
|
|
console.log('Parsing error', e);
|
|
|
|
return console.log('JSON', $(this).text());
|
2017-01-19 07:09:20 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return values;
|
|
|
|
};
|
|
|
|
|
2016-05-20 19:09:32 +02:00
|
|
|
setSelector = "#appslist";
|
2012-12-04 17:31:12 +01:00
|
|
|
|
2017-09-18 21:10:01 +02:00
|
|
|
setOrder = function() {
|
2017-09-18 22:40:01 +02:00
|
|
|
return setKey('_appsListOrder', $(setSelector).sortable("toArray").join());
|
|
|
|
};
|
|
|
|
|
|
|
|
removeOidcConsent = function(partner) {
|
2018-06-20 21:38:26 +02:00
|
|
|
var e;
|
|
|
|
e = function(j, s, e) {
|
2017-09-19 19:01:19 +02:00
|
|
|
return alert(s + " " + e);
|
2018-06-20 21:38:26 +02:00
|
|
|
};
|
2018-07-15 22:08:30 +02:00
|
|
|
return delKey("_oidcConsents", partner, function() {
|
|
|
|
return $("[partner='" + partner + "']").hide();
|
2018-06-20 21:38:26 +02:00
|
|
|
}, e);
|
2017-09-18 22:40:01 +02:00
|
|
|
};
|
|
|
|
|
2017-09-19 19:01:19 +02:00
|
|
|
setKey = function(key, val, success, error) {
|
2016-05-20 19:09:32 +02:00
|
|
|
return $.ajax({
|
2017-09-18 22:40:01 +02:00
|
|
|
type: "GET",
|
|
|
|
url: datas['scriptname'] + '/mysession/?gettoken',
|
|
|
|
dataType: 'json',
|
2017-09-19 19:01:19 +02:00
|
|
|
error: error,
|
2017-09-18 22:40:01 +02:00
|
|
|
success: function(data) {
|
|
|
|
var d;
|
|
|
|
d = {
|
|
|
|
token: data.token
|
|
|
|
};
|
|
|
|
d[key] = val;
|
|
|
|
return $.ajax({
|
|
|
|
type: "PUT",
|
|
|
|
url: datas['scriptname'] + '/mysession/persistent',
|
|
|
|
dataType: 'json',
|
2017-09-19 19:01:19 +02:00
|
|
|
data: d,
|
|
|
|
success: success,
|
|
|
|
error: error
|
2017-09-18 22:40:01 +02:00
|
|
|
});
|
|
|
|
}
|
2016-05-20 19:09:32 +02:00
|
|
|
});
|
|
|
|
};
|
2012-12-04 17:31:12 +01:00
|
|
|
|
2018-07-17 18:18:50 +02:00
|
|
|
delKey = function(key, sub, success, error) {
|
2018-06-20 21:38:26 +02:00
|
|
|
return $.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: datas['scriptname'] + '/mysession/?gettoken',
|
|
|
|
dataType: 'json',
|
|
|
|
error: error,
|
|
|
|
success: function(data) {
|
|
|
|
return $.ajax({
|
|
|
|
type: "DELETE",
|
2018-07-17 18:18:50 +02:00
|
|
|
url: datas['scriptname'] + "/mysession/persistent/" + key + "?sub=" + sub + "&token=" + data.token,
|
2018-06-20 21:38:26 +02:00
|
|
|
dataType: 'json',
|
|
|
|
success: success,
|
|
|
|
error: error
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-05-20 19:09:32 +02:00
|
|
|
restoreOrder = function() {
|
2017-02-19 12:45:26 +01:00
|
|
|
var IDs, child, i, item, itemID, items, l, len, len1, list, rebuild, savedOrd, v;
|
2016-05-20 19:09:32 +02:00
|
|
|
list = $(setSelector);
|
2017-01-19 12:33:11 +01:00
|
|
|
if (!((list != null) && datas['appslistorder'])) {
|
2016-05-20 19:09:32 +02:00
|
|
|
return null;
|
|
|
|
}
|
2017-01-19 12:33:11 +01:00
|
|
|
IDs = datas['appslistorder'].split(',');
|
2016-05-20 19:09:32 +02:00
|
|
|
items = list.sortable("toArray");
|
|
|
|
rebuild = [];
|
|
|
|
for (i = 0, len = items.length; i < len; i++) {
|
|
|
|
v = items[i];
|
|
|
|
rebuild[v] = v;
|
|
|
|
}
|
2017-02-19 12:45:26 +01:00
|
|
|
for (l = 0, len1 = IDs.length; l < len1; l++) {
|
|
|
|
itemID = IDs[l];
|
2017-09-05 16:40:52 +02:00
|
|
|
if (rebuild[itemID]) {
|
|
|
|
item = rebuild[itemID];
|
2016-05-20 19:09:32 +02:00
|
|
|
child = $(setSelector + ".ui-sortable").children("#" + item);
|
|
|
|
savedOrd = $(setSelector + ".ui-sortable").children("#" + itemID);
|
|
|
|
child.remove();
|
|
|
|
$(setSelector + ".ui-sortable").filter(":first").append(savedOrd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
isHiddenFormValueSet = function(option) {
|
|
|
|
return $('#lmhidden_' + option).length;
|
|
|
|
};
|
|
|
|
|
|
|
|
ping = function() {
|
|
|
|
return $.ajax({
|
|
|
|
type: "POST",
|
2017-01-19 12:33:11 +01:00
|
|
|
url: datas['scriptname'],
|
2016-05-20 19:09:32 +02:00
|
|
|
data: {
|
|
|
|
ping: 1
|
|
|
|
},
|
|
|
|
dataType: 'json',
|
|
|
|
success: function(data) {
|
2017-02-19 12:45:26 +01:00
|
|
|
if ((data.result != null) && data.result === 1) {
|
2017-01-19 12:33:11 +01:00
|
|
|
return setTimeout(ping, datas['pingInterval']);
|
2016-05-20 19:09:32 +02:00
|
|
|
} else {
|
2017-01-19 22:48:07 +01:00
|
|
|
return location.reload(true);
|
2016-05-20 19:09:32 +02:00
|
|
|
}
|
2017-02-19 12:45:26 +01:00
|
|
|
},
|
|
|
|
error: function(j, t, e) {
|
|
|
|
return location.reload(true);
|
2016-05-20 19:09:32 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
2012-12-04 17:31:12 +01:00
|
|
|
|
2016-05-20 19:09:32 +02:00
|
|
|
window.ping = ping;
|
2012-12-04 17:31:12 +01:00
|
|
|
|
2017-02-16 08:37:47 +01:00
|
|
|
getCookie = function(cname) {
|
|
|
|
var c, ca, i, len, name, re;
|
|
|
|
name = cname + "=";
|
|
|
|
ca = decodeURIComponent(document.cookie).split(';');
|
|
|
|
re = new RegExp('^ *' + cname + '=');
|
|
|
|
for (i = 0, len = ca.length; i < len; i++) {
|
|
|
|
c = ca[i];
|
|
|
|
if (c.match(re)) {
|
|
|
|
c = c.replace(re, '');
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
};
|
|
|
|
|
|
|
|
setCookie = function(name, value, exdays) {
|
|
|
|
var d;
|
|
|
|
d = new Date();
|
|
|
|
d.setTime(d.getTime() + exdays * 86400000);
|
|
|
|
return document.cookie = name + "=" + value + "; expires=" + (d.toUTCString()) + "; path=/";
|
|
|
|
};
|
|
|
|
|
2017-01-19 12:33:11 +01:00
|
|
|
datas = {};
|
|
|
|
|
2016-05-20 19:09:32 +02:00
|
|
|
$(document).ready(function() {
|
2018-12-11 21:35:40 +01:00
|
|
|
var action, al, authMenuTabs, back_url, i, l, lang, langdiv, langs, langs2, len, len1, len2, len3, link, m, menuIndex, menuTabs, method, n, nl, nlangs, re, ref, ref1, ref2;
|
2017-01-19 12:33:11 +01:00
|
|
|
datas = getValues();
|
|
|
|
window.datas = datas;
|
|
|
|
if (datas['antiframe'] && top !== self) {
|
2016-05-20 19:09:32 +02:00
|
|
|
top.location.href = location.href;
|
2016-01-21 12:36:23 +01:00
|
|
|
}
|
2016-05-20 19:09:32 +02:00
|
|
|
$("#appslist").sortable({
|
|
|
|
axis: "y",
|
|
|
|
cursor: "move",
|
|
|
|
opacity: 0.5,
|
|
|
|
revert: true,
|
|
|
|
items: "> div.category",
|
|
|
|
update: function() {
|
2017-09-18 21:10:01 +02:00
|
|
|
return setOrder();
|
2016-01-21 12:36:23 +01:00
|
|
|
}
|
2016-05-20 19:09:32 +02:00
|
|
|
});
|
|
|
|
restoreOrder();
|
|
|
|
$("div.message").fadeIn('slow');
|
|
|
|
$("input[name=timezone]").val(-(new Date().getTimezoneOffset() / 60));
|
|
|
|
menuTabs = $("#menu").tabs({
|
|
|
|
active: 0
|
|
|
|
});
|
2017-01-19 12:33:11 +01:00
|
|
|
menuIndex = $('#menu a[href="#' + datas['displaytab'] + '"]').parent().index();
|
2016-05-20 19:09:32 +02:00
|
|
|
if (menuIndex < 0) {
|
|
|
|
menuIndex = 0;
|
|
|
|
}
|
|
|
|
menuTabs.tabs("option", "active", menuIndex);
|
|
|
|
authMenuTabs = $("#authMenu").tabs({
|
|
|
|
active: 0
|
|
|
|
});
|
2017-01-19 12:33:11 +01:00
|
|
|
if (datas['choicetab']) {
|
|
|
|
authMenuTabs.tabs("option", "active", $('#authMenu a[href="#' + datas['choicetab'] + '"]').parent().index());
|
2016-05-20 19:09:32 +02:00
|
|
|
}
|
2017-01-19 12:33:11 +01:00
|
|
|
if (datas['login']) {
|
2016-05-20 19:09:32 +02:00
|
|
|
$("input[type=password]:first").focus();
|
|
|
|
} else {
|
|
|
|
$("input[type!=hidden]:first").focus();
|
|
|
|
}
|
2017-01-19 12:33:11 +01:00
|
|
|
if (datas['newwindow']) {
|
2016-05-20 19:09:32 +02:00
|
|
|
$('#appslist a').attr("target", "_blank");
|
|
|
|
}
|
|
|
|
if ($("p.removeOther").length) {
|
|
|
|
action = $("form.login").attr("action");
|
|
|
|
method = $("form.login").attr("method");
|
|
|
|
back_url = "";
|
|
|
|
if (action.indexOf("?") !== -1) {
|
|
|
|
action.substring(0, action.indexOf("?")) + "?";
|
|
|
|
} else {
|
|
|
|
back_url = action + "?";
|
2016-01-21 12:36:23 +01:00
|
|
|
}
|
2016-05-20 19:09:32 +02:00
|
|
|
$("form.login input[type=hidden]").each(function(index) {
|
|
|
|
return back_url += "&" + $(this).attr("name") + "=" + $(this).val();
|
|
|
|
});
|
|
|
|
link = $("p.removeOther a").attr("href") + "&method=" + method + "&url=" + btoa(back_url);
|
|
|
|
$("p.removeOther a").attr("href", link);
|
2016-01-21 12:36:23 +01:00
|
|
|
}
|
2017-02-16 08:37:47 +01:00
|
|
|
lang = getCookie('llnglanguage');
|
|
|
|
if (!lang) {
|
|
|
|
if (navigator) {
|
|
|
|
langs = [];
|
|
|
|
langs2 = [];
|
|
|
|
nlangs = [navigator.language];
|
|
|
|
if (navigator.languages) {
|
|
|
|
nlangs = navigator.languages;
|
|
|
|
}
|
2016-05-21 08:52:16 +02:00
|
|
|
ref = window.availableLanguages;
|
2017-02-16 08:37:47 +01:00
|
|
|
for (i = 0, len = ref.length; i < len; i++) {
|
|
|
|
al = ref[i];
|
2017-05-24 20:11:58 +02:00
|
|
|
langdiv += "<img class=\"langicon\" src=\"" + window.staticPrefix + "common/" + al + ".png\" title=\"" + al + "\" alt=\"[" + al + "]\"> ";
|
2018-12-11 21:35:40 +01:00
|
|
|
}
|
|
|
|
for (l = 0, len1 = nlangs.length; l < len1; l++) {
|
|
|
|
nl = nlangs[l];
|
|
|
|
console.log('Navigator lang', nl);
|
|
|
|
ref1 = window.availableLanguages;
|
|
|
|
for (m = 0, len2 = ref1.length; m < len2; m++) {
|
|
|
|
al = ref1[m];
|
|
|
|
console.log(' Available lang', al);
|
2018-12-10 21:14:30 +01:00
|
|
|
re = new RegExp('^' + al + '-?');
|
|
|
|
if (nl.match(re)) {
|
2018-12-11 21:46:39 +01:00
|
|
|
console.log(' Matching lang =', al);
|
2017-02-16 08:37:47 +01:00
|
|
|
langs.push(al);
|
|
|
|
} else if (al.substring(0, 1) === nl.substring(0, 1)) {
|
|
|
|
langs2.push(al);
|
|
|
|
}
|
2016-05-21 08:52:16 +02:00
|
|
|
}
|
|
|
|
}
|
2017-05-05 08:50:38 +02:00
|
|
|
lang = langs[0] ? langs[0] : langs2[0] ? langs2[0] : window.availableLanguages[0];
|
2017-02-16 08:37:47 +01:00
|
|
|
} else {
|
2017-05-05 08:50:38 +02:00
|
|
|
lang = window.availableLanguages[0];
|
2016-05-21 08:52:16 +02:00
|
|
|
}
|
2017-05-05 08:50:38 +02:00
|
|
|
} else if (indexOf.call(window.availableLanguages, lang) < 0) {
|
|
|
|
lang = window.availableLanguages[0];
|
2016-05-21 08:52:16 +02:00
|
|
|
}
|
2018-12-10 21:26:06 +01:00
|
|
|
console.log('Selected lang ->', lang);
|
2017-02-17 21:47:01 +01:00
|
|
|
setCookie('llnglanguage', lang);
|
2017-02-16 08:37:47 +01:00
|
|
|
translatePage(lang);
|
|
|
|
langdiv = '';
|
2018-12-11 21:35:40 +01:00
|
|
|
ref2 = window.availableLanguages;
|
|
|
|
for (n = 0, len3 = ref2.length; n < len3; n++) {
|
|
|
|
al = ref2[n];
|
2017-05-24 20:11:58 +02:00
|
|
|
langdiv += "<img class=\"langicon\" src=\"" + window.staticPrefix + "common/" + al + ".png\" title=\"" + al + "\" alt=\"[" + al + "]\"> ";
|
2017-02-16 08:37:47 +01:00
|
|
|
}
|
|
|
|
$('#languages').html(langdiv);
|
|
|
|
$('.langicon').on('click', function() {
|
|
|
|
lang = $(this).attr('title');
|
|
|
|
setCookie('llnglanguage', lang);
|
|
|
|
return translatePage(lang);
|
|
|
|
});
|
2017-01-19 12:33:11 +01:00
|
|
|
if (datas['pingInterval'] && datas['pingInterval'] > 0) {
|
|
|
|
window.setTimeout(ping, datas['pingInterval']);
|
|
|
|
}
|
2017-09-18 22:40:01 +02:00
|
|
|
$(".localeDate").each(function() {
|
2017-01-19 22:48:07 +01:00
|
|
|
var s;
|
|
|
|
s = new Date($(this).attr("val") * 1000);
|
|
|
|
return $(this).text(s.toLocaleString());
|
|
|
|
});
|
2017-09-18 22:40:01 +02:00
|
|
|
return $('.oidcConsent').on('click', function() {
|
|
|
|
return removeOidcConsent($(this).attr('partner'));
|
|
|
|
});
|
2016-01-21 12:36:23 +01:00
|
|
|
});
|
2016-05-20 19:09:32 +02:00
|
|
|
|
|
|
|
}).call(this);
|