### LemonLDAP::NG Favorite Applications script ### # FavApps function (launched by "star" icon) FavApps = (star) -> $.ajax type: "POST" url: "#{portal}favapps" data: app: star.attr 'appuri' logo: star.attr 'logo' desc: star.attr 'desc' title: star.attr 'title' 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)