|
@@ -1,54 +1,4 @@
|
|
-(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) {
|
|
|
|
|
|
+if (!window.MediaBrowser) {
|
|
window.MediaBrowser = {};
|
|
window.MediaBrowser = {};
|
|
}
|
|
}
|
|
|
|
|
|
@@ -63,6 +13,16 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
|
*/
|
|
*/
|
|
return function (serverProtocol, serverHostName, serverPortNumber, clientName) {
|
|
return function (serverProtocol, serverHostName, serverPortNumber, clientName) {
|
|
|
|
|
|
|
|
+ if (!serverProtocol) {
|
|
|
|
+ throw new Error("Must supply a serverProtocol, e.g. http:");
|
|
|
|
+ }
|
|
|
|
+ if (!serverHostName) {
|
|
|
|
+ throw new Error("Must supply serverHostName, e.g. 192.168.1.1 or myServerName");
|
|
|
|
+ }
|
|
|
|
+ if (!serverPortNumber) {
|
|
|
|
+ throw new Error("Must supply a serverPortNumber");
|
|
|
|
+ }
|
|
|
|
+
|
|
var self = this;
|
|
var self = this;
|
|
var deviceName = "Web Browser";
|
|
var deviceName = "Web Browser";
|
|
var deviceId = MediaBrowser.SHA1(navigator.userAgent + (navigator.cpuClass || ""));
|
|
var deviceId = MediaBrowser.SHA1(navigator.userAgent + (navigator.cpuClass || ""));
|
|
@@ -113,10 +73,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
|
else if ($.browser.msie) {
|
|
else if ($.browser.msie) {
|
|
name = "Internet Explorer";
|
|
name = "Internet Explorer";
|
|
}
|
|
}
|
|
- else if ($.browser.firefox) {
|
|
|
|
- name = "Firefox";
|
|
|
|
- }
|
|
|
|
- else if ($.browser.mozilla) {
|
|
|
|
|
|
+ else if ($.browser.firefox || $.browser.mozilla) {
|
|
name = "Firefox";
|
|
name = "Firefox";
|
|
}
|
|
}
|
|
else if ($.browser.opera) {
|
|
else if ($.browser.opera) {
|
|
@@ -147,15 +104,18 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
|
throw new Error("Request cannot be null");
|
|
throw new Error("Request cannot be null");
|
|
}
|
|
}
|
|
|
|
|
|
- var auth = 'MediaBrowser Client="' + clientName + '", Device="' + deviceName + '", DeviceId="' + deviceId + '"';
|
|
|
|
|
|
+ if (clientName) {
|
|
|
|
|
|
- if (currentUserId) {
|
|
|
|
- auth += ', UserId="' + currentUserId + '"';
|
|
|
|
- }
|
|
|
|
|
|
+ var auth = 'MediaBrowser Client="' + clientName + '", Device="' + deviceName + '", DeviceId="' + deviceId + '"';
|
|
|
|
|
|
- request.headers = {
|
|
|
|
- Authorization: auth
|
|
|
|
- };
|
|
|
|
|
|
+ if (currentUserId) {
|
|
|
|
+ auth += ', UserId="' + currentUserId + '"';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ request.headers = {
|
|
|
|
+ Authorization: auth
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
|
|
return $.ajax(request);
|
|
return $.ajax(request);
|
|
};
|
|
};
|
|
@@ -1933,4 +1893,54 @@ MediaBrowser.SHA1 = function (msg) {
|
|
var temp = cvt_hex(H0) + cvt_hex(H1) + cvt_hex(H2) + cvt_hex(H3) + cvt_hex(H4);
|
|
var temp = cvt_hex(H0) + cvt_hex(H1) + cvt_hex(H2) + cvt_hex(H3) + cvt_hex(H4);
|
|
|
|
|
|
return temp.toLowerCase();
|
|
return temp.toLowerCase();
|
|
-};
|
|
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+(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);
|