var mcxNotificationWindowOpen = false; var mcxNotificationCnt = 0; function mcx_notice_connect(mcxUID) { this.mcxUID = mcxUID; this.noticeLoopID = ''; this.loopWait = 10000; this.getNotice = function () { //alert(_this.mcxUID); new get_single_notice(_this.mcxUID); } this.initNoticeConnect = function (_this) { _this.noticeLoopID = setInterval(_this.getNotice, _this.loopWait) } var _this = this; this.initNoticeConnect(_this); } /*--------------- PREP AND INITIATE RETRIEVAL OF LATEST NOTICE AND PASS TO AJAX CONNECTOR & RESULT HANDLER ---------------*/ function get_single_notice(mcxUID) { this.uBase = '/shared_php/mcx_notice_mgr.php?' this.uBase = this.uBase+'mcxUID='+escape(mcxUID); this.notice_handler = new get_single_notice_handler(); var _this = this; this.mcxNotice = new mcxlive(_this.uBase,_this.notice_handler); this.mcxNotice.mcx_make_request(); } /*--------------- HANDLE RETURNED CONTENT FROM PHP INTERFACE ---------------*/ function get_single_notice_handler() { var _this = this; this.handleRequest = function (requestCode,requestContent) { if(requestCode == 'ERR') { //mcx_app_pop_alert('Application Error', 'Error: Could not establish connection to server via MCXLive to retrieve notice. Try again later.'); return; } else { var errMarker = /^/; var blankMarker = /^no-new-notices<\/span>/; var retCont = requestContent; //if ( retCont.match(errMarker) ) if ( errMarker.test(retCont) ) { //alert(requestContent); return; } //else if( retCont.match(blankMarker) ) else if( blankMarker.test(retCont) ) { //alert(requestContent); return; } else { if( requestContent != 'no-new-notices') { //alert(requestContent); updateNotificationFeed(); new mcxDrawNotification(requestContent); } } } } } function mcxDrawNotification (mcxNotice) { this.noticeVisLoopInterval = 500; this.noticeVisLoopCnt = 0; this.noticeVisLoopID = 0; var mainEl = document.getElementById('AppBody'); var dv = document.createElement('div'); dv.setAttribute('id','mcxInlineNotice'); dv.setAttribute('class','inline-notice'); dv.style.left=(document.body.clientWidth - 320) + 'px'; var innerdv = document.createElement('div'); innerdv.style.padding='15px'; innerdv.style.height='60px'; innerdv.innerHTML=mcxNotice; var closerdv = document.createElement('div'); closerdv.style.paddingRight='25px'; closerdv.style.textAlign='right'; closerdv.innerHTML="close"; dv.appendChild(innerdv); dv.appendChild(closerdv); mainEl.appendChild(dv); this.removeNotification = function () { var mainEl = document.getElementById('AppBody'); var noticeEl = document.getElementById('mcxInlineNotice'); mainEl.removeChild(noticeEl); } this.checkVisibility = function () { if(_this.noticeVisLoopCnt == 10) { if(document.getElementById('mcxInlineNotice')){ mcxItemFader('mcxInlineNotice','out',_this.removeNotification); } clearInterval(_this.noticeVisLoopID); } else { _this.noticeVisLoopCnt++; } } var _this = this; this.initNoticeRemover = function(_this) { _this.noticeVisLoopID = setInterval(_this.checkVisibility, _this.noticeVisLoopInterval); } this.initNoticeRemover(_this); } function removeNotification() { var mainEl = document.getElementById('AppBody'); var noticeEl = document.getElementById('mcxInlineNotice'); mainEl.removeChild(noticeEl); } function resetNotificationIndicator() { return; var noticeFeedInd = 'mcxNoticeFeedInd'; // THE BOX CONTAINING THE ACTUALLY NOTICE COUNT var nf = document.getElementById(noticeFeedInd); nf.style.innerHTML = ''; nf.style.display = 'none'; mcxNotificationCnt = 0; } function updateNotificationFeed() { return; var noticeFeedInd = 'mcxNoticeFeedInd'; // THE BOX CONTAINING THE ACTUALLY NOTICE COUNT var nf = document.getElementById(noticeFeedInd); mcxNotificationCnt++; nf.style.innerHTML = ""+mcxNotificationCnt+""; nf.style.display = 'block'; } function toggleNotificationFeed() { if(mcxNotificationWindowOpen == false) { var noticeFeed = 'mcxNoticeFeedCont'; // THE BOX CONTAINING THE ACTUALLY RECENT NOTIFICATIONS var nf = document.getElementById(noticeFeed); nf.style.display = 'block'; mcxNotificationWindowOpen = true; resetNotificationIndicator(); } else { hideNotificationFeed(); } } function hideNotificationFeed() { var noticeFeed = 'mcxNoticeFeedCont'; // THE BOX CONTAINING THE ACTUALLY RECENT NOTIFICATIONS var nf = document.getElementById(noticeFeed); nf.style.display = 'none'; mcxNotificationWindowOpen = false; }