" : ' '); $("#" + this + " span label").html(s); setInterval("$('#" + this + " > span > i').animate({ height: 'toggle' });", 6000); }, error: hap.common.jsonError }); }); }, LiveTile: function (type, initdata) { this.data = initdata; this.type = type; this.id = (this.data.Group + this.data.Name).replace(/['\/\\\&\.\,\?\!\£\$\%\^\*\(\)@]*/gi, "").replace(/\s/gi, '_'); this.html = '' + this.data.Name + ''; this.Render = function () { if ($("#" + this.id).length > 0) return false; else { $("#" + this.data.Group).append($(this.html).attr("data-idname", this.data.Name)); if (hap.admin) { $("#" + this.id).on("contextmenu", function (e) { if ($(".editmode").length > 0) { var b = $(this).hasClass("selected"); $(".selected").removeClass("selected"); $("#sidebaredit").removeClass("show"); $("#contextbar").removeClass("selectactive"); if (!b) { $("#contextbar").addClass("selectactive"); $(this).addClass("selected"); } return false; } }); } return true; } } }, UpdateExchangeCalendarInfo: function (tileid, mailbox) { $("#" + tileid + " span label").html($.datepicker.formatDate('D d', new Date())); $.ajax({ url: hap.common.formatJSONUrl("~/api/livetiles/exchange/calendarinfo"), type: 'POST', dataType: 'json', data: '{ "Mailbox" : "' + mailbox + '" }', context: { tile: tileid, mb: mailbox }, contentType: 'application/JSON', success: function (data) { var s = ""; for (var i = 0; i < data.length; i++) s += data[i].Start + " - " + data[i].End + " " + data[i].Subject + " "; $("#" + this.tile + " span i").html(s); if (data.length > 0) $("#" + this.tile + " span i").attr("style", "background-image: url();"); setTimeout("hap.livetiles.UpdateExchangeCalendarInfo('" + this.tile + "', '" + this.mb + "');", 100000); }, error: hap.common.jsonError }); }, UpdateExchangeCalendar: function (tileid, mailbox) { $("#" + tileid + " span label").html($.datepicker.formatDate('D d', new Date())); $.ajax({ url: hap.common.formatJSONUrl("~/api/livetiles/exchange/calendar"), type: 'POST', dataType: 'json', data: '{ "Mailbox" : "' + mailbox + '" }', context: { tile: tileid, mb: mailbox }, contentType: 'application/JSON', success: function (data) { var s = ""; for (var i = 0; i < data.length; i++) s += data[i] + " "; $("#" + this.tile + " span i").html(s); if (data.length > 0) $("#" + this.tile + " span i").attr("style", "background-image: url();"); setTimeout("hap.livetiles.UpdateExchangeCalendar('" + this.tile + "', '" + this.mb + "');", 100000); }, error: hap.common.jsonError }); }, UpdateExchangeAppointments: function (tileid) { $("#" + tileid + " span label").html($.datepicker.formatDate('D d', new Date())); $.ajax({ url: hap.common.formatJSONUrl("~/api/livetiles/exchange/appointments"), type: 'GET', context: tileid, dataType: "json", contentType: 'application/JSON', success: function (data) { var s = ""; for (var i = 0; i < data.length; i++) s += data[i] + " "; $("#" + this + " span i").html(s); if (data.length > 0) $("#" + this + " span i").attr("style", "background-image: url();"); setTimeout("hap.livetiles.UpdateExchangeAppointments('" + this + "');", 100000); }, error: hap.common.jsonError }); }, UpdateBookings: function (tileid) { $.ajax({ type: 'POST', url: hap.common.formatJSONUrl("~/api/BookingSystem/Search"), dataType: 'json', context: tileid, data: '{ "Query": "' + hap.user + '" }', contentType: 'application/json', success: function (data) { var d = ""; for (var i = 0; i < data.length; i++) { var item = data[i]; d += (item.Date.match(/[0|1][0-9]\w\w\w/g) ? item.Date.substr(2, item.Date.length - 2) : item.Date) + ": " + item.Name + " in " + item.Room + " "; } $('#' + this + " span label").html(d); setTimeout("hap.livetiles.UpdateBookings('" + this + "');", 110000); }, error: hap.common.jsonError }); }, UpdateTickets: function (tileid) { $.ajax({ type: 'GET', url: hap.common.formatJSONUrl("~/api/HelpDesk/Tickets/Open" + (hap.hdadmin ? '' : ('/' + hap.user))), dataType: 'json', context: tileid, contentType: 'application/json', success: function (data) { var x = ""; var y = 0; data.reverse(); for (var i = 0; i < data.length; i++) { x += '' + (i + 1) + ':' + data[i].Subject + ' '; var read = false; for (var a = 0; a < data[i].ReadBy.split(",").length; a++) if ($.trim(data[i].ReadBy.split(",")[a].toLowerCase()) == hap.user.toLowerCase()) read = true; if (!read) y++; } if (data.length == 0) x = "No Open Tickets"; $("#" + this + " span label").html(x); if (y > 0) $("#" + this + " span i").animate({ width: 180 }, 500, function () { $(this).parent().children("label.count").html(y); }); else { $("#" + this + " span .count").html(""); $("#" + this + " span i").animate({ width: 227 }); } setTimeout("hap.livetiles.UpdateTickets('" + this + "');", 500000); }, error: hap.common.jsonError }); }, UpdateExchangeMail: function (tileid) { $.ajax({ url: hap.common.formatJSONUrl("~/api/livetiles/exchange/unread"), type: 'GET', context: tileid, dataType: "json", contentType: 'application/JSON', success: function (data) { if (data > 0) { $("#" + this + " span i").animate({ width: 60 }, 500, function () { $(this).parent().children("label").html(data); }); } else { $("#" + this + " span label").html(""); $("#" + this + " span i").animate({ width: 108 }); } setTimeout("hap.livetiles.UpdateExchangeMail('" + this + "');", 30000); }, error: hap.common.jsonError }); }, UpdateUptime: function (tileid, server) { var con = { tile: tileid, server: server }; $.ajax({ url: hap.common.formatJSONUrl("api/livetiles/uptime/" + server), type: 'GET', context: con, dataType: "json", contentType: 'application/JSON', success: function (data) { $("#" + this.tile + " span i").html(data); setTimeout("hap.livetiles.UpdateUptime('" + this.tile + "', '" + this.server + "');", 5000); }, error: hap.common.jsonError }); } } }; hap.livetiles.RegisterDefaultTiles(); $(function () { hap.header.Init(); if (hap.load > hap.loadtypes.none) { hap.help.Init(); hap.common.keepAlive(); } hap.common.makeSwitchs(); $(document).ajaxStart(function () { $("#hapLoader").addClass("go"); }).ajaxStop(function () { $("#hapLoader").removeClass("go"); }); }); $.fn.hapPopup = function (e) { if (!e) e = { buttons: [{ Text: "Close", Click: function () { $(this).parents(".hapPopup").hide(); return false; } }] }; else if (e == "close") { $(this).hide(); return this; } this.show(); if (!this.hasClass("hapPopup")) { this.addClass("hapPopup").contents().wrapAll('
'); if (this.attr("title")) this.find(".hapPopup-wrapperinner").prepend('
' + this.attr("title") + '
'); if (e) { if (e.buttons) { var a = $(''); for (var i = 0; i < e.buttons.length; i++) $("").click(e.buttons[i].Click).appendTo(a); this.find(".hapPopup-wrapperinner").append(a); this.find('button').button(); } } this.find('.hapPopup-content').css('max-height', parseInt($("#hapContent").css("min-height").replace(/px/gi, "")) - 200); } return this; };}