+};
+
+/**
+* Performs a logout request. The nameless cookie is
+* always cleared and the browser redirected to the login page,
+* independent of whether or not logout succeeded.
+* @returns The AJAX object of the logout request.
+*/
+$.fn.logout = function () {
+ return $.ajax({
+ url : mctx.api + "unbind"
+ }).always(function () {
+ //Note: this only clears the nameless cookie
+ document.cookie = "";
+ window.location = mctx.location + "login.html";
+ });
+};
+
+/**
+* Sets the error log to continuously update.
+* @returns itself */
+$.fn.setErrorLog = function () {
+ var url = mctx.api + "errorlog";
+ var outdiv = this;
+
+ var updater = function () {
+ $.ajax({url : url}).done(function (data) {
+ outdiv.text(data);
+ outdiv.scrollTop(
+ outdiv[0].scrollHeight - outdiv.height()
+ );
+ setTimeout(updater, 3000);
+ }).fail(function (jqXHR) {
+ if (jqXHR.status === 502 || jqXHR.status === 0) {
+ outdiv.text("Failed to retrieve the error log.");
+ }
+ setTimeout(updater, 10000); //poll at slower rate
+ });
+ };
+
+ updater();
+ return this;
+};
+
+$(document).ajaxError(function (event, jqXHR) {
+ //console.log("AJAX query failed with: " + jqXHR.status + " (" + jqXHR.statusText + ")");
+});
\ No newline at end of file