(function(){function e(e){$.extend(this,e);if(!("pollInterval"in this)){this.pollInterval=u8.session.webConfigValues.getInt("Jobs.PollingInterval",0)}this._adapter=null}$.extend(e.prototype,{create:function(e){$.extend(this,e)},setAdapter:function(e){if(this.adapter){this.adapter.onReminderClick.unbind(this.jobName)}this.adapter=e;if(e){e.updateReminder(this.reminderName,{enable:false});e.onReminderClick.bind(this._onReminderClick.bind(this),this.jobName)}},poll:function(e){if(this.adapter&&this.adapter.isReminderEnabled(this.reminderName)){return false}e.jobNames.push(this.jobName)},update:function(e){if(!e||e.newRecords<=0){return}if(this.adapter){this.adapter.updateReminder(this.reminderName,{text:e.newRecordsMessage,enable:true})}var i=this._buildNotification(e);u8.services.notification.write(i)},_buildNotification:function(e){var i=null,t=this.infoAreaId,n=e.newRecordsMessage,s="<a href='javascript:void(0)' onclick='"+this._onReminderLinkClick.bind(this).html()+"'>"+n+"</a>";if(t=="TD"){i={linkText:e.todoType,linkAdditionalText:"("+e.todoStatus+")",description:e.todoText,image:"u8-img-infoarea-td"}}else if(t=="ER"){i={linkText:e.reminderSubject,image:"u8-img-infoarea-er"}}else if(t=="MD"){i={linkText:e.messageType,linkAdditionalText:"("+e.ofRep+")",description:e.messageText,image:"u8-img-infoarea-md"}}else if(t=="A1"){i={linkText:e.TasksSubject,image:"u8-img-infoarea-a1"}}i=$.extend({},{text:n,html:s,severity:300,show:this.showNotification,facility:e.notificationFacility||this.notificationFacility,data:{infoAreaId:this.infoAreaId,newRecords:e.newRecords,uid:e.uid}},i);return i},_onReminderExecute:function(e){var i=this.adapter.isReminderEnabled(this.reminderName);if(this.adapter){this.adapter.updateReminder(this.reminderName,{enable:false})}switch(this.reminderName){case"Todos":if(i){e.options.parameters={DEFAULTVALUES:'18:"0"'}}break;case"Messages":if(i){var t=this.lastPoll?this.lastPoll:new Date;e.options.parameters={DEFAULTVALUES:'6:"'+u8.services.typeConverter.dateToString(t)+'"'+';7:"'+u8.services.typeConverter.timeToString(t)+'"'}}break;default:break}},_onReminderClick:function(e,i){if(this.reminderName!=i.name){return}this._onReminderExecute(i)},_onReminderLinkClick:function(e){e.stopPropagation();e.preventDefault();if(this.adapter){this.adapter.executeReminder({reminderName:this.reminderName,job:this,elEvent:e})}}});function i(e){$.extend(this,e);if(!("pollInterval"in this)){this.pollInterval=u8.session.webConfigValues.getInt("Jobs.PollingInterval",0)}}$.extend(i.prototype,{create:function(){},setAdapter:function(){},poll:function(e){e.jobNames.push("QueryResults");return true},update:function(e){if(!e){return}this._showNewQueryResults(e.items)},_showNewQueryResults:function(e){if(!e||0>=e.length){return}u8.using({texts:"XSelDefineText"},i);function i(){var i=$t("TXT_XSelDefineText_62");if(!i){return}for(var t=0;t<e.length;t++){var n=e[t];var s="<a href='javascript:void(0)' onclick=\"u8.services.actions.executeDefault({ infoAreaId:'Q1', recordId:'"+n.recordId+"'}, { createNewTab: true, elSource: this, elWindow: u8.application.getWorkWindow() }); return false;\">"+u8.Base.Html.escape(n.tableCaption)+" </a>";var a=i.format({QUERYRESULTLINK:s,QUERYRESULTNAME:n.tableCaption});u8.services.notification.write({text:a,contentType:"text/html",severity:300,duration:0,facility:"QueryResults",show:true})}}}});function t(e){$.extend(this,e);if(!("pollInterval"in this)){this.pollInterval=u8.session.webConfigValues.getInt("Maintenance.CheckForSystemLocksInterval",0)}}function n(e){$.extend(this,e);if(!("pollInterval"in this)){this.pollInterval=u8.session.webConfigValues.getInt("Maintenance.CheckForSystemLocksInterval",0)}}$.extend(t.prototype,{create:function(){},setAdapter:function(){},poll:function(e){e.jobNames.push("SystemLocks");return true},update:function(){}});$.extend(n.prototype,{create:function(){},setAdapter:function(){},poll:function(e){e.jobNames.push("GlobalWarning");return true},update:function(e){}});u8.services.ready("jobs",function(){u8.services.jobs.addPolledJob("Messages",new e({jobName:"Messages",reminderName:"Messages",infoAreaId:"MD",notificationFacility:"Messages"}));u8.services.jobs.addPolledJob("Reminders",new e({jobName:"Reminders",reminderName:"Reminders",infoAreaId:"ER",notificationFacility:"Reminders"}));u8.services.jobs.addPolledJob("Todos",new e({jobName:"Todos",reminderName:"Todos",infoAreaId:"TD",notificationFacility:"Todos"}));u8.services.jobs.addPolledJob("Tasks",new e({jobName:"Tasks",reminderName:"Tasks",infoAreaId:"A1",notificationFacility:"Tasks"}));u8.services.jobs.addPolledJob("QueryResults",new i);u8.services.jobs.addPolledJob("SystemLocks",new t);u8.services.jobs.addPolledJob("GlobalWarning",new n)})})();