45 lines
1.1 KiB
CoffeeScript
45 lines
1.1 KiB
CoffeeScript
###
|
|
LemonLDAP::NG Favorite Applications script
|
|
###
|
|
|
|
# FavApps function (launched by "star" icon)
|
|
FavApps = (star, appuri) ->
|
|
$.ajax
|
|
type: "POST"
|
|
url: "#{portal}favapps"
|
|
data:
|
|
app: appuri
|
|
logo: logo
|
|
title: title
|
|
dataType: 'json'
|
|
#error: star.attr('src', 'static/common/icons/star0.png')
|
|
success: (resp) ->
|
|
if resp.error
|
|
#console.log 'Error'
|
|
#star.attr('src', 'static/common/icons/star0.png')
|
|
switchStar star, '0'
|
|
else if resp.result
|
|
#console.log 'OK'
|
|
#star.attr('src', 'static/common/icons/star1.png')
|
|
switchStar star, '1'
|
|
else
|
|
#console.log 'NOK'
|
|
#star.attr('src', 'static/common/icons/star0.png')
|
|
switchStar star, '-1'
|
|
#error: switchStar star, '0'
|
|
|
|
switchStar = (star, status) ->
|
|
if status == '1'
|
|
console.log 'OK'
|
|
star.attr('src', 'static/common/icons/star1.png')
|
|
else if status == '-1'
|
|
console.log 'NOK'
|
|
star.attr('src', 'static/common/icons/star0.png')
|
|
else
|
|
console.log 'Error'
|
|
star.attr('src', 'static/common/icons/star0.png')
|
|
|
|
# Switch "star" events
|
|
$(document).ready ->
|
|
$('body').on 'click', '.star', () -> FavApps $(this), ( $(this).attr 'appuri' )
|