From 9b916a84f00d7c15ec1751977e4aa7f2b76cddcf Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 25 Mar 2013 15:20:43 -0400 Subject: [PATCH] update to latest js api client --- MediaBrowser.WebDashboard/ApiClient.js | 104 ++++++++++++++++++++-- MediaBrowser.WebDashboard/packages.config | 2 +- 2 files changed, 98 insertions(+), 8 deletions(-) diff --git a/MediaBrowser.WebDashboard/ApiClient.js b/MediaBrowser.WebDashboard/ApiClient.js index d047b494ea..94dc72d543 100644 --- a/MediaBrowser.WebDashboard/ApiClient.js +++ b/MediaBrowser.WebDashboard/ApiClient.js @@ -1,4 +1,54 @@ -if (!window.MediaBrowser) { +(function (jQuery, window, undefined) { + "use strict"; + + var matched, browser; + + jQuery.uaMatch = function (ua) { + ua = ua.toLowerCase(); + + var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || + /(webkit)[ \/]([\w.]+)/.exec(ua) || + /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || + /(msie) ([\w.]+)/.exec(ua) || + ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || + []; + + var platform_match = /(ipad)/.exec(ua) || + /(iphone)/.exec(ua) || + /(android)/.exec(ua) || + []; + + return { + browser: match[1] || "", + version: match[2] || "0", + platform: platform_match[0] || "" + }; + }; + + matched = jQuery.uaMatch(window.navigator.userAgent); + browser = {}; + + if (matched.browser) { + browser[matched.browser] = true; + browser.version = matched.version; + } + + if (matched.platform) { + browser[matched.platform] = true + } + + // Chrome is Webkit, but Webkit is also Safari. + if (browser.chrome) { + browser.webkit = true; + } else if (browser.webkit) { + browser.safari = true; + } + + jQuery.browser = browser; + +})(jQuery, window); + +if (!window.MediaBrowser) { window.MediaBrowser = {}; } @@ -47,6 +97,47 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { } }; + deviceName = (function () { + + var name = ""; + + if ($.browser.chrome) { + name = "Chrome"; + } + else if ($.browser.safari) { + name = "Safari"; + } + else if ($.browser.webkit) { + name = "WebKit"; + } + else if ($.browser.msie) { + name = "Internet Explorer"; + } + else if ($.browser.firefox) { + name = "Firefox"; + } + else if ($.browser.mozilla) { + name = "Firefox"; + } + else if ($.browser.opera) { + name = "Opera"; + } + else { + name = "Web Browser"; + } + + if ($.browser.ipad) { + name += " Ipad"; + } + else if ($.browser.iphone) { + name += " Iphone"; + } + else if ($.browser.android) { + name += " Android"; + } + return name; + }()); + /** * Wraps around jQuery ajax methods to add additional info to the request. */ @@ -1683,7 +1774,7 @@ MediaBrowser.SHA1 = function (msg) { function rotate_left(n, s) { var t4 = (n << s) | (n >>> (32 - s)); return t4; - }; + } function lsb_hex(val) { var str = ""; @@ -1697,7 +1788,7 @@ MediaBrowser.SHA1 = function (msg) { str += vh.toString(16) + vl.toString(16); } return str; - }; + } function cvt_hex(val) { var str = ""; @@ -1709,8 +1800,7 @@ MediaBrowser.SHA1 = function (msg) { str += v.toString(16); } return str; - }; - + } function Utf8Encode(string) { string = string.replace(/\r\n/g, "\n"); @@ -1736,7 +1826,7 @@ MediaBrowser.SHA1 = function (msg) { } return utftext; - }; + } var blockstart; var i, j; @@ -1843,4 +1933,4 @@ MediaBrowser.SHA1 = function (msg) { var temp = cvt_hex(H0) + cvt_hex(H1) + cvt_hex(H2) + cvt_hex(H3) + cvt_hex(H4); return temp.toLowerCase(); -} +}; \ No newline at end of file diff --git a/MediaBrowser.WebDashboard/packages.config b/MediaBrowser.WebDashboard/packages.config index ca25a26f47..cd8da27323 100644 --- a/MediaBrowser.WebDashboard/packages.config +++ b/MediaBrowser.WebDashboard/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file