add LocalFileInfo.Id

This commit is contained in:
Luke Pulverenti 2014-10-24 00:54:35 -04:00
parent f2358f0a65
commit 90082ed4bc
12 changed files with 935 additions and 188 deletions

View File

@ -23,7 +23,7 @@
<li>
<label for="txtMetadataPath">${LabelMetadataPath}</label>
<div style="display: inline-block; width: 92%;">
<input type="text" id="txtMetadataPath" name="txtMetadataPath" />
<input type="text" id="txtMetadataPath" />
</div>
<button id="btnSelectMetadataPath" type="button" data-icon="search" data-iconpos="notext" data-inline="true">${ButtonSelectDirectory}</button>
<div class="fieldDescription">${LabelMetadataPathHelp}</div>
@ -34,7 +34,7 @@
</li>
<li>
<label for="selectDateAdded">${LabelDateAddedBehavior}</label>
<select data-mini="true" id="selectDateAdded">
<select id="selectDateAdded" data-mini="true">
<option value="0">${OptionDateAddedImportTime}</option>
<option value="1">${OptionDateAddedFileTime}</option>
</select>

View File

@ -46,7 +46,7 @@
</div>
<div id="fldNewImagePreview"></div>
<div id="fldUpload" style="display: none;">
<button type="submit" data-icon="check">${ButtonUpload}</button>
<button type="submit" data-icon="check" data-theme="a">${ButtonUpload}</button>
</div>
</div>
</div>

View File

