lemonldap-ng/lemonldap-ng-portal/site/coffee/favapps.coffee
2019-04-26 22:58:53 +02:00

38 lines
918 B
CoffeeScript

###
LemonLDAP::NG Favorite Applications script
###
# FavApps function (launched by "star" icon)
FavApps = (star) ->
$.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: (resp) ->
if resp.error
console.log 'Max number reached'
switchStar star, 0
else if resp.error == 0
console.log 'Not authorized'
switchStar star, 0
else if resp.result
console.log 'App. registered'
switchStar star, 1
else
console.log 'App. unregistered'
switchStar star, 0
error: switchStar star, '0'
switchStar = (star, status) ->
star.attr('src', "#{window.staticPrefix}common/icons/star#{status}.png")
# Switch "star" events
$(document).ready ->
$('body').on 'click', '.star', () -> FavApps $(this)