/*HAP.Web.JS.js - Copyright © 2012 nb development - Version 2 */if (hap == null) { var hap = { root: "/", user: "", admin: false, bsadmin: false, hdadmin: false, common: { jsonError: function (xhr, ajaxOptions, thrownError) { try { if (xhr.responseText.match(/\'); $("
" + jQuery.parseJSON(xhr.responseText).Message + "
This error has been logged on the server's event log
").appendTo("#errorlist"); setTimeout("hap.common.clearError();", 10000); try { console.log(xhr.responseText); } catch (ex) { }; } } catch (e) { if (thrownError != "") alert(thrownError); } }, formatJSONUrl: function (url) { var d = new Date().valueOf(); return hap.common.resolveUrl(url) + '?' + d; }, clearError: function () { $($("#errorlist").children()[0]).animate({ height: 0 }, 500, function () { $(this).remove(); }); }, resolveUrl: function (virtual) { return virtual.replace(/~\//g, hap.root); }, keepAlive: function () { setInterval(function () { $.ajax({ url: hap.common.formatJSONUrl("~/api/test/"), type: 'GET', success: function (data) { }, error: hap.common.jsonError }); }, 60000); }, getLocal: function (e) { for (var i = 0; i < hap.localization.length; i++) if (hap.localization[i].name == e) return unescape(hap.localization[i].value.replace(/\\\\/g, "\\")); } }, header: { StopClose: false, StopUClose: false, WaitInit: false, Init: function () { if (window.location.pathname.toLowerCase() != hap.root.toLowerCase() && window.location.pathname.toLowerCase() != hap.common.resolveUrl('~/login.aspx').toLowerCase()) { $("#hapTitleMore").click(function () { return false; }); $.ajax({ url: hap.common.formatJSONUrl('~/api/livetiles/'), type: 'GET', dataType: "json", contentType: 'application/JSON', success: function (data) { $("#hapContent").click(function () { if ($("#hapHeaderMore").css('display') == 'block' && !hap.header.StopClose) $("#hapHeaderMore").animate({ height: 'toggle' }); hap.header.StopClose = false; }).append('
'); $("#hapHeaderMore").click(function () { hap.header.StopClose = true; }).mouseleave(function () { if (!hap.header.WaitInit) $("#hapHeaderMore").animate({ height: 'toggle' }); }); $("#hapTitleMore").click(function () { hap.header.WaitInit = true; $("#hapHeaderMore").animate({ height: 'toggle' }, 500, 'linear', function () { hap.header.WaitInit = false; }); return false; }).trigger("click"); for (var i = 0; i < data.length; i++) { if (data[i].Group == 'Me') continue; var s = "
" + unescape(data[i].GroupName) + "
"; if (i == 0) s += '' + hap.common.getLocal("home") + ''; for (var i2 = 0; i2 < data[i].Tiles.length; i2++) { if (data[i].Tiles[i2].Url.substr(0, 1) != "#") s += '' + data[i].Tiles[i2].Name + ''; } s += "
"; $("#hapHeaderMore > .tiles").append(s); } }, error: hap.common.jsonError }); $("#hapTitleMore").attr("title", hap.common.getLocal("more")); $("#hapHeader").css('right', $("#hapUserTitle").width() + 30 + 'px'); } else { $("#hapHeader").hide(); } $("#hapUserTitle").click(function () { $("#hapUserMenu").animate({ height: 'toggle' }); return false; }).trigger("click"); $("#hapUserMenu").click(function () { hap.header.StopUClose = true; }); $("#hapContent").click(function () { if (!hap.header.StopUClose && $("#hapUserMenu").css('display') == 'block') $("#hapUserMenu").animate({ height: 'toggle' }); hap.header.StopUClose = false; }); } }, loadtypes : { none: 0, help: 1, full: 2 }, load: 2, help: { Init: function () { if (document.getElementById("helpbox") != null) return; $('
Loading
').appendTo(document.body); $("#helpbox").dialog({ autoOpen: false }); }, Load: function (path) { $("#helpbox").dialog({ autoOpen: true, modal: true, height: 600, width: 990, buttons: { "Close": function () { $(this).dialog("close"); } } }); $("#helpbox .content").html("Loading..."); $.ajax({ type: 'GET', url: hap.common.resolveUrl('~/api/Help/' + path), dataType: 'json', contentType: 'application/json', success: function (data) { $("#helpbox .content").html(data); }, error: hap.common.jsonError }); } }, localization: [{ name: 'homeaccessplus', value: 'Home Access Plus+' }, { name: 'home', value: 'Home' }, { name: 'editprofile', value: 'Edit Profile' }, { name: 'loading', value: 'Loading' }, { name: 'help', value: 'Help' }, { name: 'more', value: 'More' }, { name: 'name', value: 'Name' }, { name: 'of', value: 'of' }, { name: 'to', value: 'to' }, { name: 'items', value: 'items' }, { name: 'username', value: 'Username' }, { name: 'close', value: 'Close' }, { name: 'openmenu', value: 'Open Menu' }, { name: 'search', value: 'Search' }, { name: 'password', value: 'Password' }, { name: 'errordetails', value: 'Error Details' }, { name: 'bookingsystem/bookingsystem', value: 'Booking System' }, { name: 'bookingsystem/quicksearch', value: 'Search for: ' }, { name: 'timetable/my', value: 'My Timetable' }, { name: 'helpdesk/daystoindex', value: 'Days to Index' }, { name: 'helpdesk/refreshstats', value: 'Refresh Stats' }, { name: 'helpdesk/stats', value: 'Stats' }, { name: 'helpdesk/helpdesk', value: 'Help Desk' }, { name: 'helpdesk/priority', value: 'Priority' }, { name: 'helpdesk/high', value: 'High' }, { name: 'helpdesk/low', value: 'Low' }, { name: 'helpdesk/normal', value: 'Normal' }, { name: 'helpdesk/makeaware', value: 'Make aware' }, { name: 'helpdesk/csloun', value: '(comma seperated list of usernames)' }, { name: 'helpdesk/markasfaq', value: 'Mark as FAQ' }, { name: 'helpdesk/fixed', value: 'Fixed' }, { name: 'helpdesk/note', value: 'Note' }, { name: 'helpdesk/faqs', value: 'FAQs' }, { name: 'helpdesk/opentickets', value: 'Open Tickets' }, { name: 'helpdesk/newtickets', value: 'New Ticket' }, { name: 'helpdesk/closedtickets', value: 'Closed Tickets' }, { name: 'helpdesk/issue', value: 'Issue' }, { name: 'helpdesk/room', value: 'Room' }, { name: 'helpdesk/subject', value: 'Subject' }, { name: 'helpdesk/userinter', value: 'User Interaction Requested' }, { name: 'tracker/archive', value: 'Archive' }, { name: 'tracker/logontracker', value: 'Logon Tracker' }, { name: 'tracker/webtracker', value: 'Web Tracker' }, { name: 'tracker/livelogons', value: 'Live Logons' }, { name: 'tracker/weblogs', value: 'Web Logs' }, { name: 'tracker/historiclogs', value: 'Historic Logs' }, { name: 'tracker/logs', value: 'Logs' }, { name: 'myfiles/myfiles', value: 'My Files' }, { name: 'myfiles/open', value: 'Open' }, { name: 'myfiles/download', value: 'Download' }, { name: 'myfiles/rename', value: 'Rename' }, { name: 'myfiles/only1', value: 'This only works on 1 item' }, { name: 'myfiles/create', value: 'Create' }, { name: 'myfiles/mydrives', value: 'My Drives' }, { name: 'myfiles/filefolder', value: 'File Folder' }, { name: 'myfiles/waiting', value: 'Waiting' }, { name: 'myfiles/renaming', value: 'Renaming' }, { name: 'myfiles/folderexists1', value: 'The folder' }, { name: 'myfiles/checking', value: 'Checking' }, { name: 'myfiles/folderexists2', value: 'already exists!' }, { name: 'myfiles/merge', value: 'Do you want to merge this folder?' }, { name: 'myfiles/cut', value: 'Cut' }, { name: 'myfiles/paste', value: 'Paste' }, { name: 'myfiles/copy/copy', value: 'Copy' }, { name: 'myfiles/copy/copying', value: 'Copying' }, { name: 'myfiles/copy/copyingitem1', value: 'Copying item' }, { name: 'myfiles/copy/error1', value: 'An Error has occured while copying' }, { name: 'myfiles/copy/error2', value: 'do you want to Continue?' }, { name: 'myfiles/move/move', value: 'Move' }, { name: 'myfiles/move/moving', value: 'Moving' }, { name: 'myfiles/move/movingitem1', value: 'Moving item' }, { name: 'myfiles/move/error1', value: 'An Error has occured while moving' }, { name: 'myfiles/move/error2', value: 'do you want to Continue?' }, { name: 'myfiles/move/question1', value: 'Are you sure you want to move:' }, { name: 'myfiles/downloadwarning', value: 'You are about to download this file. If you wish to edit this file, remember to\r\nsave it to your computer and upload it back once you have finished!' }, { name: 'myfiles/upload/upload', value: 'Upload' }, { name: 'myfiles/upload/uploading', value: 'Uploading' }, { name: 'myfiles/upload/uploadprogress', value: 'Upload Progress' }, { name: 'myfiles/upload/filetypewarning', value: 'is an restricted file type\r\n\r\nYou can only upload' }, { name: 'myfiles/upload/folderwarning', value: 'You cannot upload the folder %\r\n\r\nTry compressing it into a ZIP File first' }, { name: 'myfiles/upload/filetypeerror', value: 'You have attempted to upload a restricted file type!' }, { name: 'myfiles/upload/filesizewarning', value: 'is Too Big to Upload!' }, { name: 'myfiles/upload/fileexists1', value: 'The file' }, { name: 'myfiles/upload/fileexists2', value: 'already exists\r\n\r\nDo you want to overwrite it?' }, { name: 'myfiles/upload/failed', value: ' has Failed!' }, { name: 'myfiles/upload/note', value: 'This page will refresh when it has finished' }, { name: 'myfiles/delete/question1', value: 'Are you sure you want to delete:' }, { name: 'myfiles/delete/delete', value: 'Delete' }, { name: 'myfiles/delete/deletingitem1', value: 'Deleting item' }, { name: 'myfiles/zip/zipingitem1', value: 'Zipping item' }, { name: 'myfiles/zip/question1', value: 'What do you want to call your Zip File?' }, { name: 'myfiles/zip/question2', value: 'FileName:' }, { name: 'myfiles/zip/zip', value: 'ZIP' }, { name: 'myfiles/unzip/unzipping', value: 'Unzipping' }, { name: 'myfiles/unzip/error1', value: 'An Error has occured while unzipping' }, { name: 'myfiles/unzip/error2', value: 'do you want to Continue?' }, { name: 'myfiles/unzip/question1', value: 'Are you sure you want to unzip:' }, { name: 'myfiles/unzip/unzip', value: 'UnZIP' }, { name: 'myfiles/size', value: 'Size' }, { name: 'myfiles/type', value: 'Type' }, { name: 'myfiles/location', value: 'Location' }, { name: 'myfiles/contains', value: 'Contains' }, { name: 'myfiles/created', value: 'Created' }, { name: 'myfiles/typeoffile', value: 'Type of File' }, { name: 'myfiles/modified', value: 'Modified' }, { name: 'myfiles/accessed', value: 'Accessed' }, { name: 'myfiles/extension', value: 'Extension' }, { name: 'myfiles/newfolder', value: 'New Folder' }, { name: 'myfiles/tiles', value: 'Tiles' }, { name: 'myfiles/smallicons', value: 'Small Icons' }, { name: 'myfiles/mediumicons', value: 'Medium Icons' }, { name: 'myfiles/largeicons', value: 'Large Icons' }, { name: 'myfiles/details', value: 'Details' }, { name: 'myfiles/view', value: 'View' }, { name: 'myfiles/properties', value: 'Properties' }, { name: 'myfiles/preview', value: 'Preview' }, { name: 'myfiles/progress', value: 'Progress' }, { name: 'myfiles/sendto/googledocs', value: 'Send to Google Docs' }, { name: 'myfiles/sendto/googlesignin', value: 'Sign into Google Docs' }, { name: 'myfiles/sendto/googlesignin2', value: 'Once you have signed into Google, HAP+ will upload the selected file to your Google Docs' }, { name: 'myfiles/sendto/skydrive', value: 'Send to SkyDrive' }, { name: 'myfiles/homework/path', value: 'Path:' }, { name: 'myfiles/homework/homework', value: 'My Files - Homework' }, { name: 'myfiles/homework/new', value: 'New' }, { name: 'myfiles/homework/edit', value: 'Edit' }, { name: 'myfiles/homework/remove', value: 'Remove' }, { name: 'myfiles/homework/title', value: 'Title' }, { name: 'myfiles/homework/description', value: 'Description' }, { name: 'myfiles/homework/start', value: 'Start' }, { name: 'myfiles/homework/end', value: 'End' }, { name: 'myfiles/homework/students', value: 'Students' }, { name: 'myfiles/homework/teachers', value: 'Additional Teachers' }, { name: 'myfiles/homework/confirmremove', value: 'Are you sure you want to remove this homework?' }, { name: 'myfiles/homework/upload', value: 'Upload Homework' }], livetiles: { Init: function (data) { if ($("#" + data[0].Data.Group).is(".me")) this.ShowMe(data); else for (var i = 0; i < data.length; i++) { var found = false; for (var x = 0; x < this.TileHandlers.length; x++) if (data[i].Type.match(this.TileHandlers[x].type)) { found = true; this.Tiles.push(this.TileHandlers[x].func(data[i].Type, data[i].Data)); break; } if (!found) this.Tiles.push(new this.LiveTile(data[i].Type, data[i].Data)); } }, TileHandlers: [], RegisterTileHandler: function (type, func) { this.TileHandlers.push({ "type": type, "func": func }); }, Tiles: [], ShowMe: function (data) { for (var i = 0; i < data.length; i++) if (data[i].Data.Name == "Me") { $("#" + data[i].Data.Group).append('
').parent().addClass("me"); $.ajax({ url: hap.common.formatJSONUrl("~/api/livetiles/me"), type: 'GET', context: this.id, dataType: "json", contentType: 'application/JSON', success: function (data) { if (data.Photo != "" && data.Photo != null) $("#me-me").append(''); $("#me-me").append('
' + data.Name + '
' + data.Email + '
'); }, error: hap.common.jsonError }); } else if (data[i].Data.Name == "Password") { $("#" + data[i].Data.Group).append('

Change My Password

'); $("#me-setpassword").button().click(function () { if ($("#me-password-current").val().length == 0 || $("#me-password-new").val().length == 0 || $("#me-password-confirm").val().length == 0 || $("#me-password-confirm").val() != $("#me-password-new").val()) return false; $.ajax({ url: hap.common.formatJSONUrl("~/api/livetiles/me/password"), type: 'POST', dataType: "json", contentType: 'application/JSON', data: '{ "oldpassword": "' + $("#me-password-current").val() + '", "newpassword": "' + $("#me-password-new").val() + '" }', success: function (data) { alert("Password Updated"); $("#me-password-current, #me-password-new, #me-password-confirm").val(""); }, error: hap.common.jsonError }); return false; }); } }, RegisterDefaultTiles: function () { hap.livetiles.RegisterTileHandler("exchange.unread", function (type, initdata, size) { this.id = (initdata.Group + initdata.Name).replace(/[\s'\/\\\&\.\,\*]*/gi, ""); this.html = '' + initdata.Name + ''; $("#" + initdata.Group).append(this.html); setTimeout("hap.livetiles.UpdateExchangeMail('" + this.id + "');", 100); }); hap.livetiles.RegisterTileHandler("exchange.appointments", function (type, initdata, size) { size = "large"; this.id = (initdata.Group + initdata.Name).replace(/[\s'\/\\\&\.\,\*]*/gi, ""); this.html = '' + initdata.Name + ''; $("#" + initdata.Group).append(this.html); $("#" + this.id).addClass("appointment"); setTimeout("hap.livetiles.UpdateExchangeAppointments('" + this.id + "');", 100); }); hap.livetiles.RegisterTileHandler(/exchange.calendar\:/gi, function (type, initdata, size) { size = "large"; this.id = (initdata.Group + initdata.Name).replace(/[\s'\/\\\&\.\,\*]*/gi, ""); this.html = '' + initdata.Name + ''; $("#" + initdata.Group).append(this.html); $("#" + this.id).addClass("appointment"); setTimeout("hap.livetiles.UpdateExchangeCalendar('" + this.id + "', '" + type.split(/exchange.calendar\:/gi)[1] + "');", 100); }); hap.livetiles.RegisterTileHandler(/^me/gi, function (type, initdata, size) { this.id = (initdata.Group + initdata.Name).replace(/[\s'\/\\\&\.\,\*]*/gi, ""); this.html = '' + initdata.Name + ''; $("#" + initdata.Group).append(this.html); $("#" + this.id).addClass("me"); $.ajax({ url: hap.common.formatJSONUrl("~/api/livetiles/me"), type: 'GET', context: this.id, dataType: "json", contentType: 'application/JSON', success: function (data) { $("#" + this + " span label").html("" + data.Name + "
" + data.Email); if (data.Photo != "" && data.Photo != null) $("#" + this + " span i").css("background-image", "url(" + hap.common.resolveUrl(data.Photo) + ")"); setInterval("$('#" + this + " span i').animate({ height: 'toggle' });", 8000); }, error: hap.common.jsonError }); }); hap.livetiles.RegisterTileHandler("bookings", function (type, initdata, size) { size = "large"; this.id = (initdata.Group + initdata.Name).replace(/[\s'\/\\\&\.\,\*]*/gi, ""); this.html = '' + initdata.Name + ''; $("#" + initdata.Group).append(this.html); $("#" + this.id).addClass("appointment"); setTimeout("hap.livetiles.UpdateBookings('" + this.id + "');", 100); }); hap.livetiles.RegisterTileHandler("helpdesk", function (type, initdata, size) { size = "large"; this.id = (initdata.Group + initdata.Name).replace(/[\s'\/\\\&\.\,\*]*/gi, ""); this.html = '' + initdata.Name + ''; $("#" + initdata.Group).append(this.html); $("#" + this.id).addClass("me"); setInterval("$('#" + this.id + " > span > i').animate({ height: 'toggle' });", 10000); setTimeout("hap.livetiles.UpdateTickets('" + this.id + "');", 100); }); hap.livetiles.RegisterTileHandler(/^uptime\:/gi, function (type, initdata, size) { this.id = (initdata.Group + initdata.Name).replace(/[\s'\/\\\&\.\,\*]*/gi, ""); this.html = '' + initdata.Name + ''; $("#" + initdata.Group).append(this.html); $("#" + this.id).addClass("me"); setTimeout("hap.livetiles.UpdateUptime('" + this.id + "', '" + type.substr(7) + "');", 100); }); hap.livetiles.RegisterTileHandler("myfiles", function (type, initdata, size) { this.id = (initdata.Group + initdata.Name).replace(/[\s'\/\\\&\.\,\*]*/gi, ""); this.html = '' + initdata.Name + ''; $("#" + initdata.Group).append(this.html); $.ajax({ url: hap.common.formatJSONUrl("~/api/myfiles/drives"), type: 'GET', context: this.id, dataType: "json", contentType: 'application/JSON', success: function (data) { var s = ""; for (var i = 0; i < (data.length > 3 ? 3 : data.length) ; i++) s += "" + data[i].Name + "" + (data[i].Space == -1 ? "

" : '
'); $("#" + this + " span label").html(s); setInterval("$('#" + this + " > span > i').animate({ height: 'toggle' });", 6000); }, error: hap.common.jsonError }); }); }, LiveTile: function (type, initdata, size) { this.id = (initdata.Group + initdata.Name).replace(/[\s'\/\\\&\.\,\*]*/gi, ""); if (type == "exchange.appointments" || type.match(/exchange.calendar\:/gi) || type == "bookings" || type == "helpdesk") size = "large"; this.html = '' + initdata.Name + ''; $("#" + initdata.Group).append(this.html); }, 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 + "
"; } if (data.length > 0) $("#" + this + " span i").attr("style", "background-image: url();"); $('#' + this + " span i").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 = ""; for (var i = 0; i < data.length; i++) x += '' + (i + 1) + ':' + data[i].Subject + '
'; if (data.length == 0) x = "No Open Tickets"; $("#" + this + " span label").html(x); 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(); } });}