2024-09-13 17:43:01 +02:00
|
|
|
// AlertifyJS default settings
|
|
|
|
alertify.defaults = {
|
|
|
|
// dialogs defaults
|
|
|
|
modal: true,
|
|
|
|
movable: true,
|
|
|
|
resizable: true,
|
|
|
|
closable: true,
|
|
|
|
maximizable: true,
|
|
|
|
pinnable: true,
|
|
|
|
pinned: true,
|
|
|
|
padding: true,
|
|
|
|
overflow: true,
|
|
|
|
maintainFocus: true,
|
|
|
|
transition: "fade",
|
|
|
|
|
|
|
|
// notifier defaults
|
|
|
|
notifier: {
|
|
|
|
// auto-dismiss wait time (in seconds)
|
|
|
|
delay: 0,
|
|
|
|
// default position
|
|
|
|
position: "top-right",
|
|
|
|
},
|
|
|
|
|
|
|
|
// language resources
|
|
|
|
glossary: {
|
|
|
|
// Dialog title text
|
|
|
|
title: "Confirmation",
|
|
|
|
// ok button text
|
|
|
|
ok: "OK",
|
|
|
|
// cancel button text
|
|
|
|
cancel: "Annuler",
|
|
|
|
},
|
|
|
|
theme: {
|
|
|
|
// class name attached to prompt dialog input textbox.
|
|
|
|
input: "ajs-input form-control",
|
|
|
|
// class name attached to ok button
|
|
|
|
ok: "ajs-ok btn btn-primary",
|
|
|
|
// class name attached to cancel button
|
|
|
|
cancel: "ajs-cancel btn btn-default",
|
|
|
|
},
|
|
|
|
// global hooks
|
|
|
|
hooks:{
|
|
|
|
// invoked before initializing any dialog
|
|
|
|
preinit:function(instance){},
|
|
|
|
// invoked after initializing any dialog
|
|
|
|
postinit:function(instance){},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2016-09-06 01:12:46 +02:00
|
|
|
$('#cats').collapse({
|
|
|
|
toggle: false
|
|
|
|
});
|
|
|
|
|
|
|
|
on_title_click=function(event) {
|
|
|
|
if (event.target.tagName=='BUTTON') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var title=$(this);
|
|
|
|
var panel=title.parent().parent();
|
|
|
|
var panel_collapse=panel.find('.panel-collapse');
|
|
|
|
var show=!panel_collapse.hasClass('in');
|
|
|
|
$('.panel-collapse').each(function(idx,div) {
|
|
|
|
$(div).collapse('hide');
|
|
|
|
});
|
|
|
|
if (show) {
|
|
|
|
panel_collapse.collapse('show');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************
|
|
|
|
* Add scase
|
|
|
|
**********************/
|
|
|
|
on_add_scase_btn_click=function(event) {
|
|
|
|
navbar_collapse_hide();
|
|
|
|
$('#add_scase_modal').modal('show');
|
|
|
|
}
|
|
|
|
|
|
|
|
on_valid_add_scase_modal=function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var name=$('#add_scase_name')[0].value;
|
|
|
|
if (name=='') {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Vous devez saisir le nom de la valise !", "error", 5);
|
2016-09-06 01:12:46 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-09-17 18:55:25 +02:00
|
|
|
var nameshake=scases.byName(name);
|
|
|
|
if (nameshake) {
|
|
|
|
if (nameshake.removed) {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Une valise de ce nom existe dans la corbeille !", "error", 5);
|
2017-09-17 18:55:25 +02:00
|
|
|
}
|
|
|
|
else {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Cette valise existe déjà !", "error", 5);
|
2017-09-17 18:55:25 +02:00
|
|
|
}
|
2016-09-06 01:12:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
var scase=scases.newSCase(name);
|
|
|
|
if (scase) {
|
|
|
|
scases.save();
|
|
|
|
show_scase(scase);
|
|
|
|
}
|
|
|
|
$('#add_scase_modal').modal('hide');
|
|
|
|
}
|
|
|
|
|
|
|
|
on_show_add_scase_modal=function () {
|
|
|
|
$('#add_scase_name').focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
on_close_add_scase_modal=function () {
|
|
|
|
$('#add_scase_modal form')[0].reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************
|
|
|
|
* Rename scase
|
|
|
|
**********************/
|
|
|
|
on_rename_scase_btn_click=function(event) {
|
|
|
|
navbar_collapse_hide();
|
|
|
|
$('#rename_scase_name')[0].value=$('#cats').data('scase');
|
|
|
|
$('#rename_scase_modal').modal('show');
|
|
|
|
}
|
|
|
|
|
|
|
|
on_valid_rename_scase_modal=function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var name=$('#rename_scase_name')[0].value;
|
|
|
|
if (name=='') {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Vous devez saisir le nouveau nom de la valise !", "error", 5);
|
2016-09-06 01:12:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ($('#cats').data('scase')!=name) {
|
2017-09-17 18:55:25 +02:00
|
|
|
var nameshake=scases.byName(name);
|
|
|
|
if (nameshake) {
|
|
|
|
if (nameshake.removed) {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Une valise portant ce nom existe dans la corbeille !", "error", 5);
|
2017-09-17 18:55:25 +02:00
|
|
|
}
|
|
|
|
else {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Une valise portant ce nom existe déjà !", "error", 5);
|
2017-09-17 18:55:25 +02:00
|
|
|
}
|
2016-09-06 01:12:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var scase=scases.renameSCase($('#cats').data('scase'),name);
|
|
|
|
if (scase) {
|
|
|
|
scases.save();
|
|
|
|
show_scase(scase);
|
|
|
|
}
|
|
|
|
else {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify('Une erreur est survenue en renomant la valise...', "error", 5);
|
2016-09-06 01:12:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$('#rename_scase_modal').modal('hide');
|
|
|
|
}
|
|
|
|
|
|
|
|
on_show_rename_scase_modal=function () {
|
|
|
|
$('#rename_scase_name').focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
on_close_rename_scase_modal=function () {
|
|
|
|
$('#rename_scase_modal form')[0].reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************
|
|
|
|
* Copy scase
|
|
|
|
**********************/
|
|
|
|
on_copy_scase_btn_click=function(event) {
|
|
|
|
navbar_collapse_hide();
|
|
|
|
$('#copy_scase_modal').modal('show');
|
|
|
|
}
|
|
|
|
|
|
|
|
on_valid_copy_scase_modal=function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var name=$('#copy_scase_name')[0].value;
|
|
|
|
if (name=='') {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Vous devez saisir le nom de la nouvelle valise !", "error", 5);
|
2016-09-06 01:12:46 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-09-17 18:55:25 +02:00
|
|
|
var nameshake=scases.byName(name);
|
|
|
|
if (nameshake) {
|
|
|
|
if (nameshake.removed) {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Une valise portant ce nom existe dans la corbeille !", "error", 5);
|
2017-09-17 18:55:25 +02:00
|
|
|
}
|
|
|
|
else {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Une valise portant ce nom existe déjà !", "error", 5);
|
2017-09-17 18:55:25 +02:00
|
|
|
}
|
2016-09-06 01:12:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
var scase=scases.copySCase($('#cats').data('scase'),name);
|
|
|
|
if (scase) {
|
|
|
|
scases.save();
|
|
|
|
show_scase(scase);
|
|
|
|
}
|
|
|
|
else {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify('Une erreur est survenue en copiant la valise...', "error", 5);
|
2016-09-06 01:12:46 +02:00
|
|
|
}
|
|
|
|
$('#copy_scase_modal').modal('hide');
|
|
|
|
}
|
|
|
|
|
|
|
|
on_show_copy_scase_modal=function () {
|
|
|
|
$('#copy_scase_name').focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
on_close_copy_scase_modal=function () {
|
|
|
|
$('#copy_scase_modal form')[0].reset();
|
|
|
|
}
|
|
|
|
|
2016-09-07 00:30:25 +02:00
|
|
|
/***********************
|
|
|
|
* Reset scase
|
|
|
|
**********************/
|
|
|
|
on_reset_scase_btn_click=function(event) {
|
|
|
|
navbar_collapse_hide();
|
|
|
|
var scase=scases.byName($('#cats').data('scase'));
|
|
|
|
if (scase) {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.confirm(
|
|
|
|
`Réinitialisation de la valise ${scase.name}`,
|
|
|
|
`Voulez-vous vraiment réinitialiser la valise ${scase.name} ?`,
|
|
|
|
function(data) {
|
|
|
|
scases.resetSCase(scase.name);
|
|
|
|
scases.save();
|
|
|
|
show_scase(scase);
|
|
|
|
},
|
|
|
|
null
|
|
|
|
);
|
2016-09-07 00:30:25 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-06 01:12:46 +02:00
|
|
|
/***********************
|
|
|
|
* Delete scase
|
|
|
|
**********************/
|
|
|
|
on_delete_scase_btn_click=function(event) {
|
|
|
|
navbar_collapse_hide();
|
|
|
|
var scase=scases.byName($('#cats').data('scase'));
|
|
|
|
if (scase) {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.confirm(
|
|
|
|
`Suppression de la valise ${scase.name}`,
|
|
|
|
`Voulez-vous vraiment supprimer la valise ${scase.name} ?`,
|
|
|
|
function(data) {
|
|
|
|
scases.removeSCase(scase.name);
|
|
|
|
scases.save();
|
|
|
|
show_scases();
|
|
|
|
},
|
|
|
|
null
|
|
|
|
);
|
2016-09-06 01:12:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-17 18:55:25 +02:00
|
|
|
on_restore_scase_btn_click=function(event) {
|
|
|
|
navbar_collapse_hide();
|
|
|
|
var scase=event.data.scase;
|
|
|
|
if (scase) {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.confirm(
|
|
|
|
`Restauration de la valise ${scase.name}`,
|
|
|
|
`Voulez-vous vraiment restaurer la valise ${scase.name} ?`,
|
|
|
|
function(data) {
|
|
|
|
scase.restore();
|
|
|
|
scases.save();
|
|
|
|
show_scases();
|
|
|
|
},
|
|
|
|
null
|
|
|
|
);
|
2017-09-17 18:55:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
on_scase_trash_btn_click=function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
navbar_collapse_hide();
|
|
|
|
var scase=scases.byName($('#cats').data('scase'));
|
|
|
|
if (scase) {
|
|
|
|
show_scase_trash(scase);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-06 01:12:46 +02:00
|
|
|
/***********************
|
|
|
|
* Add cat
|
|
|
|
**********************/
|
|
|
|
on_add_cat_btn_click=function(event) {
|
|
|
|
navbar_collapse_hide();
|
|
|
|
$('#add_cat_modal').modal('show');
|
|
|
|
}
|
|
|
|
|
|
|
|
on_valid_add_cat_modal=function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var name=$('#add_cat_name')[0].value;
|
|
|
|
if (name=='') {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Vous devez saisir le nom de la catégorie !", "error", 5);
|
2016-09-06 01:12:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
var scase=scases.byName($('#cats').data('scase'));
|
|
|
|
if (scase) {
|
2017-09-17 18:55:25 +02:00
|
|
|
var nameshake=scase.cats.byName(name);
|
|
|
|
if (nameshake) {
|
|
|
|
if (nameshake.removed) {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Une catégorie portant ce nom existe dans la corbeille !", "error", 5);
|
2017-09-17 18:55:25 +02:00
|
|
|
}
|
|
|
|
else {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Une catégorie portant ce nom existe déjà !", "error", 5);
|
2017-09-17 18:55:25 +02:00
|
|
|
}
|
2016-09-06 01:12:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
var cat=scase.cats.newCat(name);
|
|
|
|
if (cat) {
|
|
|
|
scases.save();
|
|
|
|
show_scase(scase,cat.name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$('#add_cat_modal').modal('hide');
|
|
|
|
}
|
|
|
|
|
|
|
|
on_show_add_cat_modal=function () {
|
|
|
|
$('#add_cat_name').focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
on_close_add_cat_modal=function () {
|
|
|
|
$('#add_cat_modal form')[0].reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************
|
|
|
|
* Rename cat
|
|
|
|
**********************/
|
|
|
|
on_rename_cat_btn_click=function(event) {
|
|
|
|
navbar_collapse_hide();
|
|
|
|
$('#rename_cat_modal').data('cat',event.data.cat.name);
|
|
|
|
$('#rename_cat_name')[0].value=event.data.cat.name;
|
|
|
|
$('#rename_cat_modal').modal('show');
|
|
|
|
}
|
|
|
|
|
|
|
|
on_valid_rename_cat_modal=function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var name=$('#rename_cat_name')[0].value;
|
|
|
|
if (name=='') {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Vous devez saisir le nouveau nom de la catégorie !", "error", 5);
|
2016-09-06 01:12:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
var scase=scases.byName($('#cats').data('scase'));
|
|
|
|
if (scase) {
|
|
|
|
if (scase.cats.byName(name)) {
|
2017-09-17 18:55:25 +02:00
|
|
|
var namesake=scase.cats.byName(name);
|
|
|
|
if (namesake.removed) {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Une catégorie de se nom existe dans la corbeille !", "error", 5);
|
2017-09-17 18:55:25 +02:00
|
|
|
}
|
|
|
|
else {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Cette catégorie existe déjà !", "error", 5);
|
2017-09-17 18:55:25 +02:00
|
|
|
}
|
2016-09-06 01:12:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
var cat=scase.cats.renameCat($('#rename_cat_modal').data('cat'),name);
|
|
|
|
if (cat) {
|
|
|
|
scases.save();
|
|
|
|
show_scase(scase,cat.name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$('#rename_cat_modal').modal('hide');
|
|
|
|
}
|
|
|
|
|
|
|
|
on_show_rename_cat_modal=function () {
|
|
|
|
$('#rename_cat_name').focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
on_close_rename_cat_modal=function () {
|
|
|
|
$('#rename_cat_modal form')[0].reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************
|
|
|
|
* Delete cat
|
|
|
|
**********************/
|
|
|
|
on_delete_cat_btn_click=function(event) {
|
|
|
|
navbar_collapse_hide();
|
|
|
|
var scase=scases.byName($('#cats').data('scase'));
|
|
|
|
if (scase) {
|
|
|
|
var cat=event.data.cat.name;
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.confirm(
|
|
|
|
`Suppression de la catégorie ${cat}`,
|
|
|
|
`Voulez-vous vraiment supprimer la catégorie ${cat} ?`,
|
|
|
|
function(data) {
|
|
|
|
scase.cats.removeCat(cat);
|
|
|
|
scases.save();
|
|
|
|
show_scase(scase);
|
|
|
|
},
|
|
|
|
null
|
|
|
|
);
|
2016-09-06 01:12:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-17 18:55:25 +02:00
|
|
|
on_restore_cat_btn_click=function(event) {
|
|
|
|
navbar_collapse_hide();
|
|
|
|
var scase=scases.byName($('#cats').data('scase'));
|
|
|
|
if (scase) {
|
|
|
|
var cat=event.data.cat.name;
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.confirm(
|
|
|
|
`Restauration de la catégorie ${cat}`,
|
|
|
|
`Voulez-vous vraiment restaurer la catégorie ${cat} ?`,
|
|
|
|
function(data) {
|
|
|
|
scase.cats.restoreCat(cat);
|
|
|
|
scases.save();
|
|
|
|
show_scase(scase);
|
|
|
|
},
|
|
|
|
null
|
|
|
|
);
|
2017-09-17 18:55:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-06 01:12:46 +02:00
|
|
|
/************************
|
|
|
|
* Check/Uncheck thing
|
|
|
|
***********************/
|
|
|
|
on_li_click=function(event) {
|
|
|
|
if (event.target.tagName!='LI') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var li=$(this);
|
2017-09-17 23:37:44 +02:00
|
|
|
if (li.hasClass('checked')) {
|
|
|
|
li.removeClass('checked');
|
2016-09-06 01:12:46 +02:00
|
|
|
}
|
|
|
|
else {
|
2017-09-17 23:37:44 +02:00
|
|
|
li.addClass('checked');
|
2016-09-06 01:12:46 +02:00
|
|
|
}
|
|
|
|
var ul=li.parent();
|
|
|
|
var scase=scases.byName($('#cats').data('scase'));
|
|
|
|
if (scase) {
|
|
|
|
var cat=scase.cats.byName(ul.data('cat'));
|
|
|
|
if (cat) {
|
|
|
|
var thing=cat.byLabel(li.data('label'));
|
|
|
|
if (thing) {
|
2017-09-17 23:37:44 +02:00
|
|
|
thing.setChecked(li.hasClass('checked'));
|
2016-09-06 01:12:46 +02:00
|
|
|
scases.save();
|
|
|
|
}
|
|
|
|
show_scase(scase,cat.name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************
|
|
|
|
* Add thing
|
|
|
|
**********************/
|
|
|
|
on_li_add_click=function(event) {
|
|
|
|
var li=$(this);
|
|
|
|
var cat=li.parent().data('cat');
|
2017-09-17 12:18:45 +02:00
|
|
|
var modal=$('#add_thing_modal');
|
2016-09-06 01:12:46 +02:00
|
|
|
modal.data('cat',cat);
|
|
|
|
modal.modal('show');
|
|
|
|
}
|
|
|
|
|
|
|
|
on_valid_add_thing_modal=function (e) {
|
|
|
|
e.preventDefault();
|
2017-09-17 12:18:45 +02:00
|
|
|
|
2016-09-06 01:12:46 +02:00
|
|
|
var modal=$('#add_thing_modal');
|
|
|
|
var scase=scases.byName($('#cats').data('scase'));
|
|
|
|
if (scase) {
|
|
|
|
var cat=scase.cats.byName(modal.data('cat'));
|
|
|
|
if (cat) {
|
2017-09-17 19:43:57 +02:00
|
|
|
var things=[];
|
2017-09-17 12:18:45 +02:00
|
|
|
var labels=[];
|
|
|
|
var error=false;
|
2017-09-17 19:43:57 +02:00
|
|
|
var add_thing_nbs=$('input.add_thing_nb');
|
2017-09-17 12:18:45 +02:00
|
|
|
$('input.add_thing_label').each(function(idx,input) {
|
2017-09-17 19:43:57 +02:00
|
|
|
var label=$(input).val();
|
|
|
|
if (label && label!='') {
|
|
|
|
if (labels.indexOf(label)>-1) {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Deux élements ne peuvent porter le même nom !", "error", 5);
|
2017-09-17 12:18:45 +02:00
|
|
|
error=true;
|
|
|
|
return;
|
|
|
|
}
|
2017-09-17 19:43:57 +02:00
|
|
|
if (cat.byLabel(label)) {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("L'élément '"+label+"' existe déjà !", "error", 5);
|
2017-09-17 12:18:45 +02:00
|
|
|
error=true;
|
|
|
|
return;
|
|
|
|
}
|
2017-09-17 19:43:57 +02:00
|
|
|
var nb=1;
|
|
|
|
if (add_thing_nbs[idx]) {
|
|
|
|
nb=parseInt($(add_thing_nbs[idx]).val());
|
|
|
|
if (!nb || nb==0) {
|
|
|
|
nb=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
things.push({
|
|
|
|
'label': label,
|
|
|
|
'nb': nb
|
|
|
|
});
|
|
|
|
labels.push(label);
|
2017-09-17 12:18:45 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
if (error) {
|
2016-09-06 01:12:46 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-09-17 19:43:57 +02:00
|
|
|
if (things.length==0) {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Vous devez saisir au moins un nom d'élément !", "error", 5);
|
2017-09-17 12:18:45 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-09-17 19:43:57 +02:00
|
|
|
for (idx in things) {
|
|
|
|
cat.newThing(things[idx]['label'], things[idx]['nb']);
|
2017-09-17 12:18:45 +02:00
|
|
|
}
|
2016-09-06 01:12:46 +02:00
|
|
|
scases.save();
|
|
|
|
show_scase(scase,cat.name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
modal.modal('hide');
|
|
|
|
}
|
|
|
|
|
|
|
|
on_show_add_thing_modal=function () {
|
2017-09-17 19:43:57 +02:00
|
|
|
$('.add_thing_other').remove();
|
2017-09-17 12:18:45 +02:00
|
|
|
$('input.add_thing_label').val('');
|
2017-09-17 19:43:57 +02:00
|
|
|
$('input.add_thing_nb').val('');
|
2017-09-17 12:18:45 +02:00
|
|
|
$('input.add_thing_label').first().focus();
|
2016-09-06 01:12:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
on_close_add_thing_modal=function () {
|
|
|
|
$('#add_thing_modal form')[0].reset();
|
|
|
|
}
|
|
|
|
|
2017-09-17 12:18:45 +02:00
|
|
|
on_add_thing_label_focus=function(event) {
|
|
|
|
if ($('input.add_thing_label').last()[0] == event.target) {
|
2017-09-17 19:43:57 +02:00
|
|
|
var new_input_group=$('<div class="form-group add_thing_other"></div>');
|
|
|
|
var new_input_label=$('<input type="text" class="form-control add_thing_label" placeholder="Encore un ?"/>');
|
|
|
|
var new_input_nb=$('<input type="number" class="form-control add_thing_nb" placeholder="Nb"/>');
|
|
|
|
new_input_group.append(new_input_label);
|
|
|
|
new_input_group.append(' ');
|
|
|
|
new_input_group.append(new_input_nb);
|
|
|
|
new_input_label.bind('focus', on_add_thing_label_focus);
|
2017-09-17 12:18:45 +02:00
|
|
|
$(event.target).parent().after(new_input_group);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-06 01:12:46 +02:00
|
|
|
|
|
|
|
/***********************
|
2017-09-17 19:43:57 +02:00
|
|
|
* Edit thing
|
2016-09-06 01:12:46 +02:00
|
|
|
**********************/
|
2017-09-17 19:43:57 +02:00
|
|
|
on_edit_thing_btn_click=function(event) {
|
2016-09-06 01:12:46 +02:00
|
|
|
navbar_collapse_hide();
|
2017-09-17 19:43:57 +02:00
|
|
|
$('#edit_thing_modal').data('cat',event.data.cat.name);
|
|
|
|
$('#edit_thing_modal').data('thing',event.data.thing.label);
|
|
|
|
$('#edit_thing_label').val(event.data.thing.label);
|
|
|
|
$('#edit_thing_nb').val(event.data.thing.nb);
|
|
|
|
$('#edit_thing_modal').modal('show');
|
2016-09-06 01:12:46 +02:00
|
|
|
}
|
|
|
|
|
2017-09-17 19:43:57 +02:00
|
|
|
on_valid_edit_thing_modal=function (e) {
|
2016-09-06 01:12:46 +02:00
|
|
|
e.preventDefault();
|
2017-09-17 19:43:57 +02:00
|
|
|
var label=$('#edit_thing_label').val();
|
2016-09-06 01:12:46 +02:00
|
|
|
if (label=='') {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Vous devez saisir le nouveau nom de l'élément !", "error", 5);
|
2016-09-06 01:12:46 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-09-17 19:43:57 +02:00
|
|
|
var nb=parseInt($('#edit_thing_nb').val());
|
|
|
|
if (!nb || nb==0) {
|
|
|
|
nb=1;
|
|
|
|
}
|
2016-09-06 01:12:46 +02:00
|
|
|
var scase=scases.byName($('#cats').data('scase'));
|
|
|
|
if (scase) {
|
2017-09-17 19:43:57 +02:00
|
|
|
var cat=scase.cats.byName($('#edit_thing_modal').data('cat'));
|
2016-09-06 01:12:46 +02:00
|
|
|
if (cat) {
|
2017-09-17 19:43:57 +02:00
|
|
|
if (label!=$('#edit_thing_modal').data('thing')) {
|
|
|
|
var namesake=cat.byLabel(label);
|
|
|
|
if (namesake) {
|
|
|
|
if (namesake.removed) {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Un élément de ce nom existe dans la corbeille !", "error", 5);
|
2017-09-17 19:43:57 +02:00
|
|
|
}
|
|
|
|
else {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify("Un élément de ce nom existe déjà !", "error", 5);
|
2017-09-17 19:43:57 +02:00
|
|
|
}
|
|
|
|
return;
|
2017-09-17 18:55:25 +02:00
|
|
|
}
|
2017-09-17 19:43:57 +02:00
|
|
|
var thing=cat.renameThing($('#edit_thing_modal').data('thing'),label);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var thing=cat.byLabel(label);
|
2016-09-06 01:12:46 +02:00
|
|
|
}
|
|
|
|
if (thing) {
|
2017-09-17 19:43:57 +02:00
|
|
|
thing.setNb(nb);
|
2016-09-06 01:12:46 +02:00
|
|
|
scases.save();
|
|
|
|
show_scase(scase,cat.name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-17 19:43:57 +02:00
|
|
|
$('#edit_thing_modal').modal('hide');
|
2016-09-06 01:12:46 +02:00
|
|
|
}
|
|
|
|
|
2017-09-17 19:43:57 +02:00
|
|
|
on_show_edit_thing_modal=function () {
|
|
|
|
$('#edit_thing_label').focus();
|
2016-09-06 01:12:46 +02:00
|
|
|
}
|
|
|
|
|
2017-09-17 19:43:57 +02:00
|
|
|
on_close_edit_thing_modal=function () {
|
|
|
|
$('#edit_thing_modal form')[0].reset();
|
2016-09-06 01:12:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************
|
|
|
|
* Delete thing
|
|
|
|
**********************/
|
|
|
|
on_delete_thing_btn_click=function(event) {
|
|
|
|
navbar_collapse_hide();
|
|
|
|
var scase=scases.byName($('#cats').data('scase'));
|
|
|
|
if (scase) {
|
|
|
|
var cat=scase.cats.byName(event.data.cat.name);
|
|
|
|
if (cat) {
|
|
|
|
var thing=event.data.thing.label;
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.confirm(
|
|
|
|
`Suppression de l'élément ${thing}`,
|
|
|
|
`Voulez-vous vraiment supprimer l'élément ${thing} ?`,
|
|
|
|
function(data) {
|
|
|
|
cat.removeThing(thing);
|
|
|
|
scases.save();
|
|
|
|
show_scase(scase,cat.name);
|
|
|
|
},
|
|
|
|
null
|
|
|
|
);
|
2016-09-06 01:12:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-17 18:55:25 +02:00
|
|
|
on_restore_thing_btn_click=function(event) {
|
|
|
|
navbar_collapse_hide();
|
|
|
|
var scase=scases.byName($('#cats').data('scase'));
|
|
|
|
if (scase) {
|
|
|
|
var cat=scase.cats.byName(event.data.cat.name);
|
|
|
|
if (cat) {
|
|
|
|
var thing=event.data.thing.label;
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.confirm(
|
|
|
|
`Restauration de l'élément ${thing}`,
|
|
|
|
`Voulez-vous vraiment restaurer l'élément ${thing} ?`,
|
|
|
|
function(data) {
|
|
|
|
cat.restoreThing(thing);
|
|
|
|
scases.save();
|
|
|
|
show_scase(scase,cat.name);
|
|
|
|
},
|
|
|
|
null
|
|
|
|
);
|
2017-09-17 18:55:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-06 01:12:46 +02:00
|
|
|
/********************
|
|
|
|
* Show one scase
|
|
|
|
*******************/
|
|
|
|
show_cat=function(cat,displayed) {
|
|
|
|
var panel=$('<div class="panel panel-default"></div>');
|
|
|
|
var panel_heading=$('<div class="panel-heading" role="tab"></div>');
|
|
|
|
var panel_title=$('<h4 class="panel-title">'+cat.name+' </h4>');
|
|
|
|
panel_title.bind('click',on_title_click);
|
|
|
|
|
2016-09-08 01:23:15 +02:00
|
|
|
var stats=cat.stats();
|
2016-09-06 01:12:46 +02:00
|
|
|
var tag=$('<span class="count-tag pull-right"></span>');
|
2016-09-08 01:23:15 +02:00
|
|
|
if (stats.things==stats.done) {
|
2016-09-06 01:12:46 +02:00
|
|
|
tag.append($('<span class="label label-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></span>'));
|
|
|
|
}
|
|
|
|
else {
|
2016-09-08 01:23:15 +02:00
|
|
|
tag.append($('<span class="badge">'+stats.done+' / '+stats.things+'</span>'));
|
2016-09-06 01:12:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var delete_btn=$('<button class="btn btn-default btn-xs pull-right"><span class="glyphicon glyphicon-trash"></button>');
|
|
|
|
delete_btn.bind('click',{'cat': cat},on_delete_cat_btn_click);
|
|
|
|
tag.append(delete_btn);
|
|
|
|
|
|
|
|
var rename_btn=$('<button class="btn btn-default btn-xs pull-right"><span class="glyphicon glyphicon-edit"></button>');
|
|
|
|
rename_btn.bind('click',{'cat': cat},on_rename_cat_btn_click);
|
|
|
|
tag.append(rename_btn);
|
|
|
|
|
|
|
|
panel_title.append(tag);
|
|
|
|
|
|
|
|
|
|
|
|
panel_heading.append(panel_title);
|
|
|
|
panel.append(panel_heading);
|
|
|
|
var panel_collapse=$('<div class="panel-collapse collapse" role="tabpanel"></div>');
|
|
|
|
if (displayed) {
|
|
|
|
panel_collapse.addClass('in');
|
|
|
|
}
|
|
|
|
var ul=$('<ul class="list-group" data-cat="'+cat.name+'"></ul>');
|
|
|
|
for (idx in cat.things) {
|
2017-09-17 18:55:25 +02:00
|
|
|
if (cat.things[idx].removed) {
|
|
|
|
continue;
|
|
|
|
}
|
2017-09-17 23:37:44 +02:00
|
|
|
var li=$('<li class="list-group-item checkable" data-label="'+cat.things[idx].label+'">'+cat.things[idx].label+'</li>');
|
2017-09-17 19:43:57 +02:00
|
|
|
if (cat.things[idx].nb>1) {
|
|
|
|
li.append(' <em>('+cat.things[idx].nb+')</em>');
|
|
|
|
}
|
2016-09-06 01:12:46 +02:00
|
|
|
if (cat.things[idx].checked) {
|
2017-09-17 23:37:44 +02:00
|
|
|
li.addClass('checked');
|
2016-09-06 01:12:46 +02:00
|
|
|
}
|
|
|
|
li.bind('click',on_li_click);
|
|
|
|
|
|
|
|
var li_actions=$('<span class="actions pull-right"></span>');
|
|
|
|
|
|
|
|
var delete_el_btn=$('<button class="btn btn-default btn-xs pull-right"><span class="glyphicon glyphicon-trash"></button>');
|
|
|
|
delete_el_btn.bind('click',{'cat': cat,'thing': cat.things[idx]},on_delete_thing_btn_click);
|
|
|
|
li_actions.append(delete_el_btn);
|
|
|
|
|
2017-09-17 19:43:57 +02:00
|
|
|
var edit_el_btn=$('<button class="btn btn-default btn-xs pull-right"><span class="glyphicon glyphicon-edit"></button>');
|
|
|
|
edit_el_btn.bind('click',{'cat': cat,'thing': cat.things[idx]},on_edit_thing_btn_click);
|
|
|
|
li_actions.append(edit_el_btn);
|
2016-09-06 01:12:46 +02:00
|
|
|
|
|
|
|
li.append(li_actions);
|
|
|
|
|
|
|
|
ul.append(li);
|
|
|
|
}
|
|
|
|
var li=$('<li class="list-group-item"><span class="glyphicon glyphicon-plus-sign"></span> Ajouter un élément</li>');
|
|
|
|
li.bind('click',on_li_add_click);
|
|
|
|
ul.append(li);
|
|
|
|
panel_collapse.append(ul);
|
|
|
|
panel.append(panel_collapse);
|
|
|
|
$('#cats').append(panel);
|
|
|
|
}
|
|
|
|
|
|
|
|
show_scase=function(scase,display_cat) {
|
2016-09-07 19:06:36 +02:00
|
|
|
clear_page('<h3><span class="glyphicon glyphicon-briefcase" aria-hidden="true"></span> '+scase.name+'</h3><div class="panel-group" id="cats" role="tablist" aria-multiselectable="true" data-scase="'+scase.name+'"></div>');
|
2016-09-06 01:12:46 +02:00
|
|
|
scase.cats.each(function(idx,cat) {
|
2017-09-17 18:55:25 +02:00
|
|
|
if (cat.removed) {
|
|
|
|
return;
|
|
|
|
}
|
2016-09-06 01:12:46 +02:00
|
|
|
show_cat(cat,(cat.name==display_cat));
|
|
|
|
});
|
|
|
|
show_menu('scase');
|
|
|
|
}
|
|
|
|
|
|
|
|
on_back_to_scases_btn_click=function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
navbar_collapse_hide();
|
|
|
|
show_scases();
|
|
|
|
}
|
|
|
|
|
2017-09-17 18:55:25 +02:00
|
|
|
/********************
|
|
|
|
* Show scase trash
|
|
|
|
*******************/
|
|
|
|
show_scase_trash=function(scase,display_cat) {
|
|
|
|
clear_page('<h3><span class="glyphicon glyphicon-trash" aria-hidden="true"></span>'+scase.name+' : Corbeille <button class="btn btn-default btn-xs" id="back_btn"><span class="glyphicon glyphicon-arrow-left"></button></h3><div class="panel-group" id="cats" role="tablist" aria-multiselectable="true" data-scase="'+scase.name+'"></div>');
|
|
|
|
|
|
|
|
$('#content h3 #back_btn').bind('click', {'scase': scase}, function(event) {
|
|
|
|
show_scase(event.data.scase);
|
|
|
|
});
|
|
|
|
|
|
|
|
scase.cats.each(function(idx,cat) {
|
|
|
|
show_cat_trash(cat,(cat.name==display_cat));
|
|
|
|
});
|
|
|
|
if ($('#cats .panel').length==0) {
|
|
|
|
$('#content').append('<p class="center">La corbeille est vide.</p>');
|
|
|
|
}
|
|
|
|
show_menu('scase');
|
|
|
|
}
|
|
|
|
|
|
|
|
show_cat_trash=function(cat,displayed) {
|
|
|
|
var panel=$('<div class="panel panel-default"></div>');
|
|
|
|
var panel_heading=$('<div class="panel-heading" role="tab"></div>');
|
|
|
|
var panel_title=$('<h4 class="panel-title">'+cat.name+' </h4>');
|
|
|
|
|
|
|
|
var tag=$('<span class="count-tag pull-right"></span>');
|
|
|
|
|
|
|
|
panel_title.append(tag);
|
|
|
|
|
|
|
|
|
|
|
|
panel_heading.append(panel_title);
|
|
|
|
panel.append(panel_heading);
|
|
|
|
|
|
|
|
|
|
|
|
if (cat.removed) {
|
|
|
|
var stats=cat.stats();
|
|
|
|
tag.append($('<span class="badge">'+stats.things+'</span>'));
|
|
|
|
|
|
|
|
var restore_btn=$('<button class="btn btn-default btn-xs pull-right"><span class="glyphicon glyphicon-ok"></button>');
|
|
|
|
restore_btn.bind('click',{'cat': cat},on_restore_cat_btn_click);
|
|
|
|
tag.append(restore_btn);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var deleted_things=[];
|
|
|
|
for (idx in cat.things) {
|
|
|
|
if (cat.things[idx].removed) {
|
|
|
|
deleted_things.push(cat.things[idx]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (deleted_things.length==0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
panel_title.bind('click',on_title_click);
|
|
|
|
tag.append($('<span class="badge">'+deleted_things.length+'</span>'));
|
|
|
|
|
|
|
|
var panel_collapse=$('<div class="panel-collapse collapse" role="tabpanel"></div>');
|
|
|
|
if (displayed) {
|
|
|
|
panel_collapse.addClass('in');
|
|
|
|
}
|
|
|
|
var ul=$('<ul class="list-group" data-cat="'+cat.name+'"></ul>');
|
|
|
|
for (idx in deleted_things) {
|
|
|
|
var li=$('<li class="list-group-item" data-label="'+deleted_things[idx].label+'">'+deleted_things[idx].label+'</li>');
|
|
|
|
var li_actions=$('<span class="actions pull-right"></span>');
|
|
|
|
|
|
|
|
var restore_el_btn=$('<button class="btn btn-default btn-xs pull-right"><span class="glyphicon glyphicon-ok"></button>');
|
|
|
|
restore_el_btn.bind('click',{'cat': cat,'thing': deleted_things[idx]},on_restore_thing_btn_click);
|
|
|
|
li_actions.append(restore_el_btn);
|
|
|
|
|
|
|
|
li.append(li_actions);
|
|
|
|
|
|
|
|
ul.append(li);
|
|
|
|
}
|
|
|
|
panel_collapse.append(ul);
|
|
|
|
panel.append(panel_collapse);
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#cats').append(panel);
|
|
|
|
}
|
|
|
|
|
|
|
|
on_back_to_scase_btn_click=function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
navbar_collapse_hide();
|
|
|
|
show_scase(e.data.scase);
|
|
|
|
}
|
|
|
|
|
2016-09-06 01:12:46 +02:00
|
|
|
/********************
|
|
|
|
* Show scases
|
|
|
|
*******************/
|
|
|
|
show_scases=function() {
|
2016-09-07 19:06:11 +02:00
|
|
|
clear_page('<h3>Vos valises</h3><ul class="list-group" id="scases"></ul>');
|
2016-09-06 01:12:46 +02:00
|
|
|
scases.each(function(idx,scase) {
|
2017-09-17 18:55:25 +02:00
|
|
|
if (scase.removed) {
|
|
|
|
return;
|
|
|
|
}
|
2016-09-07 19:06:11 +02:00
|
|
|
var stats=scase.stats();
|
|
|
|
var tag='<span class="count-tag pull-right">';
|
|
|
|
if (stats.things==stats.done) {
|
|
|
|
tag+='<span class="label label-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></span>';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
tag+='<span class="badge">'+stats.done+' / '+stats.things+'</span>';
|
|
|
|
}
|
|
|
|
tag+='</span>';
|
|
|
|
|
|
|
|
var li=$('<li class="list-group-item" data-name="'+scase.name+'"><span class="scase-name"><span class="glyphicon glyphicon-briefcase" aria-hidden="true"></span> '+scase.name+'</span>'+tag+'</li>');
|
2016-09-06 01:12:46 +02:00
|
|
|
li.bind('click',on_scase_click);
|
|
|
|
$('#scases').append(li);
|
|
|
|
});
|
|
|
|
show_menu('scases');
|
|
|
|
}
|
|
|
|
|
|
|
|
on_scase_click=function(event) {
|
|
|
|
var li=$(this);
|
|
|
|
var scase=scases.byName(li.data('name'));
|
|
|
|
show_scase(scase);
|
|
|
|
}
|
|
|
|
|
2017-09-17 18:55:25 +02:00
|
|
|
/********************
|
|
|
|
* Show scases trash
|
|
|
|
*******************/
|
|
|
|
show_scases_trash=function() {
|
|
|
|
clear_page('<h3>Corbeille <button class="btn btn-default btn-xs" id="back_btn"><span class="glyphicon glyphicon-arrow-left"></button></h3><ul class="list-group" id="scases"></ul>');
|
|
|
|
$('#content h3 #back_btn').bind('click', function(event) {
|
|
|
|
show_scases();
|
|
|
|
});
|
|
|
|
|
|
|
|
scases.each(function(idx,scase) {
|
|
|
|
if (!scase.removed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var stats=scase.stats();
|
|
|
|
var tags=$('<span class="count-tag pull-right"></span>');
|
|
|
|
tags.append('<span class="badge">'+stats.things+'</span>');
|
|
|
|
|
|
|
|
var restore_btn=$('<button class="btn btn-default btn-xs pull-right"><span class="glyphicon glyphicon-ok"></button>');
|
|
|
|
restore_btn.bind('click',{'scase': scase},on_restore_scase_btn_click);
|
|
|
|
tags.append(restore_btn);
|
|
|
|
|
|
|
|
var li=$('<li class="list-group-item" data-name="'+scase.name+'"><span class="scase-name"><span class="glyphicon glyphicon-briefcase" aria-hidden="true"></span> '+scase.name+'</span></li>');
|
|
|
|
li.append(tags);
|
|
|
|
$('#scases').append(li);
|
|
|
|
});
|
|
|
|
if ($('#scases li').length==0) {
|
|
|
|
$('#content').append('<p class="center">Aucune valise dans la corbeille.</p>');
|
|
|
|
}
|
|
|
|
show_menu('scases');
|
|
|
|
}
|
|
|
|
|
2017-09-17 20:04:30 +02:00
|
|
|
on_scases_trash_btn=function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
navbar_collapse_hide();
|
|
|
|
show_scases_trash();
|
|
|
|
}
|
|
|
|
|
2016-09-06 01:12:46 +02:00
|
|
|
clear_page=function(new_content) {
|
|
|
|
if (new_content) {
|
|
|
|
$('#content').html(new_content);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('#content').html('');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************
|
|
|
|
* Show menu
|
|
|
|
***********************/
|
|
|
|
show_menu=function(menu) {
|
|
|
|
$('.menu').css('display','none');
|
|
|
|
$('.menu-'+menu).css('display','block');
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************
|
|
|
|
* pleaseWaitDialog
|
|
|
|
*******************/
|
|
|
|
|
|
|
|
pleaseWaitShow=function() {
|
|
|
|
$('#please_wait_modal').modal('show');
|
|
|
|
}
|
|
|
|
|
|
|
|
pleaseWaitHide=function() {
|
|
|
|
$('#please_wait_modal').modal('hide');
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************
|
|
|
|
* Nav bars
|
|
|
|
****************/
|
|
|
|
navbar_collapse_hide=function() {
|
|
|
|
if ($('#navbar-top-collapse').hasClass('in')) {
|
|
|
|
$('#navbar-top-collapse').collapse('hide');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************
|
|
|
|
* Clear local data
|
|
|
|
********************/
|
|
|
|
clear_local_data=function() {
|
|
|
|
navbar_collapse_hide();
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.confirm(
|
|
|
|
"Suppression de toutes les données locales",
|
|
|
|
"Etes-vous sûre de vouloir supprimer les données locales (action irréversible) ?",
|
|
|
|
on_confirm_clear_local_data,
|
|
|
|
null
|
|
|
|
);
|
2016-09-06 01:12:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
on_confirm_clear_local_data=function(data) {
|
|
|
|
delete localStorage.scases;
|
|
|
|
location.reload();
|
|
|
|
}
|
|
|
|
|
2017-10-25 01:31:23 +02:00
|
|
|
/*******************************
|
|
|
|
* Import/Export local data
|
|
|
|
*******************************/
|
|
|
|
export_local_data=function() {
|
|
|
|
navbar_collapse_hide();
|
|
|
|
$('#export_local_data').attr('href','data:application/json;base64,' + btoa(JSON.stringify(scases.export())));
|
|
|
|
}
|
|
|
|
|
|
|
|
import_local_data=function() {
|
|
|
|
navbar_collapse_hide();
|
|
|
|
var input=$('<input type="file" accept="application/json">');
|
|
|
|
input.css('display', 'none');
|
|
|
|
input.bind('change',{'input': input},function(e) {
|
|
|
|
pleaseWaitShow();
|
|
|
|
var input=e.data.input;
|
|
|
|
var file=input.prop('files')[0];
|
|
|
|
if (file) {
|
|
|
|
var reader = new FileReader();
|
|
|
|
$(reader).bind('load',function(e) {
|
|
|
|
if ($.type(e.target.result)=='string') {
|
|
|
|
if (e.target.result.startsWith('data:application/json;base64,')) {
|
|
|
|
try {
|
|
|
|
json_data=atob(e.target.result.replace('data:application/json;base64,',''));
|
|
|
|
data=JSON.parse(json_data);
|
|
|
|
pleaseWaitHide();
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.confirm(
|
|
|
|
"Importation depuis un fichier",
|
|
|
|
"Etes-vous sûre de vouloir écraser vos données locales par celle issues de ce fichier ?",
|
|
|
|
function() {
|
|
|
|
scases.save();
|
|
|
|
var backData=localStorage.scases;
|
|
|
|
localStorage.scases=json_data;
|
|
|
|
scases=new SCaseList();
|
|
|
|
scases.loadFromLocalStorage(backData);
|
|
|
|
show_scases();
|
|
|
|
},
|
|
|
|
null
|
|
|
|
);
|
2017-10-25 01:31:23 +02:00
|
|
|
}
|
|
|
|
catch (e) {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify('Impossible de décodé le fichier.', "error", 5);
|
2017-10-25 01:31:23 +02:00
|
|
|
pleaseWaitHide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify('Fichier invalide.', "error", 5);
|
2017-10-25 01:31:23 +02:00
|
|
|
pleaseWaitHide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
reader.readAsDataURL(file);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$('body').append(input);
|
|
|
|
input[0].click();
|
|
|
|
}
|
|
|
|
|
2016-09-06 01:12:46 +02:00
|
|
|
/*********************
|
|
|
|
* Activate
|
|
|
|
*********************/
|
|
|
|
$( document ).ready( function() {
|
|
|
|
pleaseWaitShow();
|
|
|
|
if(typeof(localStorage)!=="undefined"){
|
|
|
|
scases=new SCaseList();
|
|
|
|
scases.loadFromLocalStorage();
|
|
|
|
show_scases();
|
|
|
|
}
|
|
|
|
else {
|
2024-09-13 17:43:01 +02:00
|
|
|
alertify.notify('Local storage not supported !', "error", 5);
|
2016-09-06 01:12:46 +02:00
|
|
|
pleaseWaitHide();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#clear_local_data').bind('click',clear_local_data);
|
2017-10-25 01:31:23 +02:00
|
|
|
$('#import_local_data').bind('click',import_local_data);
|
|
|
|
$('#export_local_data').bind('click',export_local_data);
|
2016-09-06 01:12:46 +02:00
|
|
|
|
|
|
|
$('#add_scase_btn').bind('click',on_add_scase_btn_click);
|
|
|
|
$('#add_scase_submit').bind('click',on_valid_add_scase_modal);
|
|
|
|
$("#add_scase_modal").on('shown.bs.modal',on_show_add_scase_modal);
|
|
|
|
$("#add_scase_modal").on('hidden.bs.modal',on_close_add_scase_modal);
|
|
|
|
$("#add_scase_modal form").bind('submit',on_valid_add_scase_modal);
|
|
|
|
|
2017-09-17 20:04:30 +02:00
|
|
|
$('#scases_trash_btn').bind('click',on_scases_trash_btn);
|
2017-09-17 18:55:25 +02:00
|
|
|
|
2016-09-06 01:12:46 +02:00
|
|
|
$('#rename_scase_btn').bind('click',on_rename_scase_btn_click);
|
|
|
|
$('#rename_scase_submit').bind('click',on_valid_rename_scase_modal);
|
|
|
|
$("#rename_scase_modal").on('shown.bs.modal',on_show_rename_scase_modal);
|
|
|
|
$("#rename_scase_modal").on('hidden.bs.modal',on_close_rename_scase_modal);
|
|
|
|
$("#rename_scase_modal form").bind('submit',on_valid_rename_scase_modal);
|
|
|
|
|
|
|
|
$('#copy_scase_btn').bind('click',on_copy_scase_btn_click);
|
|
|
|
$('#copy_scase_submit').bind('click',on_valid_copy_scase_modal);
|
|
|
|
$("#copy_scase_modal").on('shown.bs.modal',on_show_copy_scase_modal);
|
|
|
|
$("#copy_scase_modal").on('hidden.bs.modal',on_close_copy_scase_modal);
|
|
|
|
$("#copy_scase_modal form").bind('submit',on_valid_copy_scase_modal);
|
|
|
|
|
2016-09-07 00:30:25 +02:00
|
|
|
$('#reset_scase_btn').bind('click',on_reset_scase_btn_click);
|
2016-09-06 01:12:46 +02:00
|
|
|
$('#delete_scase_btn').bind('click',on_delete_scase_btn_click);
|
2017-09-17 18:55:25 +02:00
|
|
|
$('#scase_trash_btn').bind('click',on_scase_trash_btn_click);
|
2016-09-06 01:12:46 +02:00
|
|
|
|
|
|
|
$('#add_cat_btn').bind('click',on_add_cat_btn_click);
|
|
|
|
$('#add_cat_submit').bind('click',on_valid_add_cat_modal);
|
|
|
|
$("#add_cat_modal").on('shown.bs.modal',on_show_add_cat_modal);
|
|
|
|
$("#add_cat_modal").on('hidden.bs.modal',on_close_add_cat_modal);
|
|
|
|
$("#add_cat_modal form").bind('submit',on_valid_add_cat_modal);
|
|
|
|
|
|
|
|
$('#rename_cat_submit').bind('click',on_valid_rename_cat_modal);
|
|
|
|
$("#rename_cat_modal").on('shown.bs.modal',on_show_rename_cat_modal);
|
|
|
|
$("#rename_cat_modal").on('hidden.bs.modal',on_close_rename_cat_modal);
|
|
|
|
$("#rename_cat_modal form").bind('submit',on_valid_rename_cat_modal);
|
|
|
|
|
|
|
|
$('#back_to_scases').bind('click',on_back_to_scases_btn_click);
|
|
|
|
|
2017-09-17 12:18:45 +02:00
|
|
|
$('input.add_thing_label').bind('focus',on_add_thing_label_focus);
|
2016-09-06 01:12:46 +02:00
|
|
|
$('#add_thing_submit').bind('click',on_valid_add_thing_modal);
|
|
|
|
$("#add_thing_modal").on('shown.bs.modal',on_show_add_thing_modal);
|
|
|
|
$("#add_thing_modal").on('hidden.bs.modal',on_close_add_thing_modal);
|
|
|
|
$("#add_thing_modal form").bind('submit',on_valid_add_thing_modal);
|
|
|
|
|
2017-09-17 19:43:57 +02:00
|
|
|
$('#edit_thing_submit').bind('click',on_valid_edit_thing_modal);
|
|
|
|
$("#edit_thing_modal").on('shown.bs.modal',on_show_edit_thing_modal);
|
|
|
|
$("#edit_thing_modal").on('hidden.bs.modal',on_close_edit_thing_modal);
|
|
|
|
$("#edit_thing_modal form").bind('submit',on_valid_edit_thing_modal);
|
2016-09-06 01:12:46 +02:00
|
|
|
|
2016-09-07 19:07:05 +02:00
|
|
|
$('#app-name').bind('click', show_scases);
|
2016-09-06 01:12:46 +02:00
|
|
|
|
|
|
|
pleaseWaitHide();
|
|
|
|
});
|