// Absolute Live Support .NET // Copyright(c) XIGLA SOFTWARE // http://www.xigla.com (function( $ ){ $.widget( "dorian.blinky", { options: { "onRefresh": function( status ){}, "onActive": function(){}, "onInactive": function(){}, "onOpen": function( url, height, width ){ var w = 640, h = 480; if (document.all || document.layers) { w = screen.availWidth; h = screen.availHeight; } var leftPos = (w - width) / 2, topPos = (h - height) / 2; xlaALSwindow = window.open(url,"ALSRoom","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=" + width + ",height=" + height + ",top=" + topPos + ",left=" + leftPos); xlaALSwindow.focus(); } }, _create: function() { var elem = this.element; var opts = this.options; opts.onActive = $.proxy(opts.onActive, elem); opts.onInactive = $.proxy(opts.onInactive, elem); elem.attr("data-blinky-status", "false"); this._status(); this._setIntervalWithContext(this._status, 20000, this); }, _status: function() { var nt = String(Math.random()).substr(2, 10); var status = '/alsx/als_widget.aspx?u=&d=&getstatus=text&nt=' + nt; var ths = this; $.ajax({ url: status, method: "GET" }).done(function(data){ var status = false; var match = data.match(/blinky(.+?)\.gif/); if(match) { // make the magic happen here if(match[1] == "on") status = true; } ths.element.attr("data-blinky-status", String(status)); ths.options.onRefresh(status); if(status) { ths.options.onActive(); ths.element.on('click', $.proxy(ths.open,ths)); } else { ths.options.onInactive(); ths.element.on('click', $.proxy(ths.open,ths)); } }).fail(function(){ ths.options.onInactive(); ths.element.off('click'); }); }, _setIntervalWithContext: function( func, delay, context ) { return setInterval(function(){ func.call(context); }, delay); }, open: function() { var url = '/alsx/UserPreChat.aspx?ref=&d=&u=&bypass='; var height = 700; var width = 560; this.options.onOpen(url, height, width); } }); })( jQuery );