lemonldap-ng/lemonldap-ng-portal/site/htdocs/static/common/js/favapps.js
2019-04-17 23:15:03 +02:00

50 lines
1.1 KiB
JavaScript

// Generated by CoffeeScript 1.12.7
/*
LemonLDAP::NG Favorite Applications script
*/
(function() {
var FavApps, switchStar;
FavApps = function(star, appuri) {
return $.ajax({
type: "POST",
url: portal + "favapps",
data: {
app: appuri
},
dataType: 'json',
success: function(resp) {
if (resp.error) {
return switchStar(star, '0');
} else if (resp.result) {
return switchStar(star, '1');
} else {
return switchStar(star, '-1');
}
}
});
};
switchStar = function(star, status) {
if (status === '1') {
console.log('OK');
return star.attr('src', 'static/common/icons/star1.png');
} else if (status === '-1') {
console.log('NOK');
return star.attr('src', 'static/common/icons/star0.png');
} else {
console.log('Error');
return star.attr('src', 'static/common/icons/star0.png');
}
};
$(document).ready(function() {
return $('body').on('click', '.star', function() {
return FavApps($(this), $(this).attr('appuri'));
});
});
}).call(this);