/* The shape of the json string is : { "body":"Grande salle de réunion formation administrati...", "dat":"16:50", "from":"", "id":"00000000000ac979", "subject":"Formation UNIX", "type":"Alarm" } */ var defaultMessage = ''; var withScoll = "false"; var doCreateInformationPanelFunction = 'javascript:doCreateInformationPanel();' var link = 'Créer'; defaultMessage = '
' + defaultMessage + '' + link + '
'; var objectDisplayFunction = new Object(); //Construction of the information to be displayed . Objects : Alarm and InformationPanel ... objectDisplayFunction["Alarm"] = function(information) { // attributes var infoId = "'" + information.id + "'"; var infoType = "'" + information.type + "'"; var infoBody = decodeURIComponent(information.body); var infoSubject = decodeURIComponent(information.subject); var infoDate = information.dat; // functions var openPopupFunction = 'javascript:openPopup(' + infoId + ',' + infoType + ');' var doReprogramAlarmFunction = 'javascript:doReprogramAlarm(' + infoId + ');' var doDeleteAlarmFunction = 'javascript:doDeleteAlarm(' + infoId + ');' var doReadInformationPanelFunction = 'javascript:doReadInformationPanel(' + infoId + ');' // links var link_1 = 'Re-programmer'; var link_2 = 'Supprimer'; // informations var informationToDisplay = '
' + infoDate + ' - ' + infoSubject + '' + link_1 + '
' + infoBody +'' + link_2 + '
'; informationToDisplay = addCommonElement(informationToDisplay, ''); //Save withScoll withScoll = information.refresh; return informationToDisplay; }; objectDisplayFunction["InformationPanel"] = function(information) { // attributes var infoId = "'" + information.id + "'"; var infoType = "'" + information.type + "'"; var infoBody = decodeURIComponent(information.body); var infoSubject = decodeURIComponent(information.subject); var infoDate = information.dat; // functions var openPopupFunction = 'javascript:openPopup(' + infoId + ',' + infoType + ');' var doReprogramAlarmFunction = 'javascript:doReprogramAlarm(' + infoId + ');' var doDeleteAlarmFunction = 'javascript:doDeleteAlarm(' + infoId + ');' var doReadInformationPanelFunction = 'javascript:doReadInformationPanel(' + infoId + ');' var doCreateInformationPanelFunction = 'javascript:doCreateInformationPanel();' // links and informations var link_1 = 'Créer'; var link_2 = 'Marquer comme lu'; informationToDisplay = '
' + infoDate + ' - ' + infoSubject + '' + link_1 + '
' + infoBody +'' + link_2 + '
'; informationToDisplay = addCommonElement(informationToDisplay, ''); //Save withScoll withScoll = information.refresh; return informationToDisplay; }; function getInformationToDisplay(information){ return ((information.type != null) && (information.type != '')) ? objectDisplayFunction[information.type](information) : ''; } function displayInformationOnInfoBar(info){ $("#infobar_information").html(info); if (withScoll == "true"){ $("#infobar_information").slideUp("normal"); $("#infobar_information").slideDown("normal"); } } function getInfoBarInformation(forceupdate) { if ((forceupdate == null) || (typeof forceupdate == 'undefined')){ forceupdate = "false"; } else { forceupdate = "true"; } $.ajax({ url:"/galaxie/get_infobar_information.fl?forceupdate=" + forceupdate, dataType: 'json', success: analyseResponse, type: "POST", timeout: 20000 }); function analyseResponse(information) { if ((information != null) && (information.type != null) && (information.type != '')) { var informationToDisplay = getInformationToDisplay(information); if (informationToDisplay == '') displayInformationOnInfoBar(addCommonElement(defaultMessage)); else displayInformationOnInfoBar(getInformationToDisplay(information)); } else { displayInformationOnInfoBar(addCommonElement(defaultMessage)); } } } function addCommonElement(info, imag){ if (imag == null) imag = ''; contentHTML = '
'+ imag + '' + info + '
'; return contentHTML; } $.setupJMPopups({ screenLockerBackground: "#222222", screenLockerOpacity: "0.3" }); function openPopup(id, type) { if ((id == null) || (type == null)) return; if (type == "Alarm") { namePopup = "alarmPopup"; urlPopup = "/galaxie/open_popup_alarm.fl?id=" + id; openAjaxPopup(namePopup, urlPopup); } else if (type == "InformationPanel") { //modification namePopup = "informationpanelPopup"; urlPopup = "/galaxie/open_popup_informationpanel.fl?id=" + id; openJSPopup(namePopup, urlPopup); } } function openAjaxPopup(namePopup, urlPopup){ jQuery.openPopupLayer({ name: namePopup, width: 800, height: 250, url: urlPopup, cache: true, success: function (data) { }, error: function () { alert("Erreur lors de l'ouverture de la popup !"); } }); } function openJSPopup(namePopup, urlPopup){ var win = window.open(urlPopup, namePopup, 'menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes,width=850,height=650'); } function doDeleteAlarm(id) { urlAjax("/galaxie/delete_alarm_shortcut.fl?id=" + id); } function doReprogramAlarm(id, newdate) { url = "/galaxie/reprogram_alarm_shortcut.fl?id=" + id if (newdate != null) url = url + "&newdate=" + newdate; urlAjax(url); } function doReadInformationPanel(id) { urlAjax("/galaxie/mark_read_informationpanel.fl?id=" + id); } function doCreateInformationPanel() { namePopup = "informationpanelPopup"; urlPopup = "/galaxie/open_popup_informationpanel.fl"; openJSPopup(namePopup, urlPopup); } function urlAjax(url){ $.ajax({ url: url, dataType:'text', async: false, success: analyseResponse }); function analyseResponse(response) { if (response != null){ switch(response) { case 'alarm_ok_delete': //displayMessage('L\'alarme a été bien supprimée'); break; case 'alarm_no_delete': displayMessage('Erreur lors de la suppression de l\'alarme'); break; case 'alarm_ok_reprogram': //displayMessage('L\'alarme a été reprogrammée'); break; case 'alarm_no_reprogram': displayMessage('Erreur lors de la reprogrammation de l\'alarme'); break; case 'informationpabel_ok_read': //displayMessage('Le panneau d\'information a été marqué comme lu'); break; case 'informationpanel_no_read': displayMessage('Erreur lors de la mise en lecture du panneau d\'information'); break; default: break; } } } //forcer la mise à jour des infos getInfoBarInformation("force_update"); } function displayMessage(message) { window.alert(message); }