1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

auto-organize fix

This commit is contained in:
Luke Pulverenti 2015-06-08 17:32:20 -04:00
parent bbfda77868
commit f64e0c7c53
54 changed files with 838 additions and 666 deletions

View file

@ -4,7 +4,7 @@
<title>${TitleAutoOrganize}</title> <title>${TitleAutoOrganize}</title>
</head> </head>
<body> <body>
<div id="libraryFileOrganizerLogPage" data-role="page" class="page type-interior organizePage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Auto-Organize"> <div id="libraryFileOrganizerLogPage" data-role="page" class="page type-interior organizePage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Auto-Organize" data-require="scripts/autoorganizelog">
<div data-role="content"> <div data-role="content">
<div class="content-primary"> <div class="content-primary">
@ -94,10 +94,6 @@
</div> </div>
</div> </div>
<script type="text/javascript">
$('.episodeCorrectionForm').off('submit', OrganizerLogPage.onEpisodeCorrectionFormSubmit).on('submit', OrganizerLogPage.onEpisodeCorrectionFormSubmit);
</script>
</div> </div>
</body> </body>
</html> </html>

View file

@ -4,7 +4,7 @@
<title>${TitleAutoOrganize}</title> <title>${TitleAutoOrganize}</title>
</head> </head>
<body> <body>
<div id="libraryFileOrganizerPage" data-role="page" class="page type-interior organizePage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Auto-Organize"> <div id="libraryFileOrganizerPage" data-role="page" class="page type-interior organizePage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Auto-Organize" data-require="scripts/autoorganizetv">
<div data-role="content"> <div data-role="content">
<div class="content-primary"> <div class="content-primary">
@ -182,10 +182,6 @@
</div> </div>
</div> </div>
<script type="text/javascript">
$('.libraryFileOrganizerForm').off('submit', LibraryFileOrganizerPage.onSubmit).on('submit', LibraryFileOrganizerPage.onSubmit);
</script>
</div> </div>
</body> </body>
</html> </html>

View file

@ -4,7 +4,7 @@
<title>${TitlePlayback}</title> <title>${TitlePlayback}</title>
</head> </head>
<body> <body>
<div id="cinemaModeConfigurationPage" data-role="page" class="page type-interior playbackConfigurationPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Cinema-Mode"> <div id="cinemaModeConfigurationPage" data-role="page" class="page type-interior playbackConfigurationPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Cinema-Mode" data-require="scripts/cinemamodeconfiguration">
<div data-role="content"> <div data-role="content">
<div class="content-primary"> <div class="content-primary">
@ -86,10 +86,6 @@
</form> </form>
</div> </div>
</div> </div>
<script type="text/javascript">
$('.cinemaModeConfigurationForm').off('submit', CinemaModeConfigurationPage.onSubmit).on('submit', CinemaModeConfigurationPage.onSubmit);
</script>
</div> </div>
</body> </body>
</html> </html>

View file

@ -52,7 +52,7 @@
} }
.mediumCardMargin .cardBox { .mediumCardMargin .cardBox {
margin: 4px; margin: 5px;
} }
@media all and (max-width: 800px) { @media all and (max-width: 800px) {

View file

@ -4,7 +4,7 @@
<title>${TitleServer}</title> <title>${TitleServer}</title>
</head> </head>
<body> <body>
<div id="dashboardGeneralPage" data-role="page" class="page type-interior dashboardHomePage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Server%20Settings"> <div id="dashboardGeneralPage" data-role="page" class="page type-interior dashboardHomePage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Server%20Settings" data-require="scripts/dashboardgeneral">
<div data-role="content"> <div data-role="content">
<div class="content-primary"> <div class="content-primary">
@ -88,12 +88,6 @@
</div> </div>
</div> </div>
<script type="text/javascript">
$('.dashboardGeneralForm').off('submit', DashboardGeneralPage.onSubmit).on('submit', DashboardGeneralPage.onSubmit);
</script>
</div> </div>
</body> </body>
</html> </html>

View file

@ -5,7 +5,7 @@
</head> </head>
<body> <body>
<div id="itemByNameDetailPage" data-role="page" class="page libraryPage itemDetailPage lightBackdropPage"> <div id="itemByNameDetailPage" data-role="page" class="page libraryPage itemDetailPage lightBackdropPage" data-require="scripts/itembynamedetailpage">
<div id="movieGenreTabs" class="itemTabs" style="display: none;"> <div id="movieGenreTabs" class="itemTabs" style="display: none;">
<div class="libraryViewNav scopedLibraryViewNav"> <div class="libraryViewNav scopedLibraryViewNav">
<a href="moviesrecommended.html">${TabSuggestions}</a> <a href="moviesrecommended.html">${TabSuggestions}</a>

View file

@ -4,7 +4,7 @@
<title>${TitleMediaLibrary}</title> <title>${TitleMediaLibrary}</title>
</head> </head>
<body> <body>
<div id="mediaLibraryPage" data-role="page" class="page type-interior mediaLibraryPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Library%20setup"> <div id="mediaLibraryPage" data-role="page" class="page type-interior mediaLibraryPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Library%20setup" data-require="scripts/medialibrarypage">
<div data-role="content"> <div data-role="content">
<div class="content-primary"> <div class="content-primary">

View file

@ -4,7 +4,7 @@
<title>${TitleMediaLibrary}</title> <title>${TitleMediaLibrary}</title>
</head> </head>
<body> <body>
<div id="libraryPathMappingPage" data-role="page" class="page type-interior mediaLibraryPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Library%20setup"> <div id="libraryPathMappingPage" data-role="page" class="page type-interior mediaLibraryPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Library%20setup" data-require="scripts/librarypathmapping">
<div data-role="content"> <div data-role="content">
<div class="content-primary"> <div class="content-primary">
@ -56,10 +56,6 @@
</div> </div>
</div> </div>
<script type="text/javascript">
$('.libraryPathMappingForm').off('submit', LibraryPathMappingPage.onSubmit).on('submit', LibraryPathMappingPage.onSubmit);
</script>
</div> </div>
</body> </body>
</html> </html>

View file

@ -4,7 +4,7 @@
<title>Emby</title> <title>Emby</title>
</head> </head>
<body> <body>
<div id="liveTvRecordingPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}" data-require="scripts/livetvcomponents"> <div id="liveTvRecordingPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}" data-require="scripts/livetvcomponents,scripts/livetvrecording">
<div class="libraryViewNav"> <div class="libraryViewNav">
<a href="livetvsuggested.html">${TabSuggestions}</a> <a href="livetvsuggested.html">${TabSuggestions}</a>
<a href="livetvguide.html">${TabGuide}</a> <a href="livetvguide.html">${TabGuide}</a>

View file

@ -4,7 +4,7 @@
<title>Emby</title> <title>Emby</title>
</head> </head>
<body> <body>
<div id="liveTvSeriesTimerPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}" data-require="scripts/livetvcomponents"> <div id="liveTvSeriesTimerPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}" data-require="scripts/livetvcomponents,scripts/livetvseriestimer">
<div class="libraryViewNav"> <div class="libraryViewNav">
<a href="livetvsuggested.html">${TabSuggestions}</a> <a href="livetvsuggested.html">${TabSuggestions}</a>
<a href="livetvguide.html">${TabGuide}</a> <a href="livetvguide.html">${TabGuide}</a>
@ -113,9 +113,6 @@
<div class="scheduleTab tab"></div> <div class="scheduleTab tab"></div>
</form> </form>
</div> </div>
<script type="text/javascript">
$('.liveTvSeriesTimerForm').off('submit', LiveTvSeriesTimerPage.onSubmit).on('submit', LiveTvSeriesTimerPage.onSubmit);
</script>
</div> </div>
</body> </body>

View file

@ -4,7 +4,7 @@
<title>Emby</title> <title>Emby</title>
</head> </head>
<body> <body>
<div id="liveTvTimerPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}" data-require="scripts/livetvcomponents"> <div id="liveTvTimerPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}" data-require="scripts/livetvcomponents,scripts/livetvtimer">
<div class="libraryViewNav"> <div class="libraryViewNav">
<a href="livetvsuggested.html">${TabSuggestions}</a> <a href="livetvsuggested.html">${TabSuggestions}</a>
<a href="livetvguide.html">${TabGuide}</a> <a href="livetvguide.html">${TabGuide}</a>
@ -85,9 +85,6 @@
</form> </form>
</div> </div>
<script type="text/javascript">
$('.liveTvTimerForm').off('submit', LiveTvTimerPage.onSubmit).on('submit', LiveTvTimerPage.onSubmit);
</script>
</div> </div>
</body> </body>

View file

@ -4,7 +4,7 @@
<title>${TitleMetadata}</title> <title>${TitleMetadata}</title>
</head> </head>
<body> <body>
<div id="metadataConfigurationPage" data-role="page" class="page type-interior metadataConfigurationPage"> <div id="metadataConfigurationPage" data-role="page" class="page type-interior metadataConfigurationPage" data-require="scripts/metadataconfigurationpage">
<div data-role="content"> <div data-role="content">
@ -17,7 +17,7 @@
<a href="metadataadvanced.html" data-role="button">${TabAdvanced}</a> <a href="metadataadvanced.html" data-role="button">${TabAdvanced}</a>
</div> </div>
<form id="metadataConfigurationForm"> <form class="metadataConfigurationForm">
<ul data-role="listview" class="ulForm"> <ul data-role="listview" class="ulForm">
<li> <li>
<input type="checkbox" id="chkEnableInternetProviders" name="chkEnableInternetProviders" data-mini="true" /> <input type="checkbox" id="chkEnableInternetProviders" name="chkEnableInternetProviders" data-mini="true" />
@ -58,10 +58,6 @@
</div> </div>
</div> </div>
<script type="text/javascript">
$('#metadataConfigurationForm').on('submit', MetadataConfigurationPage.onSubmit);
</script>
</div> </div>
</body> </body>
</html> </html>

View file

@ -4,7 +4,7 @@
<title>${TitleMetadata}</title> <title>${TitleMetadata}</title>
</head> </head>
<body> <body>
<div id="metadataImagesConfigurationPage" data-role="page" class="page type-interior metadataConfigurationPage"> <div id="metadataImagesConfigurationPage" data-role="page" class="page type-interior metadataConfigurationPage" data-require="scripts/metadataimagespage">
<div data-role="content"> <div data-role="content">
@ -132,10 +132,6 @@
</div> </div>
</div> </div>
<script type="text/javascript">
$('.metadataImagesConfigurationForm').off('submit', MetadataImagesPage.onSubmit).on('submit', MetadataImagesPage.onSubmit);
</script>
</div> </div>
</body> </body>
</html> </html>

View file

@ -4,7 +4,7 @@
<title>${TitleMetadata}</title> <title>${TitleMetadata}</title>
</head> </head>
<body> <body>
<div id="metadataSubtitlesPage" data-role="page" class="page type-interior metadataConfigurationPage"> <div id="metadataSubtitlesPage" data-role="page" class="page type-interior metadataConfigurationPage" data-require="scripts/metadatasubtitles">
<div data-role="content"> <div data-role="content">
@ -70,10 +70,6 @@
</div> </div>
</div> </div>
<script type="text/javascript">
$('.metadataSubtitlesForm').off('submit', MetadataSubtitlesPage.onSubmit).on('submit', MetadataSubtitlesPage.onSubmit);
</script>
</div> </div>
</body> </body>
</html> </html>

View file

@ -4,7 +4,7 @@
<title>${TitlePlayback}</title> <title>${TitlePlayback}</title>
</head> </head>
<body> <body>
<div id="playbackConfigurationPage" data-role="page" class="page type-interior playbackConfigurationPage"> <div id="playbackConfigurationPage" data-role="page" class="page type-interior playbackConfigurationPage" data-require="scripts/playbackconfiguration">
<div data-role="content"> <div data-role="content">
<div class="content-primary"> <div class="content-primary">
@ -61,10 +61,6 @@
</form> </form>
</div> </div>
</div> </div>
<script type="text/javascript">
$('.playbackConfigurationForm').off('submit', PlaybackConfigurationPage.onSubmit).on('submit', PlaybackConfigurationPage.onSubmit);
</script>
</div> </div>
</body> </body>
</html> </html>

View file

@ -4,7 +4,7 @@
<title>Emby</title> <title>Emby</title>
</head> </head>
<body> <body>
<div id="playlistEditorPage" data-role="page" class="page libraryPage"> <div id="playlistEditorPage" data-role="page" class="page libraryPage" data-require="scripts/playlistedit">
<div class="libraryViewNav scopedLibraryViewNav"> <div class="libraryViewNav scopedLibraryViewNav">
<a href="playlists.html" class="ui-btn-active">${TabPlaylists}</a> <a href="playlists.html" class="ui-btn-active">${TabPlaylists}</a>

View file

@ -4,7 +4,7 @@
<title>Emby</title> <title>Emby</title>
</head> </head>
<body> <body>
<div id="playlistsPage" data-role="page" class="page libraryPage"> <div id="playlistsPage" data-role="page" class="page libraryPage" data-require="scripts/playlists">
<div class="libraryViewNav scopedLibraryViewNav"> <div class="libraryViewNav scopedLibraryViewNav">
<a href="#" class="ui-btn-active">${TabPlaylists}</a> <a href="#" class="ui-btn-active">${TabPlaylists}</a>

View file

@ -326,7 +326,12 @@
} }
} }
$(document).on('pageinit', "#libraryFileOrganizerLogPage", function () { function onEpisodeCorrectionFormSubmit() {
submitEpisodeForm(this);
return false;
}
$(document).on('pageinitdepends', "#libraryFileOrganizerLogPage", function () {
var page = this; var page = this;
@ -338,7 +343,9 @@
}); });
}).on('pageshow', "#libraryFileOrganizerLogPage", function () { $('.episodeCorrectionForm').off('submit', onEpisodeCorrectionFormSubmit).on('submit', onEpisodeCorrectionFormSubmit);
}).on('pageshowready', "#libraryFileOrganizerLogPage", function () {
var page = this; var page = this;
@ -368,13 +375,4 @@
$(ApiClient).off(".autoorganizelog"); $(ApiClient).off(".autoorganizelog");
}); });
window.OrganizerLogPage = {
onEpisodeCorrectionFormSubmit: function () {
submitEpisodeForm(this);
return false;
}
};
})(jQuery, document, window); })(jQuery, document, window);

View file

@ -1,16 +1,16 @@
(function ($, document, window) { (function ($, document, window) {
function updateSeasonPatternHelp(page, value) { function updateSeasonPatternHelp(page, value) {
var resultValue = value.replace('%s', '1').replace('%0s', '01').replace('%00s', '001'); var resultValue = value.replace('%s', '1').replace('%0s', '01').replace('%00s', '001');
var replacementHtmlResult = Globalize.translate('OrganizePatternResult').replace('{0}', resultValue); var replacementHtmlResult = Globalize.translate('OrganizePatternResult').replace('{0}', resultValue);
$('.seasonFolderFieldDescription', page).html(replacementHtmlResult); $('.seasonFolderFieldDescription', page).html(replacementHtmlResult);
} }
function getEpisodeFileName(value, enableMultiEpisode) { function getEpisodeFileName(value, enableMultiEpisode) {
var seriesName = "Series Name"; var seriesName = "Series Name";
var episodeTitle = "Episode Four"; var episodeTitle = "Episode Four";
@ -24,7 +24,7 @@
.replace('%en', episodeTitle) .replace('%en', episodeTitle)
.replace('%e.n', episodeTitle.replace(' ', '.')) .replace('%e.n', episodeTitle.replace(' ', '.'))
.replace('%e_n', episodeTitle.replace(' ', '_')); .replace('%e_n', episodeTitle.replace(' ', '_'));
if (enableMultiEpisode) { if (enableMultiEpisode) {
result = result result = result
.replace('%ed', '5') .replace('%ed', '5')
@ -41,7 +41,7 @@
function updateEpisodePatternHelp(page, value) { function updateEpisodePatternHelp(page, value) {
value = getEpisodeFileName(value, false); value = getEpisodeFileName(value, false);
var replacementHtmlResult = Globalize.translate('OrganizePatternResult').replace('{0}', value); var replacementHtmlResult = Globalize.translate('OrganizePatternResult').replace('{0}', value);
$('.episodePatternDescription', page).html(replacementHtmlResult); $('.episodePatternDescription', page).html(replacementHtmlResult);
@ -74,11 +74,42 @@
$('#txtDeleteLeftOverFiles', page).val(tvOptions.LeftOverFileExtensionsToDelete.join(';')); $('#txtDeleteLeftOverFiles', page).val(tvOptions.LeftOverFileExtensionsToDelete.join(';'));
$('#copyOrMoveFile', page).val(tvOptions.CopyOriginalFile.toString()).selectmenu('refresh'); $('#copyOrMoveFile', page).val(tvOptions.CopyOriginalFile.toString()).selectmenu('refresh');
} }
$(document).on('pageinit', "#libraryFileOrganizerPage", function () { function onSubmit() {
var form = this;
ApiClient.getNamedConfiguration('autoorganize').done(function (config) {
var tvOptions = config.TvOptions;
tvOptions.IsEnabled = $('#chkEnableTvSorting', form).checked();
tvOptions.OverwriteExistingEpisodes = $('#chkOverwriteExistingEpisodes', form).checked();
tvOptions.DeleteEmptyFolders = $('#chkDeleteEmptyFolders', form).checked();
tvOptions.MinFileSizeMb = $('#txtMinFileSize', form).val();
tvOptions.SeasonFolderPattern = $('#txtSeasonFolderPattern', form).val();
tvOptions.SeasonZeroFolderName = $('#txtSeasonZeroName', form).val();
tvOptions.EpisodeNamePattern = $('#txtEpisodePattern', form).val();
tvOptions.MultiEpisodeNamePattern = $('#txtMultiEpisodePattern', form).val();
tvOptions.LeftOverFileExtensionsToDelete = $('#txtDeleteLeftOverFiles', form).val().split(';');
var watchLocation = $('#txtWatchFolder', form).val();
tvOptions.WatchLocations = watchLocation ? [watchLocation] : [];
tvOptions.CopyOriginalFile = $('#copyOrMoveFile', form).val();
ApiClient.updateNamedConfiguration('autoorganize', config).done(Dashboard.processServerConfigurationUpdateResult);
});
return false;
}
$(document).on('pageinitdepends', "#libraryFileOrganizerPage", function () {
var page = this; var page = this;
@ -120,7 +151,9 @@
}); });
}); });
}).on('pageshow', "#libraryFileOrganizerPage", function () { $('.libraryFileOrganizerForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshowready', "#libraryFileOrganizerPage", function () {
var page = this; var page = this;
@ -129,40 +162,4 @@
}); });
}); });
window.LibraryFileOrganizerPage = {
onSubmit: function() {
var form = this;
ApiClient.getNamedConfiguration('autoorganize').done(function (config) {
var tvOptions = config.TvOptions;
tvOptions.IsEnabled = $('#chkEnableTvSorting', form).checked();
tvOptions.OverwriteExistingEpisodes = $('#chkOverwriteExistingEpisodes', form).checked();
tvOptions.DeleteEmptyFolders = $('#chkDeleteEmptyFolders', form).checked();
tvOptions.MinFileSizeMb = $('#txtMinFileSize', form).val();
tvOptions.SeasonFolderPattern = $('#txtSeasonFolderPattern', form).val();
tvOptions.SeasonZeroFolderName = $('#txtSeasonZeroName', form).val();
tvOptions.EpisodeNamePattern = $('#txtEpisodePattern', form).val();
tvOptions.MultiEpisodeNamePattern = $('#txtMultiEpisodePattern', form).val();
tvOptions.LeftOverFileExtensionsToDelete = $('#txtDeleteLeftOverFiles', form).val().split(';');
var watchLocation = $('#txtWatchFolder', form).val();
tvOptions.WatchLocations = watchLocation ? [watchLocation] : [];
tvOptions.CopyOriginalFile = $('#copyOrMoveFile', form).val();
ApiClient.updateNamedConfiguration('autoorganize', config).done(Dashboard.processServerConfigurationUpdateResult);
});
return false;
}
};
})(jQuery, document, window); })(jQuery, document, window);

View file

@ -20,7 +20,36 @@
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
} }
$(document).on('pageinit', "#cinemaModeConfigurationPage", function () { function onSubmit() {
Dashboard.showLoadingMsg();
var form = this;
var page = $(form).parents('.page');
ApiClient.getNamedConfiguration("cinemamode").done(function (config) {
config.CustomIntroPath = $('#txtCustomIntrosPath', page).val();
config.TrailerLimit = $('#txtNumTrailers', page).val();
config.EnableIntrosForMovies = $('#chkMovies', page).checked();
config.EnableIntrosForEpisodes = $('#chkEpisodes', page).checked();
config.EnableIntrosFromMoviesInLibrary = $('#chkMyMovieTrailers', page).checked();
config.EnableIntrosForWatchedContent = !$('#chkUnwatchedOnly', page).checked();
config.EnableIntrosParentalControl = $('#chkEnableParentalControl', page).checked();
config.EnableIntrosFromUpcomingTrailers = $('#chkUpcomingTheaterTrailers', page).checked();
config.EnableIntrosFromUpcomingDvdMovies = $('#chkUpcomingDvdTrailers', page).checked();
config.EnableIntrosFromUpcomingStreamingMovies = $('#chkUpcomingStreamingTrailers', page).checked();
ApiClient.updateNamedConfiguration("cinemamode", config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission
return false;
}
$(document).on('pageinitdepends', "#cinemaModeConfigurationPage", function () {
var page = this; var page = this;
@ -42,7 +71,9 @@
}); });
}); });
}).on('pageshow', "#cinemaModeConfigurationPage", function () { $('.cinemaModeConfigurationForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshowready', "#cinemaModeConfigurationPage", function () {
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
@ -61,40 +92,6 @@
} }
}); });
function cinemaModeConfigurationPage() {
var self = this;
self.onSubmit = function () {
Dashboard.showLoadingMsg();
var form = this;
var page = $(form).parents('.page');
ApiClient.getNamedConfiguration("cinemamode").done(function (config) {
config.CustomIntroPath = $('#txtCustomIntrosPath', page).val();
config.TrailerLimit = $('#txtNumTrailers', page).val();
config.EnableIntrosForMovies = $('#chkMovies', page).checked();
config.EnableIntrosForEpisodes = $('#chkEpisodes', page).checked();
config.EnableIntrosFromMoviesInLibrary = $('#chkMyMovieTrailers', page).checked();
config.EnableIntrosForWatchedContent = !$('#chkUnwatchedOnly', page).checked();
config.EnableIntrosParentalControl = $('#chkEnableParentalControl', page).checked();
config.EnableIntrosFromUpcomingTrailers = $('#chkUpcomingTheaterTrailers', page).checked();
config.EnableIntrosFromUpcomingDvdMovies = $('#chkUpcomingDvdTrailers', page).checked();
config.EnableIntrosFromUpcomingStreamingMovies = $('#chkUpcomingStreamingTrailers', page).checked();
ApiClient.updateNamedConfiguration("cinemamode", config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission
return false;
};
}
window.CinemaModeConfigurationPage = new cinemaModeConfigurationPage(); window.CinemaModeConfigurationPage = new cinemaModeConfigurationPage();
})(jQuery, document, window); })(jQuery, document, window);

View file

@ -36,7 +36,75 @@
}); });
} }
$(document).on('pageshow', "#dashboardGeneralPage", function () { function onSubmit() {
Dashboard.showLoadingMsg();
var form = this;
var page = $(form).parents('.page');
ApiClient.getServerConfiguration().done(function (config) {
config.ServerName = $('#txtServerName', form).val();
config.UICulture = $('#selectLocalizationLanguage', form).val();
config.CachePath = $('#txtCachePath', form).val();
if (config.UICulture != currentLanguage) {
Dashboard.showDashboardRefreshNotification();
}
ApiClient.updateServerConfiguration(config).done(function () {
refreshPageTitle(page);
ApiClient.getNamedConfiguration(brandingConfigKey).done(function (brandingConfig) {
brandingConfig.LoginDisclaimer = $('#txtLoginDisclaimer', form).val();
brandingConfig.CustomCss = $('#txtCustomCss', form).val();
var cssChanged = currentBrandingOptions && brandingConfig.CustomCss != currentBrandingOptions.CustomCss;
ApiClient.updateNamedConfiguration(brandingConfigKey, brandingConfig).done(Dashboard.processServerConfigurationUpdateResult);
if (cssChanged) {
Dashboard.showDashboardRefreshNotification();
}
});
});
});
// Disable default form submission
return false;
}
$(document).on('pageinitdepends', "#dashboardGeneralPage", function () {
var page = this;
$('#btnSelectCachePath', page).on("click.selectDirectory", function () {
var picker = new DirectoryBrowser(page);
picker.show({
callback: function (path) {
if (path) {
$('#txtCachePath', page).val(path);
}
picker.close();
},
header: Globalize.translate('HeaderSelectServerCachePath'),
instruction: Globalize.translate('HeaderSelectServerCachePathHelp')
});
});
$('.dashboardGeneralForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshowready', "#dashboardGeneralPage", function () {
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
@ -60,75 +128,6 @@
$('#txtCustomCss', page).val(config.CustomCss || ''); $('#txtCustomCss', page).val(config.CustomCss || '');
}); });
}).on('pageinit', "#dashboardGeneralPage", function () {
var page = this;
$('#btnSelectCachePath', page).on("click.selectDirectory", function () {
var picker = new DirectoryBrowser(page);
picker.show({
callback: function (path) {
if (path) {
$('#txtCachePath', page).val(path);
}
picker.close();
},
header: Globalize.translate('HeaderSelectServerCachePath'),
instruction: Globalize.translate('HeaderSelectServerCachePathHelp')
});
});
}); });
window.DashboardGeneralPage = {
onSubmit: function () {
Dashboard.showLoadingMsg();
var form = this;
var page = $(form).parents('.page');
ApiClient.getServerConfiguration().done(function (config) {
config.ServerName = $('#txtServerName', form).val();
config.UICulture = $('#selectLocalizationLanguage', form).val();
config.CachePath = $('#txtCachePath', form).val();
if (config.UICulture != currentLanguage) {
Dashboard.showDashboardRefreshNotification();
}
ApiClient.updateServerConfiguration(config).done(function () {
refreshPageTitle(page);
ApiClient.getNamedConfiguration(brandingConfigKey).done(function (brandingConfig) {
brandingConfig.LoginDisclaimer = $('#txtLoginDisclaimer', form).val();
brandingConfig.CustomCss = $('#txtCustomCss', form).val();
var cssChanged = currentBrandingOptions && brandingConfig.CustomCss != currentBrandingOptions.CustomCss;
ApiClient.updateNamedConfiguration(brandingConfigKey, brandingConfig).done(Dashboard.processServerConfigurationUpdateResult);
if (cssChanged) {
Dashboard.showDashboardRefreshNotification();
}
});
});
});
// Disable default form submission
return false;
}
};
})(jQuery, document, window); })(jQuery, document, window);

View file

@ -47,10 +47,6 @@ Array.prototype.remove = function (from, to) {
return this.push.apply(this, rest); return this.push.apply(this, rest);
}; };
String.prototype.endsWith = function (suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
$.fn.checked = function (value) { $.fn.checked = function (value) {
if (value === true || value === false) { if (value === true || value === false) {
// Set the value of the checkbox // Set the value of the checkbox
@ -68,31 +64,6 @@ $.fn.buttonEnabled = function (enabled) {
return enabled ? this.attr('disabled', '').removeAttr('disabled') : this.attr('disabled', 'disabled'); return enabled ? this.attr('disabled', '').removeAttr('disabled') : this.attr('disabled', 'disabled');
}; };
$.fn.dateTimeVal = function (val) {
if (val != null) {
var now = val;
var year = now.getFullYear();
var month = now.getMonth().toString().length === 1 ? '0' + (now.getMonth() + 1).toString() : now.getMonth() + 1;
var date = now.getDate().toString().length === 1 ? '0' + (now.getDate()).toString() : now.getDate();
var hours = now.getHours().toString().length === 1 ? '0' + now.getHours().toString() : now.getHours();
var minutes = now.getMinutes().toString().length === 1 ? '0' + now.getMinutes().toString() : now.getMinutes();
var seconds = now.getSeconds().toString().length === 1 ? '0' + now.getSeconds().toString() : now.getSeconds();
var formattedDateTime = year + '-' + month + '-' + date + 'T' + hours + ':' + minutes + ':' + seconds;
//if (onlyBlank === true && $(this).val()) {
// return this;
//}
return this.val(formattedDateTime);
}
return this.val();
};
if (!Array.prototype.filter) { if (!Array.prototype.filter) {
Array.prototype.filter = function (fun /*, thisp*/) { Array.prototype.filter = function (fun /*, thisp*/) {
"use strict"; "use strict";
@ -125,7 +96,7 @@ var WebNotifications = {
show: function (data) { show: function (data) {
// Seeing crashes in android // Seeing crashes in android
if (window.cordova && window.cordova.plugins && window.cordova.plugins.notification && !$.browser.android) { if (window.cordova && window.cordova.plugins && window.cordova.plugins.notification) {
if (!WebNotifications.lastId) { if (!WebNotifications.lastId) {
// Cordova plugin will crash on android with long. need an int // Cordova plugin will crash on android with long. need an int

View file

@ -535,7 +535,7 @@
}); });
} }
$(document).on('pageinit', "#itemByNameDetailPage", function () { $(document).on('pageinitdepends', "#itemByNameDetailPage", function () {
var page = this; var page = this;
@ -571,7 +571,7 @@
}); });
}); });
}).on('pageshow', "#itemByNameDetailPage", function () { }).on('pageshowready', "#itemByNameDetailPage", function () {
var page = this; var page = this;

View file

@ -393,7 +393,7 @@
html += '<li data-icon="false"><a class="btnMoreMenuDelete" href="#" onclick="$(\'.playFlyout\').popup(\'close\');LibraryBrowser.deleteItem([\'' + itemId + '\']);">' + Globalize.translate('ButtonDelete') + '</a></li>'; html += '<li data-icon="false"><a class="btnMoreMenuDelete" href="#" onclick="$(\'.playFlyout\').popup(\'close\');LibraryBrowser.deleteItem([\'' + itemId + '\']);">' + Globalize.translate('ButtonDelete') + '</a></li>';
} }
if (commands.indexOf('false') != -1) { if (commands.indexOf('download') != -1) {
var downloadHref = ApiClient.getUrl("Items/" + itemId + "/Download", { var downloadHref = ApiClient.getUrl("Items/" + itemId + "/Download", {
api_key: ApiClient.accessToken() api_key: ApiClient.accessToken()
}); });

View file

@ -4,7 +4,7 @@
var html = '<div class="viewMenuBar ui-bar-b">'; var html = '<div class="viewMenuBar ui-bar-b">';
html += '<button type="button" data-role="none" onclick="history.back();" class="headerButton headerButtonLeft headerBackButton"><div class="fa fa-arrow-left"></div></button>'; html += '<button type="button" data-role="none" class="headerButton headerButtonLeft headerBackButton"><div class="fa fa-arrow-left"></div></button>';
html += '<button type="button" data-role="none" title="Menu" class="headerButton dashboardMenuButton barsMenuButton headerButtonLeft">'; html += '<button type="button" data-role="none" title="Menu" class="headerButton dashboardMenuButton barsMenuButton headerButtonLeft">';
html += '<div class="barMenuInner fa fa-bars">'; html += '<div class="barMenuInner fa fa-bars">';
@ -53,6 +53,15 @@
bindMenuEvents(); bindMenuEvents();
} }
function onBackClick() {
if (Dashboard.exitOnBack()) {
Dashboard.exit();
}
else {
history.back();
}
}
function addUserToHeader(user) { function addUserToHeader(user) {
var header = $('.viewMenuBar'); var header = $('.viewMenuBar');
@ -96,6 +105,8 @@
$('.dashboardMenuButton').createHoverTouch().on('hovertouch', showDashboardMenu); $('.dashboardMenuButton').createHoverTouch().on('hovertouch', showDashboardMenu);
} }
$('.headerBackButton').on('click', onBackClick);
// Have to wait for document ready here because otherwise // Have to wait for document ready here because otherwise
// we may see the jQM redirect back and forth problem // we may see the jQM redirect back and forth problem
$(initViewMenuBarHeadroom); $(initViewMenuBarHeadroom);

View file

@ -94,7 +94,30 @@
}); });
} }
$(document).on('pageshow', "#libraryPathMappingPage", function () { function onSubmit() {
Dashboard.showLoadingMsg();
var form = this;
var page = $(form).parents('.page');
ApiClient.getServerConfiguration().done(function (config) {
addSubstitution(page, config);
ApiClient.updateServerConfiguration(config).done(function () {
reload(page);
});
});
// Disable default form submission
return false;
}
$(document).on('pageinitdepends', "#libraryPathMappingPage", function () {
$('.libraryPathMappingForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshowready', "#libraryPathMappingPage", function () {
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
@ -112,29 +135,4 @@
}); });
window.LibraryPathMappingPage = {
onSubmit: function () {
Dashboard.showLoadingMsg();
var form = this;
var page = $(form).parents('.page');
ApiClient.getServerConfiguration().done(function (config) {
addSubstitution(page, config);
ApiClient.updateServerConfiguration(config).done(function () {
reload(page);
});
});
// Disable default form submission
return false;
}
};
})(jQuery, document, window); })(jQuery, document, window);

View file

@ -274,6 +274,8 @@
}); });
$('.liveTvSeriesTimerForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pagebeforeshowready', "#liveTvSeriesTimerPage", function () { }).on('pagebeforeshowready', "#liveTvSeriesTimerPage", function () {
var page = this; var page = this;
@ -288,13 +290,4 @@
currentItem = null; currentItem = null;
}); });
function liveTvSeriesTimerPage() {
var self = this;
self.onSubmit = onSubmit;
}
window.LiveTvSeriesTimerPage = new liveTvSeriesTimerPage();
})(window, jQuery, document); })(window, jQuery, document);

View file

@ -113,6 +113,8 @@
}); });
$('.liveTvTimerForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pagebeforeshowready', "#liveTvTimerPage", function () { }).on('pagebeforeshowready', "#liveTvTimerPage", function () {
var page = this; var page = this;
@ -124,13 +126,4 @@
currentItem = null; currentItem = null;
}); });
function liveTvTimerPage() {
var self = this;
self.onSubmit = onSubmit;
}
window.LiveTvTimerPage = new liveTvTimerPage();
})(window, jQuery, document); })(window, jQuery, document);

View file

@ -506,7 +506,7 @@
var deferred = DeferredBuilder.Deferred(); var deferred = DeferredBuilder.Deferred();
Dashboard.loadLocalAssetManager().done(function () { require(['localassetmanager'], function () {
var serverInfo = ApiClient.serverInfo(); var serverInfo = ApiClient.serverInfo();
@ -528,7 +528,6 @@
}).fail(function () { }).fail(function () {
deferred.reject(); deferred.reject();
}); });
}); });
return deferred.promise(); return deferred.promise();

View file

@ -347,7 +347,7 @@
} }
}; };
$(document).on('pageinit', ".mediaLibraryPage", MediaLibraryPage.onPageInit).on('pageshow', ".mediaLibraryPage", MediaLibraryPage.onPageShow); $(document).on('pageinitdepends', ".mediaLibraryPage", MediaLibraryPage.onPageInit).on('pageshowready', ".mediaLibraryPage", MediaLibraryPage.onPageShow);
var WizardLibraryPage = { var WizardLibraryPage = {
@ -371,7 +371,7 @@ var WizardLibraryPage = {
(function ($, document, window) { (function ($, document, window) {
$(document).on('pageshow', "#mediaLibraryPage", function () { $(document).on('pageshowready', "#mediaLibraryPage", function () {
var page = this; var page = this;

View file

@ -448,12 +448,14 @@
self.canPlayNativeHls = function () { self.canPlayNativeHls = function () {
// Don't use HLS on android 4.4, regardless of what the browser reports // Don't use HLS on android 4.x, regardless of what the browser reports
if ($.browser.android) { if ($.browser.android) {
var agent = navigator.userAgent.toLowerCase(); var agent = navigator.userAgent.toLowerCase();
if (agent.indexOf('android 4.4') != -1) { for (var i = 0; i <= 4; i++) {
return false; if (agent.indexOf('android 4.' + i) != -1) {
return false;
}
} }
} }

View file

@ -1,39 +1,6 @@
var MetadataConfigurationPage = { (function () {
onPageShow: function () {
Dashboard.showLoadingMsg();
var page = this;
var config;
var allCultures;
var allCountries;
ApiClient.getServerConfiguration().done(function (result) {
config = result;
MetadataConfigurationPage.load(page, config, allCultures, allCountries);
});
ApiClient.getCultures().done(function (result) {
Dashboard.populateLanguages($('#selectLanguage', page), result);
allCultures = result;
MetadataConfigurationPage.load(page, config, allCultures, allCountries);
});
ApiClient.getCountries().done(function (result) {
Dashboard.populateCountries($('#selectCountry', page), result);
allCountries = result;
MetadataConfigurationPage.load(page, config, allCultures, allCountries);
});
},
load: function (page, config, allCultures, allCountries) {
function load(page, config, allCultures, allCountries) {
if (!config || !allCultures || !allCountries) { if (!config || !allCultures || !allCountries) {
return; return;
} }
@ -46,9 +13,9 @@
$('#selectImageSavingConvention', page).val(config.ImageSavingConvention).selectmenu("refresh"); $('#selectImageSavingConvention', page).val(config.ImageSavingConvention).selectmenu("refresh");
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
}, }
onSubmit: function () { function onSubmit() {
var form = this; var form = this;
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
@ -68,6 +35,44 @@
// Disable default form submission // Disable default form submission
return false; return false;
} }
};
$(document).on('pageshow', "#metadataConfigurationPage", MetadataConfigurationPage.onPageShow); $(document).on('pageinitdepends', "#metadataConfigurationPage", function () {
Dashboard.showLoadingMsg();
$('.metadataConfigurationForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshowready', "#metadataConfigurationPage", function () {
Dashboard.showLoadingMsg();
var page = this;
var config;
var allCultures;
var allCountries;
ApiClient.getServerConfiguration().done(function (result) {
config = result;
load(page, config, allCultures, allCountries);
});
ApiClient.getCultures().done(function (result) {
Dashboard.populateLanguages($('#selectLanguage', page), result);
allCultures = result;
load(page, config, allCultures, allCountries);
});
ApiClient.getCountries().done(function (result) {
Dashboard.populateCountries($('#selectCountry', page), result);
allCountries = result;
load(page, config, allCultures, allCountries);
});
});
})();

View file

@ -518,7 +518,7 @@
return false; return false;
} }
$(document).on('pageinit', "#metadataImagesConfigurationPage", function () { $(document).on('pageinitdepends', "#metadataImagesConfigurationPage", function () {
var page = this; var page = this;
@ -558,7 +558,9 @@
loadType(page, this.value); loadType(page, this.value);
}); });
}).on('pageshow', "#metadataImagesConfigurationPage", function () { $('.metadataImagesConfigurationForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshowready', "#metadataImagesConfigurationPage", function () {
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
@ -567,9 +569,4 @@
loadPage(page); loadPage(page);
}); });
window.MetadataImagesPage = {
onSubmit: onSubmit
};
})(jQuery, document, window); })(jQuery, document, window);

View file

@ -43,7 +43,45 @@
}).checkboxradio('refresh'); }).checkboxradio('refresh');
} }
$(document).on('pageshow', "#metadataSubtitlesPage", function () { function onSubmit() {
Dashboard.showLoadingMsg();
var form = this;
ApiClient.getNamedConfiguration("subtitles").done(function (config) {
config.DownloadMovieSubtitles = $('#chkSubtitlesMovies', form).checked();
config.DownloadEpisodeSubtitles = $('#chkSubtitlesEpisodes', form).checked();
config.SkipIfGraphicalSubtitlesPresent = $('#chkSkipIfGraphicalSubsPresent', form).checked();
config.SkipIfAudioTrackMatches = $('#chkSkipIfAudioTrackPresent', form).checked();
config.OpenSubtitlesUsername = $('#txtOpenSubtitleUsername', form).val();
var newPassword = $('#txtOpenSubtitlePassword', form).val();
if (newPassword) {
config.OpenSubtitlesPasswordHash = newPassword;
}
config.DownloadLanguages = $('.chkLang:checked', form).get().map(function (c) {
return c.getAttribute('data-lang');
});
ApiClient.updateNamedConfiguration("subtitles", config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission
return false;
}
$(document).on('pageinitdepends', "#metadataSubtitlesPage", function () {
$('.metadataSubtitlesForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshowready', "#metadataSubtitlesPage", function () {
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
@ -60,45 +98,4 @@
}); });
function metadataSubtitlesPage() {
var self = this;
self.onSubmit = function () {
Dashboard.showLoadingMsg();
var form = this;
ApiClient.getNamedConfiguration("subtitles").done(function (config) {
config.DownloadMovieSubtitles = $('#chkSubtitlesMovies', form).checked();
config.DownloadEpisodeSubtitles = $('#chkSubtitlesEpisodes', form).checked();
config.SkipIfGraphicalSubtitlesPresent = $('#chkSkipIfGraphicalSubsPresent', form).checked();
config.SkipIfAudioTrackMatches = $('#chkSkipIfAudioTrackPresent', form).checked();
config.OpenSubtitlesUsername = $('#txtOpenSubtitleUsername', form).val();
var newPassword = $('#txtOpenSubtitlePassword', form).val();
if (newPassword) {
config.OpenSubtitlesPasswordHash = newPassword;
}
config.DownloadLanguages = $('.chkLang:checked', form).get().map(function (c) {
return c.getAttribute('data-lang');
});
ApiClient.updateNamedConfiguration("subtitles", config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission
return false;
};
}
window.MetadataSubtitlesPage = new metadataSubtitlesPage();
})(jQuery, document, window); })(jQuery, document, window);

View file

@ -9,7 +9,29 @@
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
} }
$(document).on('pageshow', "#playbackConfigurationPage", function () { function onSubmit() {
Dashboard.showLoadingMsg();
var form = this;
ApiClient.getServerConfiguration().done(function (config) {
config.MinResumePct = $('#txtMinResumePct', form).val();
config.MaxResumePct = $('#txtMaxResumePct', form).val();
config.MinResumeDurationSeconds = $('#txtMinResumeDuration', form).val();
ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission
return false;
}
$(document).on('pageinitdepends', "#playbackConfigurationPage", function () {
$('.playbackConfigurationForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshowready', "#playbackConfigurationPage", function () {
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
@ -23,29 +45,4 @@
}); });
function playbackConfigurationPage() {
var self = this;
self.onSubmit = function () {
Dashboard.showLoadingMsg();
var form = this;
ApiClient.getServerConfiguration().done(function (config) {
config.MinResumePct = $('#txtMinResumePct', form).val();
config.MaxResumePct = $('#txtMaxResumePct', form).val();
config.MinResumeDurationSeconds = $('#txtMinResumeDuration', form).val();
ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission
return false;
};
}
window.PlaybackConfigurationPage = new playbackConfigurationPage();
})(jQuery, document, window); })(jQuery, document, window);

View file

@ -175,7 +175,7 @@
$('#selectPageSize', page).val(query.Limit).selectmenu('refresh'); $('#selectPageSize', page).val(query.Limit).selectmenu('refresh');
} }
$(document).on('pageinit', "#playlistEditorPage", function () { $(document).on('pageinitdepends', "#playlistEditorPage", function () {
var page = this; var page = this;
@ -215,7 +215,7 @@
}); });
}).on('pagebeforeshow', "#playlistEditorPage", function () { }).on('pageshowready', "#playlistEditorPage", function () {
var page = this; var page = this;
@ -234,8 +234,6 @@
LibraryBrowser.loadSavedQueryValues(viewkey, query); LibraryBrowser.loadSavedQueryValues(viewkey, query);
reloadItems(page); reloadItems(page);
}).on('pageshow', "#playlistEditorPage", function () {
updateFilterControls(this); updateFilterControls(this);
}); });

View file

@ -137,7 +137,7 @@
$('#selectPageSize', page).val(query.Limit).selectmenu('refresh'); $('#selectPageSize', page).val(query.Limit).selectmenu('refresh');
} }
$(document).on('pageinit', "#playlistsPage", function () { $(document).on('pageinitdepends', "#playlistsPage", function () {
var page = this; var page = this;
@ -183,7 +183,7 @@
reloadItems(page); reloadItems(page);
}); });
}).on('pagebeforeshow', "#playlistsPage", function () { }).on('pageshowready', "#playlistsPage", function () {
var page = this; var page = this;
@ -210,8 +210,6 @@
} }
}); });
}).on('pageshow', "#playlistsPage", function () {
updateFilterControls(this); updateFilterControls(this);
}); });

View file

@ -60,9 +60,7 @@
self.showSearchPanel = function () { self.showSearchPanel = function () {
var viewMenuSearch = $('.viewMenuSearch'); showSearchMenu();
viewMenuSearch.removeClass('hide');
$('.headerSearchInput').focus(); $('.headerSearchInput').focus();
}; };
} }
@ -199,7 +197,43 @@
function closeSearchOverlay() { function closeSearchOverlay() {
$('.headerSearchInput').val(''); $('.headerSearchInput').val('');
onHeaderSearchChange(''); onHeaderSearchChange('');
$('.viewMenuSearch').addClass('hide'); hideSearchMenu();
}
function showSearchMenu() {
require(["jquery", "velocity"], function ($, Velocity) {
$('.btnCloseSearch').hide();
var elem = $('.viewMenuSearch')
.css({ left: '100%' })
.removeClass('hide')[0];
Velocity.animate(elem, { "left": "0px" },
{
complete: function () {
$('.btnCloseSearch').show();
}
});
});
}
function hideSearchMenu() {
require(["jquery", "velocity"], function ($, Velocity) {
$('.btnCloseSearch').hide();
var elem = $('.viewMenuSearch')
.css({ left: '0' })[0];
Velocity.animate(elem, { "left": "100%" },
{
complete: function () {
$('.viewMenuSearch').addClass('hide');
},
duration: 'fast'
});
});
} }
$(document).on('pagehide', ".libraryPage", function () { $(document).on('pagehide', ".libraryPage", function () {

View file

@ -50,6 +50,7 @@ var Dashboard = {
$.event.special.swipe.verticalDistanceThreshold = 40; $.event.special.swipe.verticalDistanceThreshold = 40;
$.mobile.loader.prototype.options.disabled = true; $.mobile.loader.prototype.options.disabled = true;
//$.mobile.page.prototype.options.domCache = true;
}, },
isConnectMode: function () { isConnectMode: function () {
@ -1453,25 +1454,6 @@ var Dashboard = {
return deferred.promise(); return deferred.promise();
}, },
loadLocalAssetManager: function () {
var deferred = DeferredBuilder.Deferred();
var file = 'thirdparty/apiclient/localassetmanager';
if (AppInfo.isNativeApp && $.browser.android) {
file = 'thirdparty/cordova/android/localassetmanager';
}
require([
file
], function () {
deferred.resolve();
});
return deferred.promise();
},
ready: function (fn) { ready: function (fn) {
if (Dashboard.initPromiseDone) { if (Dashboard.initPromiseDone) {
@ -1506,6 +1488,14 @@ var Dashboard = {
}); });
return deferred.promise(); return deferred.promise();
},
exitOnBack: function () {
return $($.mobile.activePage).is('#indexPage');
},
exit: function () {
Dashboard.logout();
} }
}; };
@ -1601,6 +1591,8 @@ var AppInfo = {};
function initializeApiClient(apiClient) { function initializeApiClient(apiClient) {
apiClient.enableAppStorePolicy = AppInfo.enableAppStorePolicy; apiClient.enableAppStorePolicy = AppInfo.enableAppStorePolicy;
apiClient.getDefaultImageQuality = Dashboard.getDefaultImageQuality;
apiClient.normalizeImageOptions = Dashboard.normalizeImageOptions;
$(apiClient).off('.dashboard') $(apiClient).off('.dashboard')
.on("websocketmessage.dashboard", Dashboard.onWebSocketMessageReceived) .on("websocketmessage.dashboard", Dashboard.onWebSocketMessageReceived)
@ -1619,37 +1611,35 @@ var AppInfo = {};
initializeApiClient(newApiClient); initializeApiClient(newApiClient);
}); });
var apiClient; var deferred = DeferredBuilder.Deferred();
if (Dashboard.isConnectMode()) { if (Dashboard.isConnectMode()) {
apiClient = ConnectionManager.getLastUsedApiClient(); var server = ConnectionManager.getLastUsedServer();
if (!Dashboard.isServerlessPage()) { if (!Dashboard.isServerlessPage()) {
if (apiClient && apiClient.serverAddress() && apiClient.getCurrentUserId() && apiClient.accessToken()) { if (server && server.UserId && server.AccessToken) {
ConnectionManager.connectToServer(server).done(function (result) {
initializeApiClient(apiClient); if (result.State == MediaBrowser.ConnectionState.SignedIn) {
window.ApiClient = result.ApiClient;
}
deferred.resolve();
});
return deferred.promise();
} }
} }
deferred.resolve();
} else { } else {
apiClient = new MediaBrowser.ApiClient(Logger, Dashboard.serverAddress(), AppInfo.appName, AppInfo.appVersion, AppInfo.deviceName, AppInfo.deviceId); var apiClient = new MediaBrowser.ApiClient(Logger, Dashboard.serverAddress(), AppInfo.appName, AppInfo.appVersion, AppInfo.deviceName, AppInfo.deviceId);
apiClient.enableAutomaticNetworking = false; apiClient.enableAutomaticNetworking = false;
ConnectionManager.addApiClient(apiClient); ConnectionManager.addApiClient(apiClient);
Dashboard.importCss(apiClient.getUrl('Branding/Css'));
window.ApiClient = apiClient;
} }
return deferred.promise();
window.ApiClient = apiClient;
if (window.ApiClient) {
ApiClient.getDefaultImageQuality = Dashboard.getDefaultImageQuality;
ApiClient.normalizeImageOptions = Dashboard.normalizeImageOptions;
if (!AppInfo.isNativeApp) {
Dashboard.importCss(ApiClient.getUrl('Branding/Css'));
}
}
} }
function initFastClick() { function initFastClick() {
@ -1833,7 +1823,7 @@ var AppInfo = {};
}); });
if (Dashboard.isRunningInCordova()) { if (Dashboard.isRunningInCordova()) {
requirejs(['thirdparty/cordova/connectsdk', 'scripts/registrationservices']); requirejs(['thirdparty/cordova/connectsdk', 'scripts/registrationservices', 'thirdparty/cordova/volume', 'thirdparty/cordova/back']);
if ($.browser.android) { if ($.browser.android) {
requirejs(['thirdparty/cordova/android/androidcredentials', 'thirdparty/cordova/android/immersive', 'thirdparty/cordova/android/filesystem']); requirejs(['thirdparty/cordova/android/androidcredentials', 'thirdparty/cordova/android/immersive', 'thirdparty/cordova/android/filesystem']);
@ -1853,7 +1843,7 @@ var AppInfo = {};
} }
} }
function init(deferred, capabilities, appName, deviceId, deviceName, resolveOnReady) { function init(deferred, capabilities, appName, deviceId, deviceName) {
requirejs.config({ requirejs.config({
map: { map: {
@ -1861,7 +1851,11 @@ var AppInfo = {};
'css': 'thirdparty/requirecss' // or whatever the path to require-css is 'css': 'thirdparty/requirecss' // or whatever the path to require-css is
} }
}, },
urlArgs: "v=" + window.dashboardVersion urlArgs: "v=" + window.dashboardVersion,
paths: {
"velocity": "thirdparty/velocity.min"
}
}); });
// Required since jQuery is loaded before requireJs // Required since jQuery is loaded before requireJs
@ -1869,37 +1863,61 @@ var AppInfo = {};
return jQuery; return jQuery;
}); });
if (Dashboard.isRunningInCordova() && $.browser.android) {
define("appstorage", ["thirdparty/cordova/android/appstorage"]);
} else {
define('appstorage', [], function () {
return appStorage;
});
}
if (Dashboard.isRunningInCordova()) {
define("serverdiscovery", ["thirdparty/cordova/serverdiscovery"]);
define("wakeonlan", ["thirdparty/cordova/wakeonlan"]);
} else {
define("serverdiscovery", ["thirdparty/apiclient/serverdiscovery"]);
define("wakeonlan", ["thirdparty/apiclient/wakeonlan"]);
}
if (Dashboard.isRunningInCordova() && $.browser.android) {
define("localassetmanager", ["thirdparty/cordova/android/localassetmanager"]);
} else {
define("localassetmanager", ["thirdparty/apiclient/localassetmanager"]);
}
define("connectservice", ["thirdparty/apiclient/connectservice"]);
//requirejs(['http://viblast.com/player/free-version/qy2fdwajo1/viblast.js']); //requirejs(['http://viblast.com/player/free-version/qy2fdwajo1/viblast.js']);
setAppInfo(); setAppInfo();
$.extend(AppInfo, Dashboard.getAppInfo(appName, deviceId, deviceName)); $.extend(AppInfo, Dashboard.getAppInfo(appName, deviceId, deviceName));
createConnectionManager(capabilities); if (Dashboard.isConnectMode()) {
if (!resolveOnReady) { require(['appstorage'], function () {
capabilities.DeviceProfile = MediaPlayer.getDeviceProfile(Math.max(screen.height, screen.width));
createConnectionManager(capabilities).done(function() {
$(function () {
onDocumentReady();
Dashboard.initPromiseDone = true;
deferred.resolve();
});
});
});
} else {
createConnectionManager(capabilities);
Dashboard.initPromiseDone = true; Dashboard.initPromiseDone = true;
deferred.resolve(); deferred.resolve();
}
$(function () { $(onDocumentReady);
onDocumentReady(); }
if (resolveOnReady) {
Dashboard.initPromiseDone = true;
deferred.resolve();
}
});
} }
function initCordovaWithDeviceId(deferred, deviceId) { function initCordovaWithDeviceId(deferred, deviceId) {
var screenWidth = Math.max(screen.height, screen.width);
initCordovaWithDeviceProfile(deferred, deviceId, MediaPlayer.getDeviceProfile(screenWidth));
}
function initCordovaWithDeviceProfile(deferred, deviceId, deviceProfile) {
if ($.browser.android) { if ($.browser.android) {
requirejs(['thirdparty/cordova/android/imagestore.js']); requirejs(['thirdparty/cordova/android/imagestore.js']);
} else { } else {
@ -1908,9 +1926,7 @@ var AppInfo = {};
var capablities = Dashboard.capabilities(); var capablities = Dashboard.capabilities();
capablities.DeviceProfile = deviceProfile; init(deferred, capablities, "Emby Mobile", deviceId, device.model);
init(deferred, capablities, "Emby Mobile", deviceId, device.model, true);
} }
function initCordova(deferred) { function initCordova(deferred) {

View file

@ -239,7 +239,7 @@
logger.log("Reconnect attempt failed to " + url); logger.log("Reconnect attempt failed to " + url);
if (currentRetryCount <= 6) { if (currentRetryCount <= 5) {
var newConnectionMode = switchConnectionMode(connectionMode); var newConnectionMode = switchConnectionMode(connectionMode);

View file

@ -18,6 +18,23 @@
Manual: 2 Manual: 2
}; };
globalScope.MediaBrowser.ServerInfo = {
getServerAddress: function (server, mode) {
switch (mode) {
case MediaBrowser.ConnectionMode.Local:
return server.LocalAddress;
case MediaBrowser.ConnectionMode.Manual:
return server.ManualAddress;
case MediaBrowser.ConnectionMode.Remote:
return server.RemoteAddress;
default:
return server.ManualAddress || server.LocalAddress || server.RemoteAddress;
}
}
};
globalScope.MediaBrowser.ConnectionManager = function (logger, credentialProvider, appName, appVersion, deviceName, deviceId, capabilities) { globalScope.MediaBrowser.ConnectionManager = function (logger, credentialProvider, appName, appVersion, deviceName, deviceId, capabilities) {
logger.log('Begin MediaBrowser.ConnectionManager constructor'); logger.log('Begin MediaBrowser.ConnectionManager constructor');
@ -109,12 +126,27 @@
return credentialProvider.credentials().ConnectAccessToken; return credentialProvider.credentials().ConnectAccessToken;
}; };
self.getLastUsedServer = function () {
var servers = credentialProvider.credentials().Servers;
servers.sort(function (a, b) {
return (b.DateLastAccessed || 0) - (a.DateLastAccessed || 0);
});
if (!servers.length) {
return null;
}
return servers[0];
};
self.getLastUsedApiClient = function () { self.getLastUsedApiClient = function () {
var servers = credentialProvider.credentials().Servers; var servers = credentialProvider.credentials().Servers;
servers.sort(function (a, b) { servers.sort(function (a, b) {
return b.DateLastAccessed - a.DateLastAccessed; return (b.DateLastAccessed || 0) - (a.DateLastAccessed || 0);
}); });
if (!servers.length) { if (!servers.length) {
@ -515,6 +547,7 @@
self.logout = function () { self.logout = function () {
console.log('begin connectionManager loguot');
var promises = []; var promises = [];
for (var i = 0, length = apiClients.length; i < length; i++) { for (var i = 0, length = apiClients.length; i < length; i++) {
@ -646,7 +679,7 @@
servers = filterServers(servers, connectServers); servers = filterServers(servers, connectServers);
servers.sort(function (a, b) { servers.sort(function (a, b) {
return b.DateLastAccessed - a.DateLastAccessed; return (b.DateLastAccessed || 0) - (a.DateLastAccessed || 0);
}); });
credentials.Servers = servers; credentials.Servers = servers;
@ -680,23 +713,27 @@
function findServers() { function findServers() {
var deferred = DeferredBuilder.Deferred(); var deferred = DeferredBuilder.Deferred();
ServerDiscovery.findServers(2500).done(function (foundServers) {
var servers = foundServers.map(function (foundServer) { require(['serverdiscovery'], function () {
ServerDiscovery.findServers(2500).done(function (foundServers) {
var info = { var servers = foundServers.map(function (foundServer) {
Id: foundServer.Id,
LocalAddress: foundServer.Address,
Name: foundServer.Name,
ManualAddress: convertEndpointAddressToManualAddress(foundServer),
DateLastLocalConnection: new Date().getTime()
};
info.LastConnectionMode = info.ManualAddress ? MediaBrowser.ConnectionMode.Manual : MediaBrowser.ConnectionMode.Local; var info = {
Id: foundServer.Id,
LocalAddress: foundServer.Address,
Name: foundServer.Name,
ManualAddress: convertEndpointAddressToManualAddress(foundServer),
DateLastLocalConnection: new Date().getTime()
};
return info; info.LastConnectionMode = info.ManualAddress ? MediaBrowser.ConnectionMode.Manual : MediaBrowser.ConnectionMode.Local;
return info;
});
deferred.resolveWith(null, [servers]);
}); });
deferred.resolveWith(null, [servers]);
}); });
return deferred.promise(); return deferred.promise();
} }
@ -804,6 +841,14 @@
function beginWakeServer(server) { function beginWakeServer(server) {
require(['wakeonlan'], function () {
var infos = server.WakeOnLanInfos || [];
for (var i = 0, length = infos.length; i < length; i++) {
WakeOnLan.send(infos[i]);
}
});
} }
self.connectToServer = function (server, options) { self.connectToServer = function (server, options) {
@ -819,11 +864,7 @@
if (tests.indexOf(MediaBrowser.ConnectionMode.Local) == -1) { tests.push(MediaBrowser.ConnectionMode.Local); } if (tests.indexOf(MediaBrowser.ConnectionMode.Local) == -1) { tests.push(MediaBrowser.ConnectionMode.Local); }
if (tests.indexOf(MediaBrowser.ConnectionMode.Remote) == -1) { tests.push(MediaBrowser.ConnectionMode.Remote); } if (tests.indexOf(MediaBrowser.ConnectionMode.Remote) == -1) { tests.push(MediaBrowser.ConnectionMode.Remote); }
var sendWakeOnLan = server.WakeOnLanInfos && server.WakeOnLanInfos.length; beginWakeServer(server);
if (sendWakeOnLan) {
beginWakeServer(server);
}
var wakeOnLanSendTime = new Date().getTime(); var wakeOnLanSendTime = new Date().getTime();
@ -900,7 +941,6 @@
function onSuccessfulConnection(server, systemInfo, connectionMode, options, deferred) { function onSuccessfulConnection(server, systemInfo, connectionMode, options, deferred) {
var credentials = credentialProvider.credentials(); var credentials = credentialProvider.credentials();
if (credentials.ConnectAccessToken) { if (credentials.ConnectAccessToken) {
ensureConnectUser(credentials).done(function () { ensureConnectUser(credentials).done(function () {
@ -964,8 +1004,8 @@
function normalizeAddress(address) { function normalizeAddress(address) {
// attempt to correct bad input // attempt to correct bad input
address = address.trim(); address = address.trim();
if (address.toLowerCase().indexOf('http') != 0) { if (address.toLowerCase().indexOf('http') != 0) {
address = "http://" + address; address = "http://" + address;
@ -1017,43 +1057,53 @@
self.loginToConnect = function (username, password) { self.loginToConnect = function (username, password) {
var deferred = DeferredBuilder.Deferred();
if (!username) { if (!username) {
var deferred = DeferredBuilder.Deferred();
deferred.reject(); deferred.reject();
return deferred.promise(); return deferred.promise();
} }
if (!password) { if (!password) {
var deferred = DeferredBuilder.Deferred();
deferred.reject(); deferred.reject();
return deferred.promise(); return deferred.promise();
} }
var md5 = self.getConnectPasswordHash(password); require(['connectservice'], function () {
return AjaxApi.ajax({ var md5 = self.getConnectPasswordHash(password);
type: "POST",
url: "https://connect.mediabrowser.tv/service/user/authenticate",
data: {
nameOrEmail: username,
password: md5
},
dataType: "json",
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
headers: {
"X-Application": appName + "/" + appVersion
}
}).done(function (result) { AjaxApi.ajax({
type: "POST",
url: "https://connect.mediabrowser.tv/service/user/authenticate",
data: {
nameOrEmail: username,
password: md5
},
dataType: "json",
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
headers: {
"X-Application": appName + "/" + appVersion
}
var credentials = credentialProvider.credentials(); }).done(function (result) {
credentials.ConnectAccessToken = result.AccessToken; var credentials = credentialProvider.credentials();
credentials.ConnectUserId = result.User.Id;
credentialProvider.credentials(credentials); credentials.ConnectAccessToken = result.AccessToken;
credentials.ConnectUserId = result.User.Id;
onConnectUserSignIn(result.User); credentialProvider.credentials(credentials);
onConnectUserSignIn(result.User);
deferred.resolveWith(null, [result]);
}).fail(function () {
deferred.reject();
});
}); });
return deferred.promise();
}; };
self.getConnectPasswordHash = function (password) { self.getConnectPasswordHash = function (password) {

View file

@ -7,15 +7,21 @@
globalScope.MediaBrowser.CredentialProvider = function () { globalScope.MediaBrowser.CredentialProvider = function () {
var self = this; var self = this;
var credentials; var credentials = null;
var key = 'servercredentials3'; var key = 'servercredentials3';
function ensure() { function ensure() {
credentials = credentials || JSON.parse(appStorage.getItem(key) || '{}'); if (!credentials) {
credentials.Servers = credentials.Servers || credentials.servers || [];
var json = appStorage.getItem(key) || '{}';
credentials.servers = null; console.log('credentials initialized with: ' + json);
credentials = JSON.parse(json);
credentials.Servers = credentials.Servers || credentials.servers || [];
credentials.servers = null;
}
} }
function get() { function get() {
@ -65,6 +71,8 @@
// Merge the data // Merge the data
existing.DateLastAccessed = Math.max(existing.DateLastAccessed || 0, server.DateLastAccessed || 0); existing.DateLastAccessed = Math.max(existing.DateLastAccessed || 0, server.DateLastAccessed || 0);
existing.UserLinkType = server.UserLinkType;
if (server.AccessToken) { if (server.AccessToken) {
existing.AccessToken = server.AccessToken; existing.AccessToken = server.AccessToken;
existing.UserId = server.UserId; existing.UserId = server.UserId;
@ -101,21 +109,4 @@
}; };
}; };
globalScope.MediaBrowser.ServerInfo = {
getServerAddress: function (server, mode) {
switch (mode) {
case MediaBrowser.ConnectionMode.Local:
return server.LocalAddress;
case MediaBrowser.ConnectionMode.Manual:
return server.ManualAddress;
case MediaBrowser.ConnectionMode.Remote:
return server.RemoteAddress;
default:
return server.ManualAddress || server.LocalAddress || server.RemoteAddress;
}
}
};
})(window, window.JSON); })(window, window.JSON);

View file

@ -1,26 +0,0 @@
(function (globalScope, navigator) {
function networkStatus() {
var self = this;
self.isNetworkAvailable = function () {
var online = navigator.onLine;
if (online == null) {
online = true;
}
return online;
};
self.isAnyLocalNetworkAvailable = function () {
return self.isNetworkAvailable();
};
}
globalScope.NetworkStatus = new networkStatus();
})(window, window.navigator);

View file

@ -0,0 +1,14 @@
(function (globalScope) {
function send(info) {
var deferred = DeferredBuilder.Deferred();
deferred.resolve();
return deferred.promise();
}
globalScope.WakeOnLan = {
send: send
};
})(window);

View file

@ -30,62 +30,6 @@
//initAjax(); //initAjax();
} }
var baseAjaxMethod;
var currentId = 0;
function getNewRequestId() {
var id = currentId++;
return id.toString();
}
function initAjax() {
baseAjaxMethod = AjaxApi.ajax;
AjaxApi.ajax = sendRequest;
}
function sendRequest(request) {
if (request.data || request.contentType || request.dataType != 'json') {
return baseAjaxMethod(request);
}
var deferred = DeferredBuilder.Deferred();
var id = getNewRequestId();
request.headers = request.headers || {};
if (request.dataType == 'json') {
request.headers.accept = 'application/json';
}
var requestHeaders = [];
for (name in request.headers) {
requestHeaders.push(name + "=" + request.headers[name]);
}
ApiClientBridge.sendRequest(request.url, request.type, requestHeaders.join('|||||'), "window.AndroidAjax.onResponse", id);
Events.on(AndroidAjax, 'response' + id, function (e, status, response) {
Events.off(AndroidAjax, 'response' + id);
response = decodeURIComponent(response);
if (status >= 400) {
alert(status);
deferred.reject();
}
else if (request.dataType == 'json') {
deferred.resolveWith(null, [JSON.parse(response)]);
}
else {
deferred.resolveWith(null, [response]);
}
});
return deferred.promise();
}
Events.on(ConnectionManager.credentialProvider(), 'credentialsupdated', updateCredentials); Events.on(ConnectionManager.credentialProvider(), 'credentialsupdated', updateCredentials);
updateCredentials(); updateCredentials();

View file

@ -0,0 +1,84 @@
(function (globalScope, localStorage, sessionStorage) {
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;
}
};
}
function preferencesStore() {
var self = this;
self.setItem = function (name, value) {
AndroidSharedPreferences.set(name, value);
};
self.getItem = function (name) {
return AndroidSharedPreferences.get(name);
};
self.removeItem = function (name) {
AndroidSharedPreferences.remove(name);
};
function migrateKey(key) {
var json = localStorage.getItem(key);
if (json) {
self.setItem(key, json);
localStorage.removeItem(key);
}
}
function migrate() {
migrateKey('servercredentials3');
}
migrate();
}
globalScope.appStorage = new preferencesStore();
globalScope.sessionStore = new myStore(sessionStorage);
})(window, window.localStorage, window.sessionStorage);

24
dashboard-ui/thirdparty/cordova/back.js vendored Normal file
View file

@ -0,0 +1,24 @@
(function () {
Dashboard.exit = function () {
if (navigator.app && navigator.app.exitApp) {
navigator.app.exitApp();
} else {
Dashboard.logout();
}
};
function onBackKeyDown(e) {
if (Dashboard.exitOnBack()) {
e.preventDefault();
Dashboard.exit();
}
else {
history.back();
}
}
document.addEventListener("backbutton", onBackKeyDown, false);
})();

View file

@ -1,14 +1,15 @@
(function () { (function () {
var PlayerName = "Chromecast";
var ApplicationID = "2D4B1DA3";
var currentWebAppSession;
var currentDevice;
function chromecastPlayer() { function chromecastPlayer() {
var self = this; var self = this;
var PlayerName = "Chromecast";
var ApplicationID = "2D4B1DA3";
var currentWebAppSession;
var currentDevice;
var currentDeviceId;
// MediaController needs this // MediaController needs this
self.name = PlayerName; self.name = PlayerName;
@ -301,9 +302,7 @@
self.getTargets = function () { self.getTargets = function () {
var manager = ConnectSDK.discoveryManager; return ConnectHelper.getDeviceList().filter(function (d) {
return manager.getDeviceList().filter(function (d) {
return isChromecast(d.getModelName()) || isChromecast(d.getFriendlyName()); return isChromecast(d.getModelName()) || isChromecast(d.getFriendlyName());
@ -469,6 +468,7 @@
MediaController.setActivePlayer(PlayerName, convertDeviceToTarget(device)); MediaController.setActivePlayer(PlayerName, convertDeviceToTarget(device));
currentDevice = device; currentDevice = device;
currentDeviceId = device.getId();
$(castPlayer).trigger('connect'); $(castPlayer).trigger('connect');
@ -584,7 +584,7 @@
var deferred = $.Deferred(); var deferred = $.Deferred();
var device = ConnectSDK.discoveryManager.getDeviceList().filter(function (d) { var device = ConnectHelper.getDeviceList().filter(function (d) {
return d.getId() == target.id; return d.getId() == target.id;
})[0]; })[0];
@ -629,22 +629,31 @@
$(MediaController).on('playerchange', function (e, newPlayer, newTarget) { $(MediaController).on('playerchange', function (e, newPlayer, newTarget) {
if (currentDevice) { if (currentDevice) {
if (newTarget.id != currentDevice.getId()) { if (newTarget.id != currentDeviceId) {
if (currentWebAppSession) { if (currentWebAppSession) {
console.log('Disconnecting from chromecast'); console.log('Disconnecting from chromecast');
currentDevice.disconnect(); //currentDevice.disconnect();
currentDevice = null; currentDevice = null;
currentDeviceId = null;
} }
} }
} }
}); });
function onResume() {
var deviceId = currentDeviceId;
if (deviceId) {
self.tryPair({
id: deviceId
});
}
}
document.addEventListener("resume", onResume, false);
} }
function initSdk() { MediaController.registerPlayer(new chromecastPlayer());
MediaController.registerPlayer(new chromecastPlayer());
}
initSdk();
})(); })();

View file

@ -12,11 +12,25 @@
// new ConnectSDK.CapabilityFilter(["MediaPlayer.Display.Video", "MediaControl.Pause"]) // new ConnectSDK.CapabilityFilter(["MediaPlayer.Display.Video", "MediaControl.Pause"])
//]); //]);
manager.on('devicelistchanged', onDeviceListChanged);
manager.startDiscovery(); manager.startDiscovery();
requirejs(['thirdparty/cordova/chromecast', 'thirdparty/cordova/generaldevice']); requirejs(['thirdparty/cordova/chromecast', 'thirdparty/cordova/generaldevice']);
} }
function onDeviceListChanged(list) {
}
function getDeviceList() {
return ConnectSDK.discoveryManager.getDeviceList();
}
window.ConnectHelper = {
getDeviceList: getDeviceList
};
Dashboard.ready(initSdk); Dashboard.ready(initSdk);
})(); })();

View file

@ -400,9 +400,7 @@
self.getTargets = function () { self.getTargets = function () {
var manager = ConnectSDK.discoveryManager; return ConnectHelper.getDeviceList().filter(function (d) {
return manager.getDeviceList().filter(function (d) {
return isValid(d); return isValid(d);
@ -506,7 +504,7 @@
var deferred = $.Deferred(); var deferred = $.Deferred();
var device = ConnectSDK.discoveryManager.getDeviceList().filter(function (d) { var device = ConnectHelper.getDeviceList().filter(function (d) {
return d.getId() == target.id; return d.getId() == target.id;
})[0]; })[0];

View file

@ -0,0 +1,28 @@
(function () {
// Handle the volume down button
//
function onVolumeDownKeyDown() {
MediaController.volumeDown();
}
// Handle the volume up button
//
function onVolumeUpKeyDown() {
MediaController.volumeUp();
}
$(MediaController).on('playerchange', function (e, newPlayer, newTarget) {
document.removeEventListener("volumedownbutton", onVolumeDownKeyDown, false);
document.removeEventListener("volumeupbutton", onVolumeUpKeyDown, false);
if (!newPlayer.localPlayer) {
document.addEventListener("volumedownbutton", onVolumeDownKeyDown, false);
document.addEventListener("volumeupbutton", onVolumeUpKeyDown, false);
}
});
})();

View file

@ -0,0 +1,87 @@
(function (globalScope) {
function getResultCode(result) {
if (result != null && result.resultCode != null) {
return result.resultCode;
}
return result;
}
function closeSocket(socketId) {
try {
chrome.sockets.udp.close(socketId);
} catch (err) {
}
}
function stringToArrayBuffer(string) {
// UTF-16LE
var buf = new ArrayBuffer(string.length * 2);
var bufView = new Uint16Array(buf);
for (var i = 0, strLen = string.length; i < strLen; i++) {
bufView[i] = string.charCodeAt(i);
}
return buf;
}
// https://github.com/agnat/node_wake_on_lan/blob/master/wake_on_lan.js
globalScope.WakeOnLan = {
send: function (info) {
var deferred = DeferredBuilder.Deferred();
var chrome = globalScope.chrome;
if (!chrome) {
deferred.resolve();
return deferred.promise();
}
var port = info.Port || 9;
//chrome.sockets.udp.create(function (createInfo) {
// if (!createInfo) {
// console.log('create fail');
// return;
// }
// if (!createInfo.socketId) {
// console.log('create fail');
// return;
// }
// var socketId = createInfo.socketId;
// console.log('chrome.sockets.udp.bind');
// chrome.sockets.udp.bind(createInfo.socketId, '0.0.0.0', 0, function (bindResult) {
// if (getResultCode(bindResult) != 0) {
// console.log('bind fail: ' + bindResult);
// deferred.resolve();
// closeSocket(socketId);
// }
// var data = stringToArrayBuffer('who is EmbyServer?');
// console.log('chrome.sockets.udp.send');
// chrome.sockets.udp.send(createInfo.socketId, data, '255.255.255.255', port, function (sendResult) {
// deferred.resolve();
// closeSocket(socketId);
// });
// });
//});
deferred.resolve();
return deferred.promise();
}
};
})(window);

View file

@ -10,5 +10,4 @@
return 'file://' + path; return 'file://' + path;
} }
}; };
})(); })();

View file

@ -4,7 +4,7 @@
<title>Emby</title> <title>Emby</title>
</head> </head>
<body> <body>
<div id="wizardLibraryPage" data-role="page" class="page standalonePage wizardPage mediaLibraryPage"> <div id="wizardLibraryPage" data-role="page" class="page standalonePage wizardPage mediaLibraryPage" data-require="scripts/medialibrarypage">
<div data-role="content"> <div data-role="content">
@ -56,7 +56,7 @@
</div> </div>
</div> </div>
<br/> <br />
<div class="wizardNavigation"> <div class="wizardNavigation">
<button type="button" data-iconpos="left" data-icon="arrow-l" data-inline="true" onclick="history.back();">${LabelPrevious}</button> <button type="button" data-iconpos="left" data-icon="arrow-l" data-inline="true" onclick="history.back();">${LabelPrevious}</button>
<button type="button" data-iconpos="right" data-icon="arrow-r" data-inline="true" onclick="WizardLibraryPage.next();">${LabelNext}</button> <button type="button" data-iconpos="right" data-icon="arrow-r" data-inline="true" onclick="WizardLibraryPage.next();">${LabelNext}</button>