From b20151fff373100da7946df93afb7dd4dccea3e4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 23 Mar 2013 00:04:36 -0400 Subject: copy dashboard to the output folder and load from the file system, instead of using embedded resources --- .../Html/scripts/AddPluginPage.js | 249 ---- .../Html/scripts/AdvancedConfigurationPage.js | 65 -- .../scripts/AdvancedMetadataConfigurationPage.js | 69 -- .../Html/scripts/DashboardPage.js | 462 -------- .../Html/scripts/DisplaySettingsPage.js | 46 - .../Html/scripts/EditUserPage.js | 175 --- .../Html/scripts/Extensions.js | 506 -------- .../Html/scripts/IndexPage.js | 106 -- .../Html/scripts/ItemDetailPage.js | 376 ------ .../Html/scripts/ItemListPage.js | 46 - MediaBrowser.WebDashboard/Html/scripts/LogPage.js | 86 -- .../Html/scripts/LoginPage.js | 119 -- .../Html/scripts/MediaLibraryPage.js | 272 ----- .../Html/scripts/MediaPlayer.js | 182 --- .../Html/scripts/MetadataConfigurationPage.js | 107 -- .../Html/scripts/MetadataImagesPage.js | 90 -- .../Html/scripts/PluginCatalogPage.js | 86 -- .../Html/scripts/PluginUpdatesPage.js | 104 -- .../Html/scripts/PluginsPage.js | 86 -- .../Html/scripts/ScheduledTaskPage.js | 294 ----- .../Html/scripts/ScheduledTasksPage.js | 169 --- .../Html/scripts/SupporterKeyPage.js | 77 -- .../Html/scripts/SupporterPage.js | 29 - .../Html/scripts/UpdatePasswordPage.js | 88 -- .../Html/scripts/UserImagePage.js | 181 --- .../Html/scripts/UserProfilesPage.js | 76 -- .../Html/scripts/WizardFinishPage.js | 16 - .../Html/scripts/WizardStartPage.js | 17 - .../Html/scripts/WizardUserPage.js | 59 - .../Html/scripts/aboutPage.js | 24 - MediaBrowser.WebDashboard/Html/scripts/site.js | 1235 -------------------- 31 files changed, 5497 deletions(-) delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/AddPluginPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/AdvancedConfigurationPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/AdvancedMetadataConfigurationPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/DashboardPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/DisplaySettingsPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/EditUserPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/Extensions.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/IndexPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/ItemDetailPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/ItemListPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/LogPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/LoginPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/MediaLibraryPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/MediaPlayer.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/MetadataConfigurationPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/MetadataImagesPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/PluginCatalogPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/PluginUpdatesPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/PluginsPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/ScheduledTaskPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/ScheduledTasksPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/SupporterKeyPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/SupporterPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/UpdatePasswordPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/UserImagePage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/UserProfilesPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/WizardFinishPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/WizardStartPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/WizardUserPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/aboutPage.js delete mode 100644 MediaBrowser.WebDashboard/Html/scripts/site.js (limited to 'MediaBrowser.WebDashboard/Html/scripts') diff --git a/MediaBrowser.WebDashboard/Html/scripts/AddPluginPage.js b/MediaBrowser.WebDashboard/Html/scripts/AddPluginPage.js deleted file mode 100644 index 24f7581e9..000000000 --- a/MediaBrowser.WebDashboard/Html/scripts/AddPluginPage.js +++ /dev/null @@ -1,249 +0,0 @@ -var AddPluginPage = { - - onPageShow: function () { - - var page = this; - - Dashboard.showLoadingMsg(); - - var name = getParameterByName('name'); - - var promise1 = ApiClient.getPackageInfo(name); - var promise2 = ApiClient.getInstalledPlugins(); - var promise3 = ApiClient.getPluginSecurityInfo(); - - $.when(promise1, promise2, promise3).done(function (response1, response2, response3) { - - AddPluginPage.renderPackage(response1[0], response2[0], response3[0], page); - - }); - }, - - renderPackage: function (pkg, installedPlugins, pluginSecurityInfo, page) { - - var installedPlugin = installedPlugins.filter(function (ip) { - return ip.Name == pkg.name; - })[0]; - - AddPluginPage.populateVersions(pkg, page, installedPlugin); - AddPluginPage.populateHistory(pkg); - - Dashboard.setPageTitle(pkg.name); - - if (pkg.shortDescription) { - $('#tagline', page).show().html(pkg.shortDescription); - } else { - $('#tagline', page).hide(); - } - - $('#overview', page).html(pkg.overview || ""); - - - $('#developer', page).html(pkg.owner); - - if (pkg.isPremium) { - $('.premiumPackage', page).show(); - - // Fill in registration info - var regStatus = ""; - if (pkg.isRegistered) { - regStatus += "You are currently registered for this feature"; - } else { - if (new Date(pkg.expDate).getTime() < new Date(1970, 1, 1).getTime()) { - regStatus += "This feature has no registration information"; - } else { - if (new Date(pkg.expDate).getTime() <= new Date().getTime()) { - regStatus += "The trial period for this feature has expired"; - } else { - regStatus += "The trial period for this feature will expire in " + Math.round((new Date(pkg.expDate).getTime() - new Date().getTime()) / (86400000)) + " day(s)"; - } - } - } - - regStatus += ""; - $('#regStatus', page).html(regStatus); - - if (pluginSecurityInfo.IsMBSupporter) { - $('#regInfo', page).html(pkg.regInfo || ""); - if (pkg.price > 0) { - // Fill in PayPal info - $('premiumHasPrice', page).show(); - $('#featureId', page).val(pkg.featureId); - $('#featureName', page).val(pkg.name); - $('#amount', page).val(pkg.price); - $('#regPrice', page).html("

Price: $" + pkg.price.toFixed(2) + " (USD)

"); - var url = "http://mb3admin.com/admin/service/user/getPayPalEmail?id=" + pkg.owner; - $.getJSON(url).done(function(dev) { - if (dev.payPalEmail) { - $('#payPalEmail', page).val(dev.payPalEmail); - - } else { - $('#ppButton', page).hide(); - $('#noEmail', page).show(); - } - }); - } else { - // Supporter-only feature - $('premiumHasPrice', page).hide(); - } - } else { - $('#regInfo', page).html("

You must be a Media Browser Supporter in order to gain access to this feature.

"); - $('#ppButton', page).hide(); - } - - } else { - $('.premiumPackage', page).hide(); - } - - if (pkg.richDescUrl) { - $('#pViewWebsite', page).show(); - $('#pViewWebsite a', page)[0].href = pkg.richDescUrl; - } else { - $('#pViewWebsite', page).hide(); - } - - if (pkg.previewImage) { - - var color = pkg.tileColor || "#2572EB"; - var img = pkg.previewImage ? pkg.previewImage : pkg.thumbImage; - $('#pPreviewImage', page).show().html(""); - } else { - $('#pPreviewImage', page).hide().html(""); - } - - if (installedPlugin) { - $('#pCurrentVersion', page).show().html("You currently have version " + installedPlugin.Version + " installed."); - - } else { - $('#pCurrentVersion', page).hide().html(""); - } - - Dashboard.hideLoadingMsg(); - }, - - populateVersions: function (packageInfo, page, installedPlugin) { - - var html = ''; - - for (var i = 0, length = packageInfo.versions.length; i < length; i++) { - - var version = packageInfo.versions[i]; - - html += ''; - - } - - var selectmenu = $('#selectVersion', page).html(html); - - var packageVersion; - - if (installedPlugin) { - - // Select the first available package with the same update class as the installed version - packageVersion = packageInfo.versions.filter(function (current) { - - return current.classification == installedPlugin.UpdateClass; - })[0]; - - - } else { - $('#pCurrentVersion', page).hide().html(""); - } - - // If we don't have a package version to select, pick the first release build - if (!packageVersion) { - - // Select the first available package with the same update class as the installed version - packageVersion = packageInfo.versions.filter(function (current) { - - return current.classification == "Release"; - })[0]; - } - - // If we still don't have a package version to select, pick the first Beta build - if (!packageVersion) { - - // Select the first available package with the same update class as the installed version - packageVersion = packageInfo.versions.filter(function (current) { - - return current.classification == "Beta"; - })[0]; - } - - if (packageVersion) { - var val = packageVersion.versionStr + '|' + packageVersion.classification; - - $('#selectVersion', page).val(val); - } - - selectmenu.selectmenu('refresh'); - }, - - populateHistory: function (packageInfo) { - - var html = ''; - - for (var i = 0, length = Math.min(packageInfo.versions.length, 10) ; i < length; i++) { - - var version = packageInfo.versions[i]; - - html += '

' + version.versionStr + ' (' + version.classification + ')

'; - - html += '
' + version.description + '
'; - } - - $('#revisionHistory', $.mobile.activePage).html(html); - }, - - onSubmit: function () { - - Dashboard.showLoadingMsg(); - - $('#btnInstall', $.mobile.activePage).button('disable'); - - var name = getParameterByName('name'); - - ApiClient.getInstalledPlugins().done(function (plugins) { - - var installedPlugin = plugins.filter(function (ip) { - return ip.Name == name; - })[0]; - - var vals = $('#selectVersion', $.mobile.activePage).val().split('|'); - - var version = vals[0]; - - if (installedPlugin && installedPlugin.Version == version) { - - Dashboard.hideLoadingMsg(); - - Dashboard.confirm("Are you sure you wish to reinstall the same version you already have? In most cases this will not have any effect.", "Plugin Reinstallation", function (confirmResult) { - - if (confirmResult) { - - Dashboard.showLoadingMsg(); - AddPluginPage.performInstallation(name, vals[1], version); - } else { - $('#btnInstall', $.mobile.activePage).button('enable'); - } - - }); - } else { - AddPluginPage.performInstallation(name, vals[1], version); - } - }); - - - return false; - }, - - performInstallation: function (packageName, updateClass, version) { - - ApiClient.installPlugin(packageName, updateClass, version).done(function () { - - Dashboard.hideLoadingMsg(); - }); - } -}; - -$(document).on('pageshow', "#addPluginPage", AddPluginPage.onPageShow); \ No newline at end of file diff --git a/MediaBrowser.WebDashboard/Html/scripts/AdvancedConfigurationPage.js b/MediaBrowser.WebDashboard/Html/scripts/AdvancedConfigurationPage.js deleted file mode 100644 index f8c0d0a7d..000000000 --- a/MediaBrowser.WebDashboard/Html/scripts/AdvancedConfigurationPage.js +++ /dev/null @@ -1,65 +0,0 @@ -var AdvancedConfigurationPage = { - - onPageShow: function () { - Dashboard.showLoadingMsg(); - - var promise1 = ApiClient.getServerConfiguration(); - - var promise2 = ApiClient.getSystemInfo(); - - $.when(promise1, promise2).done(function (response1, response2) { - - AdvancedConfigurationPage.loadPage(response1[0], response2[0]); - - }); - }, - - loadPage: function (config, systemInfo) { - - var page = $.mobile.activePage; - - if (systemInfo.SupportsNativeWebSocket) { - - $('#fldWebSocketPortNumber', page).hide(); - } else { - $('#fldWebSocketPortNumber', page).show(); - } - - $('#selectAutomaticUpdateLevel', page).val(config.SystemUpdateLevel).selectmenu('refresh'); - $('#txtWebSocketPortNumber', page).val(config.LegacyWebSocketPortNumber); - - $('#txtPortNumber', page).val(config.HttpServerPortNumber); - $('#chkDebugLog', page).checked(config.EnableDebugLevelLogging).checkboxradio("refresh"); - - $('#chkEnableDeveloperTools', page).checked(config.EnableDeveloperTools).checkboxradio("refresh"); - $('#chkRunAtStartup', page).checked(config.RunAtStartup).checkboxradio("refresh"); - - Dashboard.hideLoadingMsg(); - }, - - onSubmit: function () { - - Dashboard.showLoadingMsg(); - - var form = this; - - ApiClient.getServerConfiguration().done(function (config) { - - config.LegacyWebSocketPortNumber = $('#txtWebSocketPortNumber', form).val(); - - config.HttpServerPortNumber = $('#txtPortNumber', form).val(); - config.EnableDebugLevelLogging = $('#chkDebugLog', form).checked(); - - config.EnableDeveloperTools = $('#chkEnableDeveloperTools', form).checked(); - config.RunAtStartup = $('#chkRunAtStartup', form).checked(); - config.SystemUpdateLevel = $('#selectAutomaticUpdateLevel', form).val(); - - ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult); - }); - - // Disable default form submission - return false; - } -}; - -$(document).on('pageshow', "#advancedConfigurationPage", AdvancedConfigurationPage.onPageShow); diff --git a/MediaBrowser.WebDashboard/Html/scripts/AdvancedMetadataConfigurationPage.js b/MediaBrowser.WebDashboard/Html/scripts/AdvancedMetadataConfigurationPage.js deleted file mode 100644 index 41e0f7223..000000000 --- a/MediaBrowser.WebDashboard/Html/scripts/AdvancedMetadataConfigurationPage.js +++ /dev/null @@ -1,69 +0,0 @@ -var AdvancedMetadataConfigurationPage = { - - onPageShow: function () { - - Dashboard.showLoadingMsg(); - - var page = this; - - var promise1 = ApiClient.getServerConfiguration(); - var promise2 = ApiClient.getItemTypes({ HasInternetProvider: true }); - - $.when(promise1, promise2).done(function (response1, response2) { - - AdvancedMetadataConfigurationPage.load(page, response1[0], response2[0]); - - }); - }, - - load: function (page, config, itemTypes) { - - AdvancedMetadataConfigurationPage.loadItemTypes(page, config, itemTypes); - Dashboard.hideLoadingMsg(); - }, - - loadItemTypes: function (page, configuration, types) { - - var html = '
'; - - for (var i = 0, length = types.length; i < length; i++) { - - var type = types[i]; - var id = "checkbox-" + i + "a"; - - var checkedAttribute = configuration.InternetProviderExcludeTypes.indexOf(type) != -1 ? ' checked="checked"' : ''; - - html += ''; - html += ''; - } - - html += "
"; - - $('#divItemTypes', page).html(html).trigger("create"); - }, - - submit: function () { - - $('.btnSubmit', $.mobile.activePage)[0].click(); - - }, - - onSubmit: function () { - var form = this; - - ApiClient.getServerConfiguration().done(function (config) { - - config.InternetProviderExcludeTypes = $.map($('.chkItemType:checked', form), function (currentCheckbox) { - - return currentCheckbox.getAttribute('data-itemtype'); - }); - - ApiClient.updateServerConfiguration(config); - }); - - // Disable default form submission - return false; - } -}; - -$(document).on('pageshow', "#advancedMetadataConfigurationPage", AdvancedMetadataConfigurationPage.onPageShow); \ No newline at end of file diff --git a/MediaBrowser.WebDashboard/Html/scripts/DashboardPage.js b/MediaBrowser.WebDashboard/Html/scripts/DashboardPage.js deleted file mode 100644 index 47ff3b0c1..000000000 --- a/MediaBrowser.WebDashboard/Html/scripts/DashboardPage.js +++ /dev/null @@ -1,462 +0,0 @@ -var DashboardPage = { - - onPageShow: function () { - - Dashboard.showLoadingMsg(); - DashboardPage.pollForInfo(); - DashboardPage.startInterval(); - $(document).on("websocketmessage", DashboardPage.onWebSocketMessage).on("websocketopen", DashboardPage.onWebSocketConnectionChange).on("websocketerror", DashboardPage.onWebSocketConnectionChange).on("websocketclose", DashboardPage.onWebSocketConnectionChange); - - DashboardPage.lastAppUpdateCheck = null; - DashboardPage.lastPluginUpdateCheck = null; - }, - - onPageHide: function () { - - $(document).off("websocketmessage", DashboardPage.onWebSocketMessage).off("websocketopen", DashboardPage.onWebSocketConnectionChange).off("websocketerror", DashboardPage.onWebSocketConnectionChange).off("websocketclose", DashboardPage.onWebSocketConnectionChange); - DashboardPage.stopInterval(); - }, - - startInterval: function () { - - if (Dashboard.isWebSocketOpen()) { - Dashboard.sendWebSocketMessage("DashboardInfoStart", "0,1500"); - } - }, - - stopInterval: function () { - - if (Dashboard.isWebSocketOpen()) { - Dashboard.sendWebSocketMessage("DashboardInfoStop"); - } - }, - - onWebSocketMessage: function (e, msg) { - - if (msg.MessageType == "DashboardInfo") { - DashboardPage.renderInfo(msg.Data); - } - }, - - onWebSocketConnectionChange: function () { - - DashboardPage.stopInterval(); - DashboardPage.startInterval(); - }, - - pollForInfo: function () { - $.getJSON("dashboardInfo").done(DashboardPage.renderInfo); - }, - - renderInfo: function (dashboardInfo) { - - DashboardPage.lastDashboardInfo = dashboardInfo; - - DashboardPage.renderRunningTasks(dashboardInfo); - DashboardPage.renderSystemInfo(dashboardInfo); - DashboardPage.renderActiveConnections(dashboardInfo); - - Dashboard.hideLoadingMsg(); - }, - - renderActiveConnections: function (dashboardInfo) { - - var page = $.mobile.activePage; - - var html = ''; - - if (!dashboardInfo.ActiveConnections.length) { - html += '

There are no users currently connected.

'; - $('#divConnections', page).html(html).trigger('create'); - return; - } - - html += ''; - - for (var i = 0, length = dashboardInfo.ActiveConnections.length; i < length; i++) { - - var connection = dashboardInfo.ActiveConnections[i]; - - var user = dashboardInfo.Users.filter(function (u) { - return u.Id == connection.UserId; - })[0]; - - html += ''; - - html += ''; - - html += ''; - - html += ''; - - html += ''; - - html += ''; - - html += ''; - - } - - html += '
'; - html += DashboardPage.getClientType(connection); - html += ''; - html += user.Name; - html += ''; - html += connection.DeviceName; - html += ''; - html += DashboardPage.getNowPlayingImage(connection.NowPlayingItem); - html += ''; - html += DashboardPage.getNowPlayingText(connection, connection.NowPlayingItem); - html += '
'; - - $('#divConnections', page).html(html); - }, - - getClientType: function (connection) { - - var clientLowered = connection.Client.toLowerCase(); - - if (clientLowered == "dashboard") { - - return "Dashboard"; - } - if (clientLowered == "media browser classic") { - - return "Media Browser Classic"; - } - if (clientLowered == "media browser theater") { - - return "Media Browser Theater"; - } - if (clientLowered == "android") { - - return "Android"; - } - if (clientLowered == "ios") { - - return "iOS"; - } - if (clientLowered == "windows rt") { - - return "Windows RT"; - } - if (clientLowered == "windows phone") { - - return "Windows Phone"; - } - if (clientLowered == "dlna") { - - return "Dlna"; - } - - return connection.Client; - }, - - getNowPlayingImage: function (item) { - - if (item) { - - if (item.BackdropImageTag) { - var url = ApiClient.getImageUrl(item.Id, { - type: "Backdrop", - height: 100, - tag: item.BackdropImageTag - }); - - return "" + item.Name + ""; - } - else if (item.PrimaryImageTag) { - - var url = ApiClient.getImageUrl(item.Id, { - type: "Primary", - height: 100, - tag: item.PrimaryImageTag - }); - - return "" + item.Name + ""; - } - } - - return ""; - }, - - getNowPlayingText: function (connection, item) { - - var html = ""; - - if (item) { - - html += "
" + item.Name + "
"; - - html += "
"; - - if (item.RunTimeTicks) { - html += DashboardPage.getDisplayText(connection.NowPlayingPositionTicks || 0) + " / "; - - html += DashboardPage.getDisplayText(item.RunTimeTicks); - } - - html += "
"; - } - - return html; - }, - - getDisplayText: function (ticks) { - - var ticksPerHour = 36000000000; - - var parts = []; - - var hours = ticks / ticksPerHour; - hours = parseInt(hours); - - if (hours) { - parts.push(hours); - } - - ticks -= (hours * ticksPerHour); - - var ticksPerMinute = 600000000; - - var minutes = ticks / ticksPerMinute; - minutes = parseInt(minutes); - - ticks -= (minutes * ticksPerMinute); - - if (minutes < 10) { - minutes = '0' + minutes; - } - parts.push(minutes); - - var ticksPerSecond = 10000000; - - var seconds = ticks / ticksPerSecond; - seconds = parseInt(seconds); - - if (seconds < 10) { - seconds = '0' + seconds; - } - parts.push(seconds); - - return parts.join(':'); - }, - - renderRunningTasks: function (dashboardInfo) { - - var page = $.mobile.activePage; - - var html = ''; - - if (!dashboardInfo.RunningTasks.length) { - html += '

No tasks are currently running.

'; - } - - for (var i = 0, length = dashboardInfo.RunningTasks.length; i < length; i++) { - - - var task = dashboardInfo.RunningTasks[i]; - - html += '

'; - - html += task.Name; - - if (task.State == "Running") { - var progress = Math.round(task.CurrentProgressPercentage || 0); - html += ' - ' + progress + '%'; - - html += ''; - } - else if (task.State == "Cancelling") { - html += ' - Stopping'; - } - - html += '

'; - } - - - $('#divRunningTasks', page).html(html).trigger('create'); - }, - - renderSystemInfo: function (dashboardInfo) { - - Dashboard.updateSystemInfo(dashboardInfo.SystemInfo); - - var page = $.mobile.activePage; - - $('#appVersionNumber', page).html(dashboardInfo.SystemInfo.Version); - - if (dashboardInfo.RunningTasks.filter(function (task) { - - return task.Id == dashboardInfo.ApplicationUpdateTaskId; - - }).length) { - - $('#btnUpdateApplication', page).button('disable'); - } else { - $('#btnUpdateApplication', page).button('enable'); - } - - DashboardPage.renderApplicationUpdateInfo(dashboardInfo); - DashboardPage.renderPluginUpdateInfo(dashboardInfo); - DashboardPage.renderPendingInstallations(dashboardInfo.SystemInfo); - }, - - renderApplicationUpdateInfo: function (dashboardInfo) { - - var page = $.mobile.activePage; - - if (dashboardInfo.SystemInfo.IsNetworkDeployed && !dashboardInfo.SystemInfo.HasPendingRestart) { - - // Only check once every 10 mins - if (DashboardPage.lastAppUpdateCheck && (new Date().getTime() - DashboardPage.lastAppUpdateCheck) < 600000) { - return; - } - - DashboardPage.lastAppUpdateCheck = new Date().getTime(); - - ApiClient.getAvailableApplicationUpdate().done(function (packageInfo) { - - var version = packageInfo[0]; - - if (!version) { - $('#pUpToDate', page).show(); - $('#pUpdateNow', page).hide(); - } else { - $('#pUpToDate', page).hide(); - - $('#pUpdateNow', page).show(); - - $('#newVersionNumber', page).html("Version " + version.versionStr + " is now available for download."); - } - - }).fail(function () { - - Dashboard.showFooterNotification({ html: 'There was an error connecting to the remote Media Browser repository.', id: "MB3ConnectionError" }); - - }); - - } else { - - if (dashboardInfo.SystemInfo.HasPendingRestart) { - $('#pUpToDate', page).hide(); - } else { - $('#pUpToDate', page).show(); - } - - $('#pUpdateNow', page).hide(); - } - }, - - renderPendingInstallations: function (systemInfo) { - - var page = $.mobile.activePage; - - if (systemInfo.CompletedInstallations.length) { - - $('#collapsiblePendingInstallations', page).show(); - - } else { - $('#collapsiblePendingInstallations', page).hide(); - - return; - } - - var html = ''; - - for (var i = 0, length = systemInfo.CompletedInstallations.length; i < length; i++) { - - var update = systemInfo.CompletedInstallations[i]; - - html += '
' + update.Name + ' (' + update.Version + ')
'; - } - - $('#pendingInstallations', page).html(html); - }, - - renderPluginUpdateInfo: function (dashboardInfo) { - - // Only check once every 10 mins - if (DashboardPage.lastPluginUpdateCheck && (new Date().getTime() - DashboardPage.lastPluginUpdateCheck) < 600000) { - return; - } - - DashboardPage.lastPluginUpdateCheck = new Date().getTime(); - - var page = $.mobile.activePage; - - ApiClient.getAvailablePluginUpdates().done(function (updates) { - - var elem = $('#pPluginUpdates', page); - - if (updates.length) { - - elem.show(); - - } else { - elem.hide(); - - return; - } - var html = ''; - - for (var i = 0, length = updates.length; i < length; i++) { - - var update = updates[i]; - - html += '

A new version of ' + update.name + ' is available!

'; - - html += ''; - } - - elem.html(html).trigger('create'); - - }).fail(function () { - - Dashboard.showFooterNotification({ html: 'There was an error connecting to the remote Media Browser repository.', id: "MB3ConnectionError" }); - - }); - }, - - installPluginUpdate: function (button) { - - $(button).button('disable'); - - var name = button.getAttribute('data-name'); - var version = button.getAttribute('data-version'); - var classification = button.getAttribute('data-classification'); - - Dashboard.showLoadingMsg(); - - ApiClient.installPlugin(name, classification, version).done(function () { - - Dashboard.hideLoadingMsg(); - }); - }, - - updateApplication: function () { - - var page = $.mobile.activePage; - $('#btnUpdateApplication', page).button('disable'); - - Dashboard.showLoadingMsg(); - - ApiClient.startScheduledTask(DashboardPage.lastDashboardInfo.ApplicationUpdateTaskId).done(function () { - - DashboardPage.pollForInfo(); - - Dashboard.hideLoadingMsg(); - }); - }, - - stopTask: function (id) { - - ApiClient.stopScheduledTask(id).done(function () { - - DashboardPage.pollForInfo(); - }); - - } -}; - -$(document).on('pageshow', "#dashboardPage", DashboardPage.onPageShow).on('pagehide', "#dashboardPage", DashboardPage.onPageHide); \ No newline at end of file diff --git a/MediaBrowser.WebDashboard/Html/scripts/DisplaySettingsPage.js b/MediaBrowser.WebDashboard/Html/scripts/DisplaySettingsPage.js deleted file mode 100644 index da87a106f..000000000 --- a/MediaBrowser.WebDashboard/Html/scripts/DisplaySettingsPage.js +++ /dev/null @@ -1,46 +0,0 @@ -var DisplaySettingsPage = { - - onPageShow: function () { - Dashboard.showLoadingMsg(); - - var page = this; - - ApiClient.getServerConfiguration().done(function (config) { - - $('#txtWeatherLocation', page).val(config.WeatherLocation); - $('#txtMinResumePct', page).val(config.MinResumePct); - $('#txtMaxResumePct', page).val(config.MaxResumePct); - $('#txtMinResumeDuration', page).val(config.MinResumeDurationSeconds); - $('#selectWeatherUnit', page).val(config.WeatherUnit).selectmenu("refresh"); - - Dashboard.hideLoadingMsg(); - }); - - }, - - submit: function() { - - $('.btnSubmit', $.mobile.activePage)[0].click(); - - }, - - onSubmit: function () { - var form = this; - - ApiClient.getServerConfiguration().done(function (config) { - - config.WeatherLocation = $('#txtWeatherLocation', form).val(); - config.WeatherUnit = $('#selectWeatherUnit', form).val(); - config.MinResumePct = $('#txtMinResumePct', form).val(); - config.MaxResumePct = $('#txtMaxResumePct', form).val(); - config.MinResumeDurationSeconds = $('#txtMinResumeDuration', form).val(); - - ApiClient.updateServerConfiguration(config); - }); - - // Disable default form submission - return false; - } -}; - -$(document).on('pageshow', "#displaySettingsPage", DisplaySettingsPage.onPageShow); diff --git a/MediaBrowser.WebDashboard/Html/scripts/EditUserPage.js b/MediaBrowser.WebDashboard/Html/scripts/EditUserPage.js deleted file mode 100644 index 0d362e5de..000000000 --- a/MediaBrowser.WebDashboard/Html/scripts/EditUserPage.js +++ /dev/null @@ -1,175 +0,0 @@ -var EditUserPage = { - - onPageShow: function () { - Dashboard.showLoadingMsg(); - - var userId = getParameterByName("userId"); - - if (userId) { - $('#userProfileNavigation', this).show(); - } else { - $('#userProfileNavigation', this).hide(); - } - - var promise4 = ApiClient.getCultures(); - - var promise3 = ApiClient.getParentalRatings(); - - var promise1; - - if (!userId) { - - var deferred = $.Deferred(); - - deferred.resolveWith(null, [{ - Configuration: {} - }]); - - promise1 = deferred.promise(); - } else { - - promise1 = ApiClient.getUser(userId); - } - - var promise2 = Dashboard.getCurrentUser(); - - $.when(promise1, promise2, promise3, promise4).done(function (response1, response2, response3, response4) { - - EditUserPage.loadUser(response1[0] || response1, response2[0], response3[0], response4[0]); - - }); - }, - - loadUser: function (user, loggedInUser, allParentalRatings, allCultures) { - - var page = $($.mobile.activePage); - - EditUserPage.populateLanguages($('#selectAudioLanguage', page), allCultures); - EditUserPage.populateLanguages($('#selectSubtitleLanguage', page), allCultures); - EditUserPage.populateRatings(allParentalRatings, page); - - if (!loggedInUser.Configuration.IsAdministrator || user.Id == loggedInUser.Id) { - - $('#fldIsAdmin', page).hide(); - $('#fldMaxParentalRating', page).hide(); - } else { - $('#fldIsAdmin', page).show(); - $('#fldMaxParentalRating', page).show(); - } - - Dashboard.setPageTitle(user.Name || "Add User"); - - $('#txtUserName', page).val(user.Name); - - var ratingValue = ""; - - if (user.Configuration.MaxParentalRating) { - - for (var i = 0, length = allParentalRatings.length; i < length; i++) { - - var rating = allParentalRatings[i]; - - if (user.Configuration.MaxParentalRating >= rating.Value) { - ratingValue = rating.Value; - } - } - } - - $('#selectMaxParentalRating', page).val(ratingValue).selectmenu("refresh"); - - $('#selectAudioLanguage', page).val(user.Configuration.AudioLanguagePreference || "").selectmenu("refresh"); - $('#selectSubtitleLanguage', page).val(user.Configuration.SubtitleLanguagePreference || "").selectmenu("refresh"); - - $('#chkForcedSubtitlesOnly', page).checked(user.Configuration.UseForcedSubtitlesOnly || false).checkboxradio("refresh"); - $('#chkIsAdmin', page).checked(user.Configuration.IsAdministrator || false).checkboxradio("refresh"); - - Dashboard.hideLoadingMsg(); - }, - - populateLanguages: function (select, allCultures) { - - var html = ""; - - html += ""; - - for (var i = 0, length = allCultures.length; i < length; i++) { - - var culture = allCultures[i]; - - html += ""; - } - - select.html(html).selectmenu("refresh"); - }, - - populateRatings: function (allParentalRatings, page) { - - var html = ""; - - html += ""; - - for (var i = 0, length = allParentalRatings.length; i < length; i++) { - - var rating = allParentalRatings[i]; - - html += ""; - } - - $('#selectMaxParentalRating', page).html(html).selectmenu("refresh"); - }, - - saveUser: function (user) { - - var page = $($.mobile.activePage); - - user.Name = $('#txtUserName', page).val(); - user.Configuration.MaxParentalRating = $('#selectMaxParentalRating', page).val() || null; - - user.Configuration.IsAdministrator = $('#chkIsAdmin', page).checked(); - - user.Configuration.AudioLanguagePreference = $('#selectAudioLanguage', page).val(); - user.Configuration.SubtitleLanguagePreference = $('#selectSubtitleLanguage', page).val(); - user.Configuration.UseForcedSubtitlesOnly = $('#chkForcedSubtitlesOnly', page).checked(); - - var userId = getParameterByName("userId"); - - if (userId) { - ApiClient.updateUser(user).done(EditUserPage.saveComplete); - } else { - ApiClient.createUser(user).done(EditUserPage.saveComplete); - } - }, - - saveComplete: function () { - Dashboard.hideLoadingMsg(); - - var userId = getParameterByName("userId"); - - Dashboard.validateCurrentUser(); - - if (userId) { - Dashboard.alert("Settings saved."); - } else { - Dashboard.navigate("userProfiles.html"); - } - }, - - onSubmit: function () { - Dashboard.showLoadingMsg(); - - var userId = getParameterByName("userId"); - - if (!userId) { - EditUserPage.saveUser({ - Configuration: {} - }); - } else { - ApiClient.getUser(userId).done(EditUserPage.saveUser); - } - - // Disable default form submission - return false; - } -}; - -$(document).on('pageshow', "#editUserPage", EditUserPage.onPageShow); diff --git a/MediaBrowser.WebDashboard/Html/scripts/Extensions.js b/MediaBrowser.WebDashboard/Html/scripts/Extensions.js deleted file mode 100644 index 699ad6143..000000000 --- a/MediaBrowser.WebDashboard/Html/scripts/Extensions.js +++ /dev/null @@ -1,506 +0,0 @@ -// Array Remove - By John Resig (MIT Licensed) -Array.prototype.remove = function (from, to) { - var rest = this.slice((to || from) + 1 || this.length); - this.length = from < 0 ? this.length + from : from; - return this.push.apply(this, rest); -}; - -String.prototype.endsWith = function (suffix) { - return this.indexOf(suffix, this.length - suffix.length) !== -1; -}; - -$.fn.checked = function (value) { - if (value === true || value === false) { - // Set the value of the checkbox - return $(this).each(function () { - this.checked = value; - }); - } else { - // Return check state - return $(this).is(':checked'); - } -}; - -var WebNotifications = { - - show: function (data) { - if (window.webkitNotifications) { - if (!webkitNotifications.checkPermission()) { - var notif = webkitNotifications.createNotification(data.icon, data.title, data.body); - notif.show(); - - if (data.timeout) { - setTimeout(function () { - notif.cancel(); - }, data.timeout); - } - - return notif; - } else { - webkitNotifications.requestPermission(function () { - return WebNotifications.show(data); - }); - } - } - else if (window.Notification) { - if (Notification.permissionLevel() === "granted") { - var notif = new Notification(data.title, data); - notif.show(); - - if (data.timeout) { - setTimeout(function () { - notif.cancel(); - }, data.timeout); - } - - return notif; - } else if (Notification.permissionLevel() === "default") { - Notification.requestPermission(function () { - return WebNotifications.show(data); - }); - } - } - }, - - requestPermission: function () { - if (window.webkitNotifications) { - if (!webkitNotifications.checkPermission()) { - } else { - webkitNotifications.requestPermission(function () { - }); - } - } - else if (window.Notification) { - if (Notification.permissionLevel() === "granted") { - } else if (Notification.permissionLevel() === "default") { - Notification.requestPermission(function () { - }); - } - } - } -}; - -/* - * Javascript Humane Dates - * Copyright (c) 2008 Dean Landolt (deanlandolt.com) - * Re-write by Zach Leatherman (zachleat.com) - * - * Adopted from the John Resig's pretty.js - * at http://ejohn.org/blog/javascript-pretty-date - * and henrah's proposed modification - * at http://ejohn.org/blog/javascript-pretty-date/#comment-297458 - * - * Licensed under the MIT license. - */ - -function humane_date(date_str) { - var time_formats = [[90, 'a minute'], // 60*1.5 - [3600, 'minutes', 60], // 60*60, 60 - [5400, 'an hour'], // 60*60*1.5 - [86400, 'hours', 3600], // 60*60*24, 60*60 - [129600, 'a day'], // 60*60*24*1.5 - [604800, 'days', 86400], // 60*60*24*7, 60*60*24 - [907200, 'a week'], // 60*60*24*7*1.5 - [2628000, 'weeks', 604800], // 60*60*24*(365/12), 60*60*24*7 - [3942000, 'a month'], // 60*60*24*(365/12)*1.5 - [31536000, 'months', 2628000], // 60*60*24*365, 60*60*24*(365/12) - [47304000, 'a year'], // 60*60*24*365*1.5 - [3153600000, 'years', 31536000] // 60*60*24*365*100, 60*60*24*365 - ]; - - var dt = new Date; - var date = parseISO8601Date(date_str, true); - - var seconds = ((dt - date) / 1000); - var token = ' ago'; - var i = 0; - var format; - - if (seconds < 0) { - seconds = Math.abs(seconds); - token = ''; - } - - while (format = time_formats[i++]) { - if (seconds < format[0]) { - if (format.length == 2) { - return format[1] + token; - } else { - return Math.round(seconds / format[2]) + ' ' + format[1] + token; - } - } - } - - // overflow for centuries - if (seconds > 4730400000) - return Math.round(seconds / 4730400000) + ' centuries' + token; - - return date_str; -}; - -function humane_elapsed(firstDateStr, secondDateStr) { - var dt1 = new Date(firstDateStr); - var dt2 = new Date(secondDateStr); - var seconds = (dt2.getTime() - dt1.getTime()) / 1000; - var numdays = Math.floor((seconds % 31536000) / 86400); - var numhours = Math.floor(((seconds % 31536000) % 86400) / 3600); - var numminutes = Math.floor((((seconds % 31536000) % 86400) % 3600) / 60); - var numseconds = Math.round((((seconds % 31536000) % 86400) % 3600) % 60); - - var elapsedStr = ''; - elapsedStr += numdays == 1 ? numdays + ' day ' : ''; - elapsedStr += numdays > 1 ? numdays + ' days ' : ''; - elapsedStr += numhours == 1 ? numhours + ' hour ' : ''; - elapsedStr += numhours > 1 ? numhours + ' hours ' : ''; - elapsedStr += numminutes == 1 ? numminutes + ' minute ' : ''; - elapsedStr += numminutes > 1 ? numminutes + ' minutes ' : ''; - elapsedStr += elapsedStr.length > 0 ? 'and ' : ''; - elapsedStr += numseconds == 1 ? numseconds + ' second' : ''; - elapsedStr += numseconds == 0 || numseconds > 1 ? numseconds + ' seconds' : ''; - - return elapsedStr; - -} - -function getParameterByName(name) { - name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); - var regexS = "[\\?&]" + name + "=([^&#]*)"; - var regex = new RegExp(regexS); - var results = regex.exec(window.location.search); - if (results == null) - return ""; - else - return decodeURIComponent(results[1].replace(/\+/g, " ")); -} - -function parseISO8601Date(s, toLocal) { - - // parenthese matches: - // year month day hours minutes seconds - // dotmilliseconds - // tzstring plusminus hours minutes - var re = /(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)(\.\d+)?(Z|([+-])(\d\d):(\d\d))/; - - var d = []; - d = s.match(re); - - // "2010-12-07T11:00:00.000-09:00" parses to: - // ["2010-12-07T11:00:00.000-09:00", "2010", "12", "07", "11", - // "00", "00", ".000", "-09:00", "-", "09", "00"] - // "2010-12-07T11:00:00.000Z" parses to: - // ["2010-12-07T11:00:00.000Z", "2010", "12", "07", "11", - // "00", "00", ".000", "Z", undefined, undefined, undefined] - - if (!d) { - throw "Couldn't parse ISO 8601 date string '" + s + "'"; - } - - // parse strings, leading zeros into proper ints - var a = [1, 2, 3, 4, 5, 6, 10, 11]; - for (var i in a) { - d[a[i]] = parseInt(d[a[i]], 10); - } - d[7] = parseFloat(d[7]); - - // Date.UTC(year, month[, date[, hrs[, min[, sec[, ms]]]]]) - // note that month is 0-11, not 1-12 - // see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/UTC - var ms = Date.UTC(d[1], d[2] - 1, d[3], d[4], d[5], d[6]); - - // if there are milliseconds, add them - if (d[7] > 0) { - ms += Math.round(d[7] * 1000); - } - - // if there's a timezone, calculate it - if (d[8] != "Z" && d[10]) { - var offset = d[10] * 60 * 60 * 1000; - if (d[11]) { - offset += d[11] * 60 * 1000; - } - if (d[9] == "-") { - ms -= offset; - } else { - ms += offset; - } - } else if (!toLocal) { - ms += new Date().getTimezoneOffset() * 60000; - } - - return new Date(ms); -}; - -/** -* -* Secure Hash Algorithm (SHA1) -* http://www.webtoolkit.info/ -* -**/ - -function SHA1(msg) { - - function rotate_left(n, s) { - var t4 = (n << s) | (n >>> (32 - s)); - return t4; - }; - - function lsb_hex(val) { - var str = ""; - var i; - var vh; - var vl; - - for (i = 0; i <= 6; i += 2) { - vh = (val >>> (i * 4 + 4)) & 0x0f; - vl = (val >>> (i * 4)) & 0x0f; - str += vh.toString(16) + vl.toString(16); - } - return str; - }; - - function cvt_hex(val) { - var str = ""; - var i; - var v; - - for (i = 7; i >= 0; i--) { - v = (val >>> (i * 4)) & 0x0f; - str += v.toString(16); - } - return str; - }; - - - function Utf8Encode(string) { - string = string.replace(/\r\n/g, "\n"); - var utftext = ""; - - for (var n = 0; n < string.length; n++) { - - var c = string.charCodeAt(n); - - if (c < 128) { - utftext += String.fromCharCode(c); - } - else if ((c > 127) && (c < 2048)) { - utftext += String.fromCharCode((c >> 6) | 192); - utftext += String.fromCharCode((c & 63) | 128); - } - else { - utftext += String.fromCharCode((c >> 12) | 224); - utftext += String.fromCharCode(((c >> 6) & 63) | 128); - utftext += String.fromCharCode((c & 63) | 128); - } - - } - - return utftext; - }; - - var blockstart; - var i, j; - var W = new Array(80); - var H0 = 0x67452301; - var H1 = 0xEFCDAB89; - var H2 = 0x98BADCFE; - var H3 = 0x10325476; - var H4 = 0xC3D2E1F0; - var A, B, C, D, E; - var temp; - - msg = Utf8Encode(msg); - - var msg_len = msg.length; - - var word_array = new Array(); - for (i = 0; i < msg_len - 3; i += 4) { - j = msg.charCodeAt(i) << 24 | msg.charCodeAt(i + 1) << 16 | - msg.charCodeAt(i + 2) << 8 | msg.charCodeAt(i + 3); - word_array.push(j); - } - - switch (msg_len % 4) { - case 0: - i = 0x080000000; - break; - case 1: - i = msg.charCodeAt(msg_len - 1) << 24 | 0x0800000; - break; - - case 2: - i = msg.charCodeAt(msg_len - 2) << 24 | msg.charCodeAt(msg_len - 1) << 16 | 0x08000; - break; - - case 3: - i = msg.charCodeAt(msg_len - 3) << 24 | msg.charCodeAt(msg_len - 2) << 16 | msg.charCodeAt(msg_len - 1) << 8 | 0x80; - break; - } - - word_array.push(i); - - while ((word_array.length % 16) != 14) word_array.push(0); - - word_array.push(msg_len >>> 29); - word_array.push((msg_len << 3) & 0x0ffffffff); - - - for (blockstart = 0; blockstart < word_array.length; blockstart += 16) { - - for (i = 0; i < 16; i++) W[i] = word_array[blockstart + i]; - for (i = 16; i <= 79; i++) W[i] = rotate_left(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1); - - A = H0; - B = H1; - C = H2; - D = H3; - E = H4; - - for (i = 0; i <= 19; i++) { - temp = (rotate_left(A, 5) + ((B & C) | (~B & D)) + E + W[i] + 0x5A827999) & 0x0ffffffff; - E = D; - D = C; - C = rotate_left(B, 30); - B = A; - A = temp; - } - - for (i = 20; i <= 39; i++) { - temp = (rotate_left(A, 5) + (B ^ C ^ D) + E + W[i] + 0x6ED9EBA1) & 0x0ffffffff; - E = D; - D = C; - C = rotate_left(B, 30); - B = A; - A = temp; - } - - for (i = 40; i <= 59; i++) { - temp = (rotate_left(A, 5) + ((B & C) | (B & D) | (C & D)) + E + W[i] + 0x8F1BBCDC) & 0x0ffffffff; - E = D; - D = C; - C = rotate_left(B, 30); - B = A; - A = temp; - } - - for (i = 60; i <= 79; i++) { - temp = (rotate_left(A, 5) + (B ^ C ^ D) + E + W[i] + 0xCA62C1D6) & 0x0ffffffff; - E = D; - D = C; - C = rotate_left(B, 30); - B = A; - A = temp; - } - - H0 = (H0 + A) & 0x0ffffffff; - H1 = (H1 + B) & 0x0ffffffff; - H2 = (H2 + C) & 0x0ffffffff; - H3 = (H3 + D) & 0x0ffffffff; - H4 = (H4 + E) & 0x0ffffffff; - - } - - var temp = cvt_hex(H0) + cvt_hex(H1) + cvt_hex(H2) + cvt_hex(H3) + cvt_hex(H4); - - return temp.toLowerCase(); - -} - -// jqm.page.params.js - version 0.1 -// Copyright (c) 2011, Kin Blas -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -(function ($, window, undefined) { - - // Given a query string, convert all the name/value pairs - // into a property/value object. If a name appears more than - // once in a query string, the value is automatically turned - // into an array. - function queryStringToObject(qstr) { - var result = {}, nvPairs = ((qstr || "").replace(/^\?/, "").split(/&/)), i, pair, n, v; - - for (i = 0; i < nvPairs.length; i++) { - var pstr = nvPairs[i]; - if (pstr) { - pair = pstr.split(/=/); - n = pair[0]; - v = pair[1]; - if (result[n] === undefined) { - result[n] = v; - } else { - if (typeof result[n] !== "object") { - result[n] = [result[n]]; - } - result[n].push(v); - } - } - } - - return result; - } - - // The idea here is to listen for any pagebeforechange notifications from - // jQuery Mobile, and then muck with the toPage and options so that query - // params can be passed to embedded/internal pages. So for example, if a - // changePage() request for a URL like: - // - // http://mycompany.com/myapp/#page-1?foo=1&bar=2 - // - // is made, the page that will actually get shown is: - // - // http://mycompany.com/myapp/#page-1 - // - // The browser's location will still be updated to show the original URL. - // The query params for the embedded page are also added as a property/value - // object on the options object. You can access it from your page notifications - // via data.options.pageData. - $(document).bind("pagebeforechange", function (e, data) { - - // We only want to handle the case where we are being asked - // to go to a page by URL, and only if that URL is referring - // to an internal page by id. - - if (typeof data.toPage === "string") { - var u = $.mobile.path.parseUrl(data.toPage); - if ($.mobile.path.isEmbeddedPage(u)) { - - // The request is for an internal page, if the hash - // contains query (search) params, strip them off the - // toPage URL and then set options.dataUrl appropriately - // so the location.hash shows the originally requested URL - // that hash the query params in the hash. - - var u2 = $.mobile.path.parseUrl(u.hash.replace(/^#/, "")); - if (u2.search) { - if (!data.options.dataUrl) { - data.options.dataUrl = data.toPage; - } - data.options.pageData = queryStringToObject(u2.search); - data.toPage = u.hrefNoHash + "#" + u2.pathname; - } - } - } - }); - -})(jQuery, window); \ No newline at end of file diff --git a/MediaBrowser.WebDashboard/Html/scripts/IndexPage.js b/MediaBrowser.WebDashboard/Html/scripts/IndexPage.js deleted file mode 100644 index ee84e07de..000000000 --- a/MediaBrowser.WebDashboard/Html/scripts/IndexPage.js +++ /dev/null @@ -1,106 +0,0 @@ -var IndexPage = { - - onPageShow: function () { - IndexPage.loadLibrary(Dashboard.getCurrentUserId(), this); - }, - - loadLibrary: function (userId, page) { - - if (!userId) { - return; - } - - page = $(page); - - var options = { - - limit: 5, - sortBy: "DateCreated", - sortOrder: "Descending", - filters: "IsRecentlyAdded,IsNotFolder", - ImageTypes: "Primary,Backdrop,Thumb", - recursive: true - }; - - ApiClient.getItems(userId, options).done(function (result) { - - $('#divWhatsNew', page).html(Dashboard.getPosterViewHtml({ - items: result.Items, - preferBackdrop: true, - showTitle: true - })); - - }); - - options = { - - limit: 5, - sortBy: "DatePlayed", - sortOrder: "Descending", - filters: "IsResumable", - recursive: true - }; - - ApiClient.getItems(userId, options).done(function (result) { - - $('#divResumableItems', page).html(Dashboard.getPosterViewHtml({ - items: result.Items, - preferBackdrop: true, - showTitle: true - })); - - if (result.Items.length) { - $('#divResumable', page).show(); - } else { - $('#divResumable', page).hide(); - } - - }); - - options = { - - sortBy: "SortName" - }; - - ApiClient.getItems(userId, options).done(function (result) { - - $('#divCollections', page).html(Dashboard.getPosterViewHtml({ - items: result.Items, - showTitle: true - })); - - }); - - IndexPage.loadMyLibrary(userId, page); - }, - - loadMyLibrary: function (userId, page) { - - var items = [{ - Name: "Recently Played", - IsFolder: true - }, { - Name: "Favorites", - IsFolder: true - }, { - Name: "Genres", - IsFolder: true - }, { - Name: "Studios", - IsFolder: true - }, { - Name: "Performers", - IsFolder: true - }, { - Name: "Directors", - IsFolder: true - }]; - - $('#divMyLibrary', page).html(Dashboard.getPosterViewHtml({ - items: items, - showTitle: true - })); - } -}; - -$(document).on('pageshow', "#indexPage", IndexPage.onPageShow); \ No newline at end of file diff --git a/MediaBrowser.WebDashboard/Html/scripts/ItemDetailPage.js b/MediaBrowser.WebDashboard/Html/scripts/ItemDetailPage.js deleted file mode 100644 index 8a97943b0..000000000 --- a/MediaBrowser.WebDashboard/Html/scripts/ItemDetailPage.js +++ /dev/null @@ -1,376 +0,0 @@ -var ItemDetailPage = { - - onPageShow: function () { - - ItemDetailPage.reload(); - - $('#galleryCollapsible', this).on('expand', ItemDetailPage.onGalleryExpand); - }, - - onPageHide: function () { - - $('#galleryCollapsible', this).off('expand', ItemDetailPage.onGalleryExpand); - - ItemDetailPage.item = null; - }, - - reload: function () { - var id = getParameterByName('id'); - - Dashboard.showLoadingMsg(); - - ApiClient.getItem(Dashboard.getCurrentUserId(), id).done(ItemDetailPage.renderItem); - }, - - renderItem: function (item) { - - ItemDetailPage.item = item; - - var page = $.mobile.activePage; - - ItemDetailPage.item = item; - - var name = item.Name; - - if (item.IndexNumber != null) { - name = item.IndexNumber + " - " + name; - } - - Dashboard.setPageTitle(name); - - ItemDetailPage.renderImage(item); - ItemDetailPage.renderOverviewBlock(item); - ItemDetailPage.renderScenes(item); - ItemDetailPage.renderMediaInfo(item); - - $('#itemName', page).html(name); - - Dashboard.hideLoadingMsg(); - }, - - renderImage: function (item) { - - var page = $.mobile.activePage; - - var imageTags = item.ImageTags || {}; - - var html = ''; - - var url; - var useBackgroundColor; - - if (imageTags.Primary) { - - url = ApiClient.getImageUrl(item.Id, { - type: "Primary", - width: 800, - tag: item.ImageTags.Primary - }); - } - else if (item.BackdropImageTags && item.BackdropImageTags.length) { - - url = ApiClient.getImageUrl(item.Id, { - type: "Backdrop", - width: 800, - tag: item.BackdropImageTags[0] - }); - } - else if (imageTags.Thumb) { - - url = ApiClient.getImageUrl(item.Id, { - type: "Thumb", - width: 800, - tag: item.ImageTags.Thumb - }); - } - else if (imageTags.Disc) { - - url = ApiClient.getImageUrl(item.Id, { - type: "Disc", - width: 800, - tag: item.ImageTags.Disc - }); - } - else if (item.MediaType == "Audio") { - url = "css/images/itemDetails/audioDefault.png"; - useBackgroundColor = true; - } - else if (item.MediaType == "Game") { - url = "css/images/itemDetails/gameDefault.png"; - useBackgroundColor = true; - } - else { - url = "css/images/itemDetails/videoDefault.png"; - useBackgroundColor = true; - } - - if (url) { - - var style = useBackgroundColor ? "background-color:" + Dashboard.getRandomMetroColor() + ";" : ""; - - html += ""; - } - - $('#itemImage', page).html(html); - }, - - renderOverviewBlock: function (item) { - - var page = $.mobile.activePage; - - if (item.Taglines && item.Taglines.length) { - $('#itemTagline', page).html(item.Taglines[0]).show(); - } else { - $('#itemTagline', page).hide(); - } - - if (item.Overview) { - $('#itemOverview', page).html(item.Overview).show(); - } else { - $('#itemOverview', page).hide(); - } - - if (item.CommunityRating) { - $('#itemCommunityRating', page).html(ItemDetailPage.getStarRating(item)).show().attr('title', item.CommunityRating); - } else { - $('#itemCommunityRating', page).hide(); - } - - if (MediaPlayer.canPlay(item)) { - $('#btnPlay', page).show(); - $('#playButtonShadow', page).show(); - } else { - $('#btnPlay', page).hide(); - $('#playButtonShadow', page).hide(); - } - - var miscInfo = []; - - if (item.ProductionYear) { - miscInfo.push(item.ProductionYear); - } - - if (item.OfficialRating) { - miscInfo.push(item.OfficialRating); - } - - if (item.RunTimeTicks) { - - var minutes = item.RunTimeTicks / 600000000; - - minutes = minutes || 1; - - miscInfo.push(parseInt(minutes) + "min"); - } - - if (item.DisplayMediaType) { - miscInfo.push(item.DisplayMediaType); - } - - if (item.VideoFormat && item.VideoFormat !== 'Standard') { - miscInfo.push(item.VideoFormat); - } - - $('#itemMiscInfo', page).html(miscInfo.join('     ')); - - ItemDetailPage.renderGenres(item); - ItemDetailPage.renderStudios(item); - }, - - renderGenres: function (item) { - - var page = $.mobile.activePage; - - if (item.Genres && item.Genres.length) { - var elem = $('#itemGenres', page).show(); - - var html = 'Genres:  '; - - for (var i = 0, length = item.Genres.length; i < length; i++) { - - if (i > 0) { - html += '  /  '; - } - - html += '' + item.Genres[i] + ''; - } - - elem.html(html); - - - } else { - $('#itemGenres', page).hide(); - } - }, - - renderStudios: function (item) { - - var page = $.mobile.activePage; - - if (item.Studios && item.Studios.length) { - var elem = $('#itemStudios', page).show(); - - var html = 'Studios:  '; - - for (var i = 0, length = item.Studios.length; i < length; i++) { - - if (i > 0) { - html += '  /  '; - } - - html += '' + item.Studios[i] + ''; - } - - elem.html(html); - - - } else { - $('#itemStudios', page).hide(); - } - }, - - getStarRating: function (item) { - var rating = item.CommunityRating; - - var html = ""; - for (var i = 1; i <= 10; i++) { - if (rating < i - 1) { - html += "
"; - } - else if (rating < i) { - html += "
"; - } - else { - html += "
"; - } - } - - return html; - }, - - renderScenes: function (item) { - - var html = ''; - - var page = $.mobile.activePage; - - if (!item.Chapters || !item.Chapters.length) { - $('#scenesCollapsible', page).hide(); - $('#scenesContent', page).html(html); - return; - } - - for (var i = 0, length = item.Chapters.length; i < length; i++) { - - var chapter = item.Chapters[i]; - - - } - - $('#scenesCollapsible', page).show(); - $('#scenesContent', page).html(html); - }, - - play: function () { - MediaPlayer.play([ItemDetailPage.item]); - }, - - onGalleryExpand: function() { - - if (ItemDetailPage.item) { - - ItemDetailPage.renderGallery(ItemDetailPage.item); - - $(this).off('expand', ItemDetailPage.onGalleryExpand); - } - }, - - renderGallery: function (item) { - - var page = $.mobile.activePage; - - var imageTags = item.ImageTags || {}; - - var html = ''; - - var downloadWidth = 400; - - if (imageTags.Logo) { - - html += ''; - } - if (imageTags.Thumb) { - - html += ''; - } - if (imageTags.Art) { - - html += ''; - } - if (imageTags.Menu) { - - html += ''; - } - if (imageTags.Disc) { - - html += ''; - } - if (imageTags.Box) { - - html += ''; - } - - if (item.BackdropImageTags) { - - for (var i = 0, length = item.BackdropImageTags.length; i < length; i++) { - html += ''; - } - - } - - $('#galleryContent', page).html(html); - }, - - renderMediaInfo: function(item) { - - var page = $.mobile.activePage; - - if (!item.MediaStreams || !item.MediaStreams.length) { - $('#mediaInfoCollapsible', page).hide(); - return; - } - - $('#mediaInfoCollapsible', page).show(); - } -}; - -$(document).on('pageshow', "#itemDetailPage", ItemDetailPage.onPageShow).on('pagehide', "#itemDetailPage", ItemDetailPage.onPageHide); diff --git a/MediaBrowser.WebDashboard/Html/scripts/ItemListPage.js b/MediaBrowser.WebDashboard/Html/scripts/ItemListPage.js deleted file mode 100644 index bf89fa813..000000000 --- a/MediaBrowser.WebDashboard/Html/scripts/ItemListPage.js +++ /dev/null @@ -1,46 +0,0 @@ -var ItemListPage = { - - onPageShow: function () { - - ItemListPage.reload(); - }, - - reload: function () { - - var userId = Dashboard.getCurrentUserId(); - - var parentId = getParameterByName('parentId'); - - var query = {}; - - if (parentId) { - query.parentId = parentId; - - ApiClient.getItem(userId, parentId).done(ItemListPage.renderTitle); - } - - ApiClient.getItems(userId, query).done(ItemListPage.renderItems); - }, - - renderItems: function(result) { - - var items = result.Items; - - var renderOptions = { - - items: items - }; - - var html = Dashboard.getPosterViewHtml(renderOptions); - - $('#listItems', $.mobile.activePage).html(html); - }, - - renderTitle: function (item) { - - - $('#itemName', $.mobile.activePage).html(item.Name); - } -}; - -$(document).on('pageshow', "#itemListPage", ItemListPage.onPageShow); diff --git a/MediaBrowser.WebDashboard/Html/scripts/LogPage.js b/MediaBrowser.WebDashboard/Html/scripts/LogPage.js deleted file mode 100644 index 133eb34fb..000000000 --- a/MediaBrowser.WebDashboard/Html/scripts/LogPage.js +++ /dev/null @@ -1,86 +0,0 @@ -var LogPage = { - - onPageShow: function () { - - LogPage.startLine = 0; - - $('#logContents', this).html(''); - - $(document).on("websocketmessage", LogPage.onWebSocketMessage).on("websocketopen", LogPage.onWebSocketConnectionChange).on("websocketerror", LogPage.onWebSocketConnectionChange).on("websocketclose", LogPage.onWebSocketConnectionChange); - - LogPage.startInterval(); - - var autoScroll = localStorage.getItem("autoScrollLogPage"); - - if (autoScroll == "true") { - LogPage.updateAutoScroll(true); - } - else if (autoScroll == "false") { - LogPage.updateAutoScroll(false); - } - }, - - onPageHide: function () { - - $(document).off("websocketmessage", LogPage.onWebSocketMessage).off("websocketopen", LogPage.onWebSocketConnectionChange).off("websocketerror", LogPage.onWebSocketConnectionChange).off("websocketclose", LogPage.onWebSocketConnectionChange); - - LogPage.stopInterval(); - }, - - startInterval: function () { - - if (Dashboard.isWebSocketOpen()) { - Dashboard.sendWebSocketMessage("LogFileStart", "0,2000"); - } - }, - - stopInterval: function () { - - if (Dashboard.isWebSocketOpen()) { - Dashboard.sendWebSocketMessage("LogFileStop"); - } - }, - - onWebSocketConnectionChange: function () { - LogPage.stopInterval(); - LogPage.startInterval(); - }, - - onWebSocketMessage: function (e, msg) { - - if (msg.MessageType == "LogFile") { - LogPage.appendLines(msg.Data); - } - }, - - appendLines: function (lines) { - - if (!lines.length) { - return; - } - - LogPage.startLine += lines.length; - - lines = lines.join('\n') + '\n'; - - var elem = $('#logContents', $.mobile.activePage).append(lines)[0]; - - elem.style.height = (elem.scrollHeight) + 'px'; - - if ($('#chkAutoScroll', $.mobile.activePage).checked()) { - $('html, body').animate({ scrollTop: $(document).height() }, 'slow'); - } - }, - - updateAutoScroll: function (value) { - - var page = $.mobile.activePage; - - $('#chkAutoScrollBottom', page).checked(value).checkboxradio('refresh'); - $('#chkAutoScroll', page).checked(value).checkboxradio('refresh'); - - localStorage.setItem("autoScrollLogPage", value.toString()); - } -}; - -$(document).on('pageshow', "#logPage", LogPage.onPageShow).on('pagehide', "#logPage", LogPage.onPageHide); \ No newline at end of file diff --git a/MediaBrowser.WebDashboard/Html/scripts/LoginPage.js b/MediaBrowser.WebDashboard/Html/scripts/LoginPage.js deleted file mode 100644 index 5c17b90cb..000000000 --- a/MediaBrowser.WebDashboard/Html/scripts/LoginPage.js +++ /dev/null @@ -1,119 +0,0 @@ -var LoginPage = { - - onPageShow: function () { - Dashboard.showLoadingMsg(); - - ApiClient.getUsers().done(LoginPage.loadUserList); - }, - - getLastSeenText: function (lastActivityDate) { - - if (!lastActivityDate) { - return ""; - } - - return "Last seen " + humane_date(lastActivityDate); - }, - - getImagePath: function (user) { - - if (!user.PrimaryImageTag) { - return "css/images/logindefault.png"; - } - - return ApiClient.getUserImageUrl(user.Id, { - width: 240, - tag: user.PrimaryImageTag, - type: "Primary" - }); - }, - - authenticateUserLink: function (link) { - - LoginPage.authenticateUser(link.getAttribute('data-username'), link.getAttribute('data-userid')); - }, - - authenticateUser: function (username, userId, password) { - - Dashboard.showLoadingMsg(); - - ApiClient.authenticateUser(userId, password).done(function () { - - Dashboard.setCurrentUser(userId); - - window.location = "index.html?u=" + userId; - - }).fail(function () { - Dashboard.hideLoadingMsg(); - - setTimeout(function () { - Dashboard.showError("Invalid user or password."); - }, 300); - }); - }, - - loadUserList: function (users) { - var html = ""; - - for (var i = 0, length = users.length; i < length; i++) { - var user = users[i]; - - var linkId = "lnkUser" + i; - - var background = Dashboard.getRandomMetroColor(); - - html += ''; - } - - $('#divUsers', '#loginPage').html(html); - - Dashboard.hideLoadingMsg(); - }, - - onSubmit: function () { - $('#popupLogin', '#loginPage').popup('close'); - - var link = $('#' + LoginPage.authenticatingLinkId)[0]; - - LoginPage.authenticateUser(link.getAttribute('data-username'), link.getAttribute('data-userid'), $('#pw', '#loginPage').val()); - - // Disable default form submission - return false; - } -}; - -$(document).on('pageshow', "#loginPage", LoginPage.onPageShow); diff --git a/MediaBrowser.WebDashboard/Html/scripts/MediaLibraryPage.js b/MediaBrowser.WebDashboard/Html/scripts/MediaLibraryPage.js deleted file mode 100644 index 4f4d119d8..000000000 --- a/MediaBrowser.WebDashboard/Html/scripts/MediaLibraryPage.js +++ /dev/null @@ -1,272 +0,0 @@ -var MediaLibraryPage = { - - onPageShow: function () { - - MediaLibraryPage.lastVirtualFolderName = ""; - - MediaLibraryPage.reloadLibrary(); - }, - - reloadLibrary: function () { - - Dashboard.showLoadingMsg(); - - var userId = getParameterByName("userId"); - - var page = $.mobile.activePage; - - if (userId) { - - $('#userProfileNavigation', page).show(); - - ApiClient.getUser(userId).done(function (user) { - - Dashboard.setPageTitle(user.Name); - - $('#fldUseDefaultLibrary', page).show(); - - $('#chkUseDefaultLibrary', page).checked(!user.Configuration.UseCustomLibrary).checkboxradio("refresh"); - - if (user.Configuration.UseCustomLibrary) { - - ApiClient.getVirtualFolders(userId).done(MediaLibraryPage.reloadVirtualFolders); - $('#divMediaLibrary', page).show(); - } else { - $('#divMediaLibrary', page).hide(); - Dashboard.hideLoadingMsg(); - } - - }); - - } else { - - $('#userProfileNavigation', page).hide(); - ApiClient.getVirtualFolders().done(MediaLibraryPage.reloadVirtualFolders); - - $('#fldUseDefaultLibrary', page).hide(); - $('#divMediaLibrary', page).show(); - Dashboard.setPageTitle("Media Library"); - } - }, - - reloadVirtualFolders: function (virtualFolders) { - - var page = $.mobile.activePage; - - if (virtualFolders) { - MediaLibraryPage.virtualFolders = virtualFolders; - } else { - virtualFolders = MediaLibraryPage.virtualFolders; - } - - var html = ''; - - for (var i = 0, length = virtualFolders.length; i < length; i++) { - - var virtualFolder = virtualFolders[i]; - - var isCollapsed = MediaLibraryPage.lastVirtualFolderName != virtualFolder.Name; - - html += MediaLibraryPage.getVirtualFolderHtml(virtualFolder, isCollapsed, i); - } - - $('#divVirtualFolders', page).html(html).trigger('create'); - - Dashboard.hideLoadingMsg(); - }, - - getVirtualFolderHtml: function (virtualFolder, isCollapsed, index) { - - isCollapsed = isCollapsed ? "true" : "false"; - var html = '
'; - - html += '

' + virtualFolder.Name + '

'; - - html += '
    '; - - html += '
  • Media Locations'; - html += ''; - html += '
  • '; - - for (var i = 0, length = virtualFolder.Locations.length; i < length; i++) { - - var location = virtualFolder.Locations[i]; - html += '
  • '; - html += '' + location + ''; - html += ''; - html += '
  • '; - } - html += '
'; - - html += '

'; - html += ''; - html += ''; - html += '

'; - - html += '
'; - - return html; - }, - - setUseDefaultMediaLibrary: function (useDefaultLibrary) { - - Dashboard.showLoadingMsg(); - - var userId = getParameterByName("userId"); - - ApiClient.getUser(userId).done(function (user) { - - user.Configuration.UseCustomLibrary = !useDefaultLibrary; - - ApiClient.updateUser(user).done(MediaLibraryPage.reloadLibrary); - }); - }, - - addVirtualFolder: function () { - - MediaLibraryPage.getTextValue("Add Media Collection", "Name:", "", function (name) { - - var userId = getParameterByName("userId"); - - MediaLibraryPage.lastVirtualFolderName = name; - - ApiClient.addVirtualFolder(name, userId).done(MediaLibraryPage.processOperationResult); - - }); - }, - - addMediaLocation: function (virtualFolderIndex) { - - MediaLibraryPage.selectDirectory(function (path) { - - if (path) { - - var virtualFolder = MediaLibraryPage.virtualFolders[virtualFolderIndex]; - - MediaLibraryPage.lastVirtualFolderName = virtualFolder.Name; - - var userId = getParameterByName("userId"); - - ApiClient.addMediaPath(virtualFolder.Name, path, userId).done(MediaLibraryPage.processOperationResult); - } - - }); - }, - - selectDirectory: function (callback) { - - Dashboard.selectDirectory({callback: callback}); - }, - - getTextValue: function (header, label, initialValue, callback) { - - var page = $.mobile.activePage; - - var popup = $('#popupEnterText', page); - - $('h3', popup).html(header); - $('label', popup).html(label); - $('#txtValue', popup).val(initialValue); - - popup.popup("open").on("popupafterclose", function () { - - $(this).off("popupafterclose").off("click"); - - $('#textEntryForm', this).off("submit"); - - }); - - $('#textEntryForm', popup).on('submit', function () { - - if (callback) { - callback($('#txtValue', popup).val()); - } - - return false; - }); - }, - - renameVirtualFolder: function (button) { - - var folderIndex = button.getAttribute('data-folderindex'); - var virtualFolder = MediaLibraryPage.virtualFolders[folderIndex]; - - MediaLibraryPage.lastVirtualFolderName = virtualFolder.Name; - - MediaLibraryPage.getTextValue(virtualFolder.Name, "Rename " + virtualFolder.Name, virtualFolder.Name, function (newName) { - - if (virtualFolder.Name != newName) { - - var userId = getParameterByName("userId"); - - ApiClient.renameVirtualFolder(virtualFolder.Name, newName, userId).done(MediaLibraryPage.processOperationResult); - } - }); - }, - - deleteVirtualFolder: function (button) { - - var folderIndex = button.getAttribute('data-folderindex'); - var virtualFolder = MediaLibraryPage.virtualFolders[folderIndex]; - - var parent = $(button).parents('.collapsibleVirtualFolder'); - - var locations = $('.lnkMediaLocation', parent).map(function () { - return this.innerHTML; - }).get(); - - var msg = "Are you sure you wish to remove " + virtualFolder.Name + "?"; - - if (locations.length) { - msg += "

The following media locations will be removed from your library:

"; - msg += locations.join("
"); - } - - MediaLibraryPage.lastVirtualFolderName = virtualFolder.Name; - - Dashboard.confirm(msg, "Remove Media Folder", function (confirmResult) { - - if (confirmResult) { - - var userId = getParameterByName("userId"); - - ApiClient.removeVirtualFolder(virtualFolder.Name, userId).done(MediaLibraryPage.processOperationResult); - } - - }); - }, - - deleteMediaLocation: function (button) { - - var folderIndex = button.getAttribute('data-folderindex'); - var index = parseInt(button.getAttribute('data-index')); - - var virtualFolder = MediaLibraryPage.virtualFolders[folderIndex]; - - MediaLibraryPage.lastVirtualFolderName = virtualFolder.Name; - - var location = virtualFolder.Locations[index]; - - Dashboard.confirm("Are you sure you wish to remove " + location + "?", "Remove Media Location", function (confirmResult) { - - if (confirmResult) { - - var userId = getParameterByName("userId"); - - ApiClient.removeMediaPath(virtualFolder.Name, location, userId).done(MediaLibraryPage.processOperationResult); - } - }); - }, - - processOperationResult: function (result) { - Dashboard.hideLoadingMsg(); - - var page = $.mobile.activePage; - - $('#popupEnterText', page).popup("close"); - $('#popupDirectoryPicker', page).popup("close"); - MediaLibraryPage.reloadLibrary(); - } -}; - -$(document).on('pageshow', ".mediaLibraryPage", MediaLibraryPage.onPageShow); \ No newline at end of file diff --git a/MediaBrowser.WebDashboard/Html/scripts/MediaPlayer.js b/MediaBrowser.WebDashboard/Html/scripts/MediaPlayer.js deleted file mode 100644 index 928fb06b6..000000000 --- a/MediaBrowser.WebDashboard/Html/scripts/MediaPlayer.js +++ /dev/null @@ -1,182 +0,0 @@ -var MediaPlayer = { - - canPlay: function (item) { - - if (item.MediaType === "Video") { - - var media = document.createElement('video'); - - if (media.canPlayType) { - - return media.canPlayType('video/mp4').replace(/no/, '') || media.canPlayType('video/mp2t').replace(/no/, '') || media.canPlayType('video/webm').replace(/no/, '') || media.canPlayType('application/x-mpegURL').replace(/no/, '') || media.canPlayType('video/ogv').replace(/no/, ''); - } - - return false; - } - - if (item.MediaType === "Audio") { - - var media = document.createElement('audio'); - - if (media.canPlayType) { - return media.canPlayType('audio/mpeg').replace(/no/, '') || media.canPlayType('audio/aac').replace(/no/, ''); - } - - return false; - } - - return false; - }, - - play: function (items) { - - if (MediaPlayer.isPlaying()) { - MediaPlayer.stop(); - } - - var item = items[0]; - - var mediaElement; - - if (item.MediaType === "Video") { - - mediaElement = MediaPlayer.playVideo(items); - } - - else if (item.MediaType === "Audio") { - - mediaElement = MediaPlayer.playAudio(items); - } - - if (!mediaElement) { - return; - } - - MediaPlayer.mediaElement = mediaElement; - - var nowPlayingBar = $('#nowPlayingBar').show(); - - if (items.length > 1) { - $('#previousTrackButton', nowPlayingBar)[0].disabled = false; - $('#nextTrackButton', nowPlayingBar)[0].disabled = false; - } else { - $('#previousTrackButton', nowPlayingBar)[0].disabled = true; - $('#nextTrackButton', nowPlayingBar)[0].disabled = true; - } - }, - - playAudio: function (items) { - var item = items[0]; - - var baseParams = { - audioChannels: 2, - audioBitrate: 128000 - }; - - var mp3Url = ApiClient.getUrl('Audio/' + item.Id + '/stream.mp3', $.extend({}, baseParams, { - audioCodec: 'mp3' - })); - - var aacUrl = ApiClient.getUrl('Audio/' + item.Id + '/stream.aac', $.extend({}, baseParams, { - audioCodec: 'aac' - })); - - var webmUrl = ApiClient.getUrl('Audio/' + item.Id + '/stream.webma', $.extend({}, baseParams, { - audioCodec: 'Vorbis' - })); - - var oggUrl = ApiClient.getUrl('Audio/' + item.Id + '/stream.oga', $.extend({}, baseParams, { - audioCodec: 'Vorbis' - })); - - var html = ''; - html += '