@ -551,7 +551,10 @@ var Dashboard = {
html += '<form>';
if (user.Configuration.EnableUserPreferenceAccess) {
html += '<p><a data-mini="true" data-role="button" href="mypreferencesdisplay.html?userId=' + user.Id + '" data-icon="gear">' + Globalize.translate('ButtonMyPreferences') + '</button></a>';
}
html += '<p><button data-mini="true" type="button" onclick="Dashboard.logout();" data-icon="lock">' + Globalize.translate('ButtonSignOut') + '</button></p>';
html += '</form>';
@ -1191,20 +1194,79 @@ var Dashboard = {
(function () {
function generateDeviceName() {
var name = "Web Browser";
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.opera) {
name = "Opera";
} else if ($.browser.firefox || $.browser.mozilla) {
name = "Firefox";
}
if ($.browser.version) {
name += " " + $.browser.version;
}
if ($.browser.ipad) {
name += " Ipad";
} else if ($.browser.iphone) {
name += " Iphone";
} else if ($.browser.android) {
name += " Android";
}
return name;
}
if (!window.WebSocket) {
alert(Globalize.translate('MessageBrowserDoesNotSupportWebSockets'));
}
window.ApiClient = new MediaBrowser.ApiClient(Dashboard.serverAddress(), "Dashboard", window.dashboardVersion, MediaBrowser.ApiClient.generateDeviceName(), MediaBrowser.ApiClient.generateDeviceId());
var appName = "Dashboard";
var appVersion = window.dashboardVersion;
var deviceName = generateDeviceName();
var deviceId = MediaBrowser.ApiClient.generateDeviceId();
window.ApiClient = new MediaBrowser.ApiClient(Dashboard.serverAddress(), appName, appVersion, deviceName, deviceId);
window.ConnectionManager = new MediaBrowser.ConnectionManager(new MediaBrowser.CredentialProvider(), appName, appVersion, deviceName, deviceId);
$(ApiClient).on("websocketopen", Dashboard.onWebSocketOpened)
.on("websocketmessage", Dashboard.onWebSocketMessageReceived);
// TODO: Improve with http://webpjs.appspot.com/
ApiClient.supportsWebP($.browser.chrome);
ApiClient.setCurrentUserId(Dashboard.getCurrentUserId(), Dashboard.getAccessToken());
//test();
})();
function test() {
ConnectionManager.loginToConnect("luke", "ac501ac7111a1e5").done(function (result) {
var promise = ConnectionManager.connect();
promise.done(function (r) {
alert(JSON.stringify(r));
}).fail(function() {
alert('fail');
});
});
}
$(function () {

View File

@ -59,6 +59,8 @@
$('#chkEnableLiveTvAccess', page).checked(user.Configuration.EnableLiveTvAccess || false).checkboxradio("refresh");
$('#chkEnableContentDeletion', page).checked(user.Configuration.EnableContentDeletion || false).checkboxradio("refresh");
$('#chkDisableUserPreferences', page).checked((!user.Configuration.EnableUserPreferenceAccess) || false).checkboxradio("refresh");
Dashboard.hideLoadingMsg();
}
@ -102,6 +104,7 @@
user.Configuration.EnableMediaPlayback = $('#chkEnableMediaPlayback', page).checked();
user.Configuration.EnableLiveTvAccess = $('#chkEnableLiveTvAccess', page).checked();
user.Configuration.EnableContentDeletion = $('#chkEnableContentDeletion', page).checked();
user.Configuration.EnableUserPreferenceAccess = !$('#chkDisableUserPreferences', page).checked();
var userId = getParameterByName("userId");

View File

@ -2,55 +2,664 @@
window.MediaBrowser = {};
}
MediaBrowser.ConnectionManager = function () {
MediaBrowser.ConnectionManager = function (store) {
return function () {
MediaBrowser.ConnectionState = {
Unavilable: 0,
ServerSelection: 1,
ServerSignIn: 2,
SignedIn: 3
};
MediaBrowser.ConnectionMode = {
Local: 0,
Remote: 1
};
return function (credentialProvider, appName, applicationVersion, deviceName, deviceId) {
var self = this;
var apiClients = [];
self.onConnectAuthenticated = function (result) {
function mergeServers(list1, list2) {
store.setItem('ConnectAccessToken', result.AccessToken);
store.setItem('ConnectUserId', result.User.Id);
for (var i = 0, length = list2.length; i < length; i++) {
credentialProvider.addOrUpdateServer(list1, list2[i]);
}
return list1;
}
function resolveWithFailure(deferred) {
deferred.resolveWith(null, [
{
state: MediaBrowser.ConnectionState.Unavilable,
connectUser: self.connectUser()
}]);
}
function updateServerInfo(server, systemInfo) {
server.Name = systemInfo.ServerName;
server.Id = systemInfo.Id;
if (systemInfo.LocalAddress) {
server.LocalAddress = systemInfo.LocalAddress;
}
if (systemInfo.WanAddress) {
server.RemoteAddress = systemInfo.WanAddress;
}
if (systemInfo.MacAddress) {
server.WakeOnLanInfos = [
{ MacAddress: systemInfo.MacAddress }
];
}
}
function tryConnect(url) {
return $.ajax({
type: "GET",
url: url + "/mediabrowser/system/info/public",
dataType: "json",
error: function () {
}
});
}
var connectUser;
self.connectUser = function () {
return connectUser;
};
self.isLoggedIntoConnect = function () {
function onConnectAuthenticated(user) {
return self.connectToken() && self.connectUserId();
};
connectUser = user;
$(self).trigger('connectusersignedin', [user]);
}
self.logoutFromConnect = function () {
store.removeItem('ConnectAccessToken');
store.removeItem('ConnectUserId');
};
function getOrAddApiClient(server, connectionMode) {
self.changeServer = function (currentApiClient, server) {
var apiClient = self.getApiClient(server.Id);
};
if (!apiClient) {
self.connectUserId = function () {
return store.getItem('ConnectUserId');
};
var url = connectionMode == MediaBrowser.ConnectionMode.Local ? server.LocalAddress : server.RemoteAddress;
self.connectToken = function () {
return store.getItem('ConnectAccessToken');
};
apiClient = new MediaBrowser.ApiClient(url, appName, applicationVersion, deviceName, deviceId);
self.getServers = function () {
apiClients.push(apiClient);
var url = "https://connect.mediabrowser.tv/service/servers?userId=" + self.connectUserId();
$(apiClient).on('authenticated', function (e, result) {
onLocalAuthenticated(this, result);
});
}
if (!server.accessToken) {
apiClient.clearAuthenticationInfo();
}
else {
apiClient.setAuthenticationInfo(server.accessToken, server.userId);
}
return apiClient;
}
function onLocalAuthenticated(apiClient, result) {
apiClient.getSystemInfo().done(function (systemInfo) {
var server = apiClient.serverInfo;
updateServerInfo(server, systemInfo);
var credentials = credentialProvider.credentials();
server.DateLastAccessed = new Date().getTime();
server.UserId = result.User.Id;
server.AccessToken = result.AccessToken;
credentials.addOrUpdateServer(credentials.servers, server);
credentialProvider.credentials(credentials);
ensureWebSocket(apiClient);
onLocalUserSignIn(result.User);
});
}
function ensureWebSocket(apiClient) {
if (!apiClient.isWebSocketOpenOrConnecting) {
apiClient.openWebSocket();
}
}
function onLocalUserSignIn(user) {
$(self).trigger('localusersignedin', [user]);
}
function ensureConnectUser(credentials) {
var deferred = $.Deferred();
if (self.isLoggedIntoConnect()) {
deferred.resolveWith(null, [[]]);
} else {
getConnectUser(credentials.ConnectUserId, credentials.ConnectAccessToken).done(function (user) {
onConnectAuthenticated(user);
deferred.resolveWith(null, [[]]);
}).fail(function () {
deferred.resolveWith(null, [[]]);
});
}
return deferred.promise();
}
function getConnectUser(userId, accessToken) {
var url = "https://connect.mediabrowser.tv/service/user?userId=" + userId;
return $.ajax({
type: "GET",
url: url,
dataType: "json",
headers: {
"X-Connect-UserToken": self.connectToken()
"X-Connect-UserToken": accessToken
},
error: function () {
}
});
}
function addAuthenticationInfoFromConnect(server, connectionMode, credentials) {
var url = connectionMode == MediaBrowser.ConnectionMode.Local ? server.LocalAddress : server.RemoteAddress;
url += "/mediabrowser/Connect/Exchange?format=json&ConnectUserId=" + credentials.ConnectUserId;
return $.ajax({
type: "GET",
url: url,
dataType: "json",
headers: {
"X-MediaBrowser-Token": server.ExchangeToken
},
error: function () {
}
}).done(function (auth) {
server.UserId = auth.LocalUserId;
server.AccessToken = auth.AccessToken;
}).fail(function () {
server.UserId = null;
server.AccessToken = null;
});
}
function validateAuthentication(server, connectionMode) {
var deferred = $.Deferred();
var url = connectionMode == MediaBrowser.ConnectionMode.Local ? server.LocalAddress : server.RemoteAddress;
$.ajax({
type: "GET",
url: url + "/mediabrowser/system/info",
dataType: "json",
headers: {
"X-MediaBrowser-Token": server.AccessToken
},
error: function () {
}
}).done(function (systemInfo) {
updateServerInfo(server, systemInfo);
if (server.UserId) {
$.ajax({
type: "GET",
url: url + "/mediabrowser/users/" + server.UserId,
dataType: "json",
headers: {
"X-MediaBrowser-Token": server.AccessToken
},
error: function () {
}
}).done(function (user) {
onLocalUserSignIn(user);
deferred.resolveWith(null, [[]]);
}).fail(function () {
server.UserId = null;
server.AccessToken = null;
deferred.resolveWith(null, [[]]);
});
}
}).fail(function () {
server.UserId = null;
server.AccessToken = null;
deferred.resolveWith(null, [[]]);
});
return deferred.promise();
}
self.isLoggedIntoConnect = function () {
return self.connectToken() && self.connectUserId();
};
self.logout = function () {
var i, length;
var promises = [];
for (i = 0, length = apiClients.length; i < length; i++) {
var apiClient = apiClients[i];
if (apiClient.accessToken()) {
promises.push(apiClient.logout());
}
}
return $.when(promises).done(function () {
var credentials = credentialProvider.credentials();
for (i = 0, length = credentials.servers.length; i < length; i++) {
credentials.servers[i].UserId = null;
credentials.servers[i].AccessToken = null;
credentials.servers[i].ExchangeToken = null;
}
credentials.ConnectAccessToken = null;
credentials.ConnectUserId = null;
credentialProvider.credentials(credentials);
connectUser = null;
$(self).trigger('signedout');
});
};
self.connectUserId = function () {
return credentialProvider.credentials().ConnectUserId;
};
}();
self.connectToken = function () {
window.ConnectionManager = new MediaBrowser.ConnectionManager();
return credentialProvider.credentials().ConnectAccessToken;
};
function getConnectServers() {
var deferred = $.Deferred();
var url = "https://connect.mediabrowser.tv/service/servers?userId=" + self.connectUserId();
$.ajax({
type: "GET",
url: url,
dataType: "json",
headers: {
"X-Connect-UserToken": self.connectToken()
},
error: function () {
}
}).done(function (servers) {
servers = servers.map(function (i) {
return {
ExchangeToken: i.AccessKey,
Id: i.SystemId,
Name: i.Name,
RemoteAddress: i.Url,
LocalAddress: null
};
});
deferred.resolveWith(null, [servers]);
}).fail(function () {
deferred.resolveWith(null, [[]]);
});
return deferred.promise();
}
self.getServers = function () {
// Clone the array
var credentials = credentialProvider.credentials();
var servers = credentials.servers.slice(0);
var deferred = $.Deferred();
getConnectServers().done(function (result) {
var newList = mergeServers(servers, result);
deferred.resolveWith(null, [newList]);
credentials.servers = newList;
credentialProvider.credentials(credentials);
});
return deferred.promise();
};
self.connect = function () {
var deferred = $.Deferred();
self.getServers().done(function (servers) {
self.connectToServers(servers).done(function (result) {
deferred.resolveWith(null, [result]);
});
});
return deferred.promise();
};
self.connectToServers = function (servers) {
var deferred = $.Deferred();
servers.sort(function (a, b) {
return b.DateLastAccessed - a.DateLastAccessed;
});
if (servers.length == 1) {
if (!servers[0].DateLastAccessed && !self.connectUser()) {
deferred.resolveWith(null, [
{
Servers: servers,
State: MediaBrowser.ConnectionState.ServerSelection,
ConnectUser: self.connectUser()
}
]);
}
self.connectToServer(servers[0]).done(function (result) {
deferred.resolveWith(null, [result]);
}).fail(function () {
deferred.resolveWith(null, [
{
Servers: servers,
State: MediaBrowser.ConnectionState.ServerSelection,
ConnectUser: self.connectUser()
}
]);
});
} else {
// Find the first server with a saved access token
var currentServer = servers.filter(function (s) {
return s.AccessToken;
})[0];
if (currentServer) {
self.connectToServer(currentServer).done(function (result) {
deferred.resolveWith(null, [result]);
}).fail(function () {
deferred.resolveWith(null, [
{
Servers: servers,
State: MediaBrowser.ConnectionState.ServerSelection,
ConnectUser: self.connectUser()
}
]);
});
} else {
deferred.resolveWith(null, [
{
Servers: servers,
State: servers.length ? MediaBrowser.ConnectionState.ServerSelection : MediaBrowser.ConnectionState.Unavailable,
ConnectUser: self.connectUser()
}]);
}
}
return deferred.promise();
};
self.connectToServer = function (server) {
var deferred = $.Deferred();
var systemInfo = null;
var connectionMode = MediaBrowser.ConnectionMode.Local;
var credentials = credentialProvider.credentials();
function onLocalServerTokenValidationDone() {
credentialProvider.addOrUpdateServer(credentials.servers, server);
server.DateLastAccessed = new Date().getTime();
credentialProvider.credentials(credentials);
var result = {
Servers: []
};
result.ApiClient = getOrAddApiClient(server, connectionMode);
result.State = server.AccessToken ?
MediaBrowser.ConnectionState.SignedIn :
MediaBrowser.ConnectionState.ServerSignIn;
result.ApiClient.enableAutomaticNetworking(server, connectionMode);
if (result.State == MediaBrowser.ConnectionState.SignedIn) {
ensureWebSocket(result.ApiClient);
}
result.Servers.push(server);
deferred.resolveWith(null, [result]);
$(this).trigger('connected', [result]);
}
function onExchangeTokenDone() {
if (server.AccessToken) {
validateAuthentication(server, connectionMode).always(onLocalServerTokenValidationDone);
} else {
onLocalServerTokenValidationDone();
}
}
function onEnsureConnectUserDone() {
if (credentials.ConnectUserId && credentials.ConnectAccessToken) {
addAuthenticationInfoFromConnect(server, connectionMode, credentials).always(onExchangeTokenDone);
} else {
onExchangeTokenDone();
}
}
function onRemoteTestDone() {
if (systemInfo == null) {
resolveWithFailure(deferred);
return;
}
updateServerInfo(server, systemInfo);
if (credentials.ConnectUserId && credentials.ConnectAccessToken) {
ensureConnectUser(credentials).always(onEnsureConnectUserDone);
} else {
onEnsureConnectUserDone();
}
}
function onLocalTestDone() {
if (!systemInfo && server.RemoteAddress) {
// Try to connect to the local address
tryConnect(server.RemoteAddress).done(function (result) {
systemInfo = result;
connectionMode = MediaBrowser.ConnectionMode.Remote;
onRemoteTestDone();
}).fail(function () {
onRemoteTestDone();
});
} else {
onRemoteTestDone();
}
}
if (server.LocalAddress) {
// Try to connect to the local address
tryConnect(server.LocalAddress).done(function (result) {
systemInfo = result;
onLocalTestDone();
}).fail(function () {
onLocalTestDone();
});
} else {
onLocalTestDone();
}
return deferred.promise();
};
self.connectToAddress = function (address) {
if (address.toLowerCase().indexOf('http') != 0) {
address = "http://" + address;
}
var deferred = $.Deferred();
tryConnect(address).done(function (publicInfo) {
var server = {};
updateServerInfo(server, publicInfo);
self.connectToServer(server).done(function (result) {
deferred.resolveWith(null, [result]);
}).fail(function () {
resolveWithFailure(deferred);
});
}).fail(function () {
resolveWithFailure(deferred);
});
return deferred.promise();
};
self.loginToConnect = function (username, password) {
var md5 = CryptoJS.MD5(password).toString();
return $.ajax({
type: "POST",
url: "https://connect.mediabrowser.tv/service/user/authenticate",
data: {
userName: username,
password: md5
},
dataType: "json",
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
error: function () {
// Don't show normal dashboard errors
}
}).done(function (result) {
var credentials = credentialProvider.credentials();
credentials.ConnectAccessToken = result.AccessToken;
credentials.ConnectUserId = result.User.Id;
credentialProvider.credentials(credentials);
onConnectAuthenticated(result.User);
});
};
self.getApiClient = function (item) {
// TODO: accept string + objet
return apiClients[0];
};
};
}(window.store);

View File

@ -0,0 +1,81 @@
if (!window.MediaBrowser) {
window.MediaBrowser = {};
}
MediaBrowser.CredentialProvider = function (store) {
return function () {
var self = this;
var credentials;
function ensure() {
credentials = credentials || JSON.parse(store.getItem('servercredentials') || '{}');
credentials.servers = credentials.servers || [];
}
function get() {
ensure();
return credentials;
}
function set(data) {
credentials = data;
store.setItem('servercredentials', JSON.stringify(get()));
}
self.credentials = function (data) {
if (data) {
set(data);
}
return get();
};
self.addOrUpdateServer = function(list, server) {
var existing = list.filter(function(s) {
return s.Id == server.Id;
})[0];
if (existing)
{
// Merge the data
existing.DateLastAccessed = Math.max(existing.DateLastAccessed || 0, server.DateLastAccessed || 0, new Date().getTime());
if (server.AccessToken)
{
existing.AccessToken = server.AccessToken;
existing.UserId = server.UserId;
}
if (server.ExchangeToken)
{
existing.ExchangeToken = server.ExchangeToken;
}
if (server.RemoteAddress)
{
existing.RemoteAddress = server.RemoteAddress;
}
if (server.LocalAddress)
{
existing.LocalAddress = server.LocalAddress;
}
if (server.Name)
{
existing.Name = server.Name;
}
if (server.WakeOnLanInfos && server.WakeOnLanInfos.length)
{
existing.WakeOnLanInfos = server.WakeOnLanInfos;
}
}
else {
list.push(server);
}
};
};
}(window.store);

View File

@ -1,55 +1,4 @@
(function (window) {
function myStore(defaultObject) {
var self = this;
self.localData = {};
var isDefaultAvailable;
if (defaultObject) {
try {
defaultObject.setItem('_test', '0');
isDefaultAvailable = true;
} catch (e) {
}
}
self.setItem = function (name, value) {
if (isDefaultAvailable) {
defaultObject.setItem(name, value);
} else {
self.localData[name] = value;
}
};
self.getItem = function (name) {
if (isDefaultAvailable) {
return defaultObject.getItem(name);
}
return self.localData[name];
};
self.removeItem = function (name) {
if (isDefaultAvailable) {
defaultObject.removeItem(name);
} else {
self.localData[name] = null;
}
};
}
window.store = new myStore(window.localStorage);
window.sessionStore = new myStore(window.sessionStorage);
})(window);
if (!window.MediaBrowser) {
if (!window.MediaBrowser) {
window.MediaBrowser = {};
}
@ -117,6 +66,16 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
return deviceId;
};
self.clearAuthenticationInfo = function () {
accessToken = null;
currentUserId = null;
};
self.setAuthenticationInfo = function (accessKey, userId) {
accessToken = accessKey;
currentUserId = userId;
};
self.encodeName = function (name) {
name = name.split('/').join('-');
@ -187,6 +146,10 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
return url;
};
self.enableAutomaticNetworking = function(server, connectionMode) {
};
self.openWebSocket = function () {
var url = serverAddress + self.apiPrefix();
@ -2117,11 +2080,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
});
};
function supportsWebP() {
var supportsWebP = false;
self.supportsWebP = function(val) {
// TODO: Improve with http://webpjs.appspot.com/
return $.browser.chrome;
if (val != null) {
supportsWebP = val;
}
return supportsWebP;
};
function normalizeImageOptions(options) {
@ -2149,7 +2115,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
options.quality = options.quality || (options.type.toLowerCase() == 'backdrop' ? 80 : 90);
if (supportsWebP()) {
if (self.supportsWebP()) {
options.format = 'webp';
}
}
@ -2225,7 +2191,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
delete options.type;
delete options.index;
if (supportsWebP()) {
if (self.supportsWebP()) {
options.format = 'webp';
}
@ -2297,6 +2263,11 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
data: JSON.stringify(postData),
dataType: "json",
contentType: "application/json"
}).done(function(result) {
$(self).trigger('authenticated', [result]);
});
};
@ -3222,94 +3193,4 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
return sha1(keys.join('|'));
};
MediaBrowser.ApiClient.generateDeviceName = function () {
var name = "Web Browser";
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.opera) {
name = "Opera";
} else if ($.browser.firefox || $.browser.mozilla) {
name = "Firefox";
}
if ($.browser.version) {
name += " " + $.browser.version;
}
if ($.browser.ipad) {
name += " Ipad";
} else if ($.browser.iphone) {
name += " Iphone";
} else if ($.browser.android) {
name += " Android";
}
return name;
};
})(window.store);
(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) ||
[];
var browser = match[1] || "";
if (ua.indexOf("like gecko") != -1 && ua.indexOf('webkit') == -1 && ua.indexOf('opera') == -1) {
browser = "msie";
}
return {
browser: browser,
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;
}
browser.mobile = (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
jQuery.browser = browser;
})(jQuery, window);

View File

@ -0,0 +1,50 @@
(function (window) {
function myStore(defaultObject) {
var self = this;
self.localData = {};
var isDefaultAvailable;
if (defaultObject) {
try {
defaultObject.setItem('_test', '0');
isDefaultAvailable = true;
} catch (e) {
}
}
self.setItem = function (name, value) {
if (isDefaultAvailable) {
defaultObject.setItem(name, value);
} else {
self.localData[name] = value;
}
};
self.getItem = function (name) {
if (isDefaultAvailable) {
return defaultObject.getItem(name);
}
return self.localData[name];
};
self.removeItem = function (name) {
if (isDefaultAvailable) {
defaultObject.removeItem(name);
} else {
self.localData[name] = null;
}
};
}
window.store = new myStore(window.localStorage);
window.sessionStore = new myStore(window.sessionStorage);
})(window);

57
dashboard-ui/thirdparty/browser.js vendored Normal file
View File

@ -0,0 +1,57 @@
(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) ||
[];
var browser = match[1] || "";
if (ua.indexOf("like gecko") != -1 && ua.indexOf('webkit') == -1 && ua.indexOf('opera') == -1) {
browser = "msie";
}
return {
browser: browser,
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;
}
browser.mobile = (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
jQuery.browser = browser;
})(jQuery, window);

View File

@ -59,10 +59,15 @@
<label for="chkDisabled">${OptionDisableUser}</label>
<div class="fieldDescription">${OptionDisableUserHelp}</div>
</div>
<p id="fldIsHidden">
<div style="margin: 1em 0;">
<input type="checkbox" id="chkDisableUserPreferences" data-mini="true" />
<label for="chkDisableUserPreferences">${OptionDisableUserPreferences}</label>
<div class="fieldDescription">${OptionDisableUserPreferencesHelp}</div>
</div>
<div id="fldIsHidden" style="margin: 2em 0 1em;">
<input type="checkbox" id="chkIsHidden" name="chkIsHidden" data-mini="true" />
<label for="chkIsHidden">${OptionHideUser}</label>
</p>
</div>
</div>
<br />
<ul data-role="listview" class="ulForm">

View File

@ -23,7 +23,7 @@
</div>
<div class="itemsContainer localUsers" style="text-align:left;margin-top:.5em;"></div>
<div class="ui-bar-a" style="padding: 0 1em;margin-top:2em;">
<div class="ui-bar-a" style="padding: 0 1em;margin-top:2.5em;">
<h3 style="margin:.6em 0;font-size:16px;font-weight:500;">
<span style="vertical-align:middle;">${HeaderGuests}</span>
<a class="btnInvite" data-role="button" data-icon="plus" href="#" data-rel="popup" data-position-to="window" data-inline="true" data-mini="true" data-iconpos="notext" style="margin: 0 0 0 .5em; vertical-align:middle;">
@ -33,7 +33,7 @@
</div>
<div class="itemsContainer connectUsers" style="text-align:left;margin-top:.5em;"></div>
<div class="sectionPendingGuests" style="display:none;margin-top:2em;">
<div class="sectionPendingGuests" style="display:none;margin-top:2.5em;">
<div class="ui-bar-a" style="padding: 0 1em;"><h3 style="font-size:16px;font-weight:500;">${HeaderPendingInvitations}</h3></div>
<div class="itemsContainer pending" style="text-align:left;margin-top:.5em;"></div>
</div>
@ -41,8 +41,6 @@
<div data-role="popup" id="popupInvite" data-theme="a">
<a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right">${ButtonClose}</a>
<div class="ui-bar-a" style="text-align: center; padding: 5px 20px;">
<h3 style="margin: .5em;">${HeaderInviteUser}</h3>
</div>
@ -60,7 +58,8 @@
</div>
<br />
<button type="submit" data-icon="mail">${ButtonSendInvitation}</button>
<button type="submit" data-icon="mail" data-theme="b">${ButtonSendInvitation}</button>
<a href="#" data-rel="back" data-icon="delete" data-role="button">${ButtonCancel}</a>
</div>
</form>