Skip to content
Snippets Groups Projects
Commit f8f22998 authored by erichard's avatar erichard
Browse files

Mise à jour des noms d'attributs et fonction

name -> name_label
update_tutorials_and_labels() -> update_elements_and_labels()
parent eff67682
No related branches found
No related tags found
2 merge requests!61Packager labelstower,!60WIP: Implement sqlalchemy
function setCookie(name, value) {
function setCookie(label_name, value) {
/**
* Create a cookie for ten years?
*/
......@@ -6,14 +6,14 @@ function setCookie(name, value) {
var expires = new Date();
expires.setTime(today.getTime() + (10*365*24*60*60*1000));
document.cookie = name + "=" + value + ";expires=" + expires.toGMTString();
document.cookie = label_name + "=" + value + ";expires=" + expires.toGMTString();
}
function getCookie(name) {
function getCookie(label_name) {
/**
* Retrieve the value of a cookie due to it's name.
* Retrieve the value of a cookie due to it's label_name.
*/
var regex = new RegExp("(?:; )?" + name + "=([^;]*);?");
var regex = new RegExp("(?:; )?" + label_name + "=([^;]*);?");
if (regex.test(document.cookie))
return (RegExp["$1"]);
......@@ -24,13 +24,13 @@ function getCookie(name) {
function labels_tab_to_str(labels) {
/**
* Transform tab of labels to string.
* ex : [{'id_label': 1, 'name': "Learn C++", 'father_id': 6}]
* ex : [{'id_label': 1, 'label_name': "Learn C++", 'father_id': 6}]
* = 1, Learn C++, 6|...
*/
var result = "";
var inter = []
for (var i = 0; labels[i]; i++)
inter.push([labels[i]['id'], labels[i]['name'], labels[i]['father_id']]);
inter.push([labels[i]['id'], labels[i]['label_name'], labels[i]['father_id']]);
result = inter.join('|');
return (result);
}
......@@ -46,9 +46,9 @@ function str_to_labels_tab(str) {
for (var i = 0; split[i]; i++) {
var inter = split[i].split(',')
if (inter.length == 2)
result.push({'id': inter[0], 'name': inter[1]});
result.push({'id': inter[0], 'label_name': inter[1]});
else
result.push({'id': inter[0], 'name': inter[1], 'father_id': inter[2]});
result.push({'id': inter[0], 'label_name': inter[1], 'father_id': inter[2]});
}
return (result);
}
......@@ -76,10 +76,10 @@ function setup_session() {
hierarchy.forbiden_labels = str_to_labels_tab(getCookie('cookies_forbiden_labels'));
if (getCookie('cookies_mandatory_labels') != null && getCookie('cookies_mandatory_labels').length != 0) {
update_tutorials_and_labels();
update_elements_and_labels();
success = 1;
} else if (getCookie('cookies_forbiden_labels') != null && getCookie('cookies_forbiden_labels').length != 0) {
update_tutorials_and_labels();
update_elements_and_labels();
success = 1;
}
return (success);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment