70 lines
1.7 KiB
JavaScript
70 lines
1.7 KiB
JavaScript
// Generated by CoffeeScript 1.12.7
|
|
|
|
/*
|
|
LemonLDAP::NG Favorite Applications script
|
|
*/
|
|
|
|
(function() {
|
|
var FavApps, ResetFavApps, switchStar;
|
|
|
|
FavApps = function(star) {
|
|
return $.ajax({
|
|
type: "POST",
|
|
url: portal + "favapps",
|
|
data: {
|
|
id: star.attr('aid'),
|
|
uri: star.attr('uri'),
|
|
name: star.attr('name'),
|
|
logo: star.attr('logo'),
|
|
desc: star.attr('desc')
|
|
},
|
|
dataType: 'json',
|
|
success: function(resp) {
|
|
if (resp.error) {
|
|
console.log('Max number reached');
|
|
return switchStar(star, 0);
|
|
} else if (resp.error === 0) {
|
|
console.log('Not authorized');
|
|
return switchStar(star, 0);
|
|
} else if (resp.result) {
|
|
console.log('App. registered');
|
|
return switchStar(star, 1);
|
|
} else {
|
|
console.log('App. unregistered');
|
|
return switchStar(star, 0);
|
|
}
|
|
},
|
|
error: switchStar(star, '0')
|
|
});
|
|
};
|
|
|
|
ResetFavApps = function() {
|
|
return $.ajax({
|
|
type: "DELETE",
|
|
url: portal + "favapps",
|
|
success: function(resp) {
|
|
if (resp.result) {
|
|
console.log('Favorite Apps. reset');
|
|
return window.location.reload();
|
|
} else {
|
|
return console.log('Error');
|
|
}
|
|
}
|
|
});
|
|
};
|
|
|
|
switchStar = function(star, status) {
|
|
return star.attr('src', window.staticPrefix + "common/icons/star" + status + ".png");
|
|
};
|
|
|
|
$(document).ready(function() {
|
|
$('body').on('click', '.star', function() {
|
|
return FavApps($(this));
|
|
});
|
|
return $('#reset').on('click', function() {
|
|
return ResetFavApps();
|
|
});
|
|
});
|
|
|
|
}).call(this);
|