extract more scripts

This commit is contained in:
Luke Pulverenti 2015-06-09 01:56:46 -04:00
parent f64e0c7c53
commit d84e09e501
24 changed files with 238 additions and 90 deletions

View File

@ -4,7 +4,7 @@
<title>${TitleAutoOrganize}</title>
</head>
<body>
<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 id="libraryFileOrganizerLogPage" data-role="page" class="page type-interior organizePage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Auto-Organize" data-require="scripts/autoorganizelog,scripts/taskbutton">
<div data-role="content">
<div class="content-primary">

View File

@ -4,7 +4,7 @@
<title>Emby</title>
</head>
<body>
<div id="editCollectionTitlesPage" data-role="page" class="page libraryPage metadataEditorPage" data-contextname="${HeaderMetadataManager}">
<div id="editCollectionTitlesPage" data-role="page" class="page libraryPage metadataEditorPage" data-contextname="${HeaderMetadataManager}" data-require="scripts/editcollectionitems">
<div data-role="content editPageContent">
<div class="editPageSidebar">
<div class="libraryTree">
@ -68,10 +68,6 @@
</div>
</div>
<script type="text/javascript">
$('.collectionItemSearchForm').off('submit', EditCollectionItemsPage.onSearchFormSubmit).on('submit', EditCollectionItemsPage.onSearchFormSubmit);
</script>
</div>
</body>
</html>

View File

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

View File

@ -4,7 +4,7 @@
<title>${TitleLiveTV}</title>
</head>
<body>
<div id="liveTvStatusPage" data-role="page" class="page type-interior liveTvSettingsPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Live%20TV" data-require="scripts/livetvstatus">
<div id="liveTvStatusPage" data-role="page" class="page type-interior liveTvSettingsPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Live%20TV" data-require="scripts/livetvstatus,scripts/taskbutton">
<div data-role="content">
<div class="content-primary">

View File

@ -155,7 +155,7 @@
<br />
<div>
<label for="chkEnableChromecastAc3">${LabelEnableChromecastAc3Passthrough}</label>
<input type="checkbox" id="chkEnableChromecastAc3" />
<input type="checkbox" id="chkEnableChromecastAc3" data-mini="true" />
</div>
</div>

View File

@ -4,7 +4,7 @@
<title>${TitleSync}</title>
</head>
<body>
<div id="mySyncActivityPage" data-role="page" class="page libraryPage syncActivityPage mySyncPage" data-contextname="${TitleSync}">
<div id="mySyncActivityPage" data-role="page" class="page libraryPage syncActivityPage mySyncPage" data-contextname="${TitleSync}" data-require="scripts/syncactivity,scripts/taskbutton">
<div class="libraryViewNav">
<a href="#" class="ui-btn-active">${TabSyncJobs}</a>
@ -13,7 +13,7 @@
<div data-role="content">
<div class="ehsContent">
<br/>
<br />
<div class="syncActivity">
</div>

View File

@ -4,7 +4,7 @@
<title>${TitleSync}</title>
</head>
<body>
<div id="mySyncJobPage" data-role="page" class="page libraryPage syncJobPage mySyncPage" data-contextname="${TitleSync}">
<div id="mySyncJobPage" data-role="page" class="page libraryPage syncJobPage mySyncPage" data-contextname="${TitleSync}" data-require="scripts/syncjob">
<div class="libraryViewNav">
<a href="mysync.html" class="ui-btn-active">${TabSyncJobs}</a>
@ -20,9 +20,6 @@
<div class="jobItems"></div>
</div>
</div>
<script type="text/javascript">
$('.syncJobForm').off('submit', SyncJobPage.onSubmit).on('submit', SyncJobPage.onSubmit);
</script>
</div>
</body>
</html>

View File

@ -4,7 +4,7 @@
<title>Emby</title>
</head>
<body>
<div id="nowPlayingPage" data-role="page" class="page libraryPage nowPlayingPage" data-contextname="${TitleRemoteControl}" data-theme="b">
<div id="nowPlayingPage" data-role="page" class="page libraryPage nowPlayingPage" data-contextname="${TitleRemoteControl}" data-theme="b" data-require="scripts/nowplayingpage">
<div class="libraryViewNav">
<a href="#" class="ui-btn-active tabButton" data-tab="tabNowPlaying">${TabNowPlaying}</a>
@ -149,11 +149,6 @@
</div>
</div>
<script type="text/javascript">
$('.sendMessageForm').off('submit', NowPlayingPage.onMessageSubmit).on('submit', NowPlayingPage.onMessageSubmit);
$('.typeTextForm').off('submit', NowPlayingPage.onSendStringSubmit).on('submit', NowPlayingPage.onSendStringSubmit);
</script>
</div>
</body>
</html>

View File

@ -743,12 +743,18 @@
self.volumeDown = function () {
self.setVolume(getCurrentVolume() - 2);
castPlayer.sendMessage({
options: {},
command: 'VolumeDown'
});
};
self.volumeUp = function () {
self.setVolume(getCurrentVolume() + 2);
castPlayer.sendMessage({
options: {},
command: 'VolumeUp'
});
};
self.setVolume = function (vol) {

View File

@ -1377,7 +1377,7 @@ $(document).on('pageshowready', "#dashboardPage", DashboardPage.onPageShow).on('
var apiClient = ApiClient;
if (apiClient) {
if (apiClient && !AppInfo.isNativeApp) {
showWelcomeIfNeeded(page, apiClient);
}

View File

@ -230,7 +230,14 @@
});
}
$(document).on('pageinit', "#editCollectionTitlesPage", function () {
function onSearchFormSubmit() {
var page = $(this).parents('.page');
showSearchResults(page, $('#txtLookupName', page).val());
return false;
}
$(document).on('pageinitdepends', "#editCollectionTitlesPage", function () {
var page = this;
@ -270,8 +277,9 @@
removeItemsFromCollection(page);
});
$('.collectionItemSearchForm').off('submit', onSearchFormSubmit).on('submit', onSearchFormSubmit);
}).on('pagebeforeshow', "#editCollectionTitlesPage", function () {
}).on('pagebeforeshowready', "#editCollectionTitlesPage", function () {
var page = this;
@ -290,15 +298,4 @@
$("body").off("popupafteropen.collections");
});
window.EditCollectionItemsPage = {
onSearchFormSubmit: function () {
var page = $(this).parents('.page');
showSearchResults(page, $('#txtLookupName', page).val());
return false;
}
};
})(jQuery, document, window, window.FileReader, escape);

View File

@ -396,7 +396,7 @@
updateEditorNode(this, item);
}).on('pagebeforeshow', ".metadataEditorPage", function () {
}).on('pagebeforeshowready', ".metadataEditorPage", function () {
window.MetadataEditor = new metadataEditor();

View File

@ -714,13 +714,16 @@
return null;
};
$(document).on('pageinit', "#nowPlayingPage", function () {
$(document).on('pageinitdepends', "#nowPlayingPage", function () {
var page = this;
bindEvents(page);
}).on('pageshow', "#nowPlayingPage", function () {
$('.sendMessageForm').off('submit', NowPlayingPage.onMessageSubmit).on('submit', NowPlayingPage.onMessageSubmit);
$('.typeTextForm').off('submit', NowPlayingPage.onSendStringSubmit).on('submit', NowPlayingPage.onSendStringSubmit);
}).on('pageshowready', "#nowPlayingPage", function () {
var page = this;

View File

@ -230,8 +230,7 @@
{
complete: function () {
$('.viewMenuSearch').addClass('hide');
},
duration: 'fast'
}
});
});
}

View File

@ -1822,13 +1822,13 @@ var AppInfo = {};
return false;
});
require(['filesystem']);
if (Dashboard.isRunningInCordova()) {
requirejs(['thirdparty/cordova/connectsdk', 'scripts/registrationservices', 'thirdparty/cordova/volume', 'thirdparty/cordova/back']);
if ($.browser.android) {
requirejs(['thirdparty/cordova/android/androidcredentials', 'thirdparty/cordova/android/immersive', 'thirdparty/cordova/android/filesystem']);
} else {
requirejs(['thirdparty/cordova/filesystem']);
requirejs(['thirdparty/cordova/android/androidcredentials', 'thirdparty/cordova/android/immersive', 'thirdparty/cordova/android/mediasession']);
}
if ($.browser.safari) {
@ -1839,7 +1839,6 @@ var AppInfo = {};
if ($.browser.chrome) {
requirejs(['scripts/chromecast']);
}
requirejs(['thirdparty/filesystem']);
}
}
@ -1884,6 +1883,16 @@ var AppInfo = {};
define("localassetmanager", ["thirdparty/apiclient/localassetmanager"]);
}
if (Dashboard.isRunningInCordova() && $.browser.android) {
define("filesystem", ["thirdparty/cordova/android/filesystem"]);
}
else if (Dashboard.isRunningInCordova()) {
define("filesystem", ["thirdparty/cordova/filesystem"]);
}
else {
define("filesystem", ["thirdparty/filesystem"]);
}
define("connectservice", ["thirdparty/apiclient/connectservice"]);
//requirejs(['http://viblast.com/player/free-version/qy2fdwajo1/viblast.js']);

View File

@ -289,7 +289,7 @@
}
$(document).on('pageshow', ".syncActivityPage", function () {
$(document).on('pageshowready', ".syncActivityPage", function () {
var page = this;

View File

@ -373,7 +373,21 @@
}
$(document).on('pageshow', ".syncJobPage", function () {
function onSubmit() {
var form = this;
var page = $(form).parents('.page');
saveJob(page);
return false;
}
$(document).on('pageinitdepends', ".syncJobPage", function () {
$('.syncJobForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshowready', ".syncJobPage", function () {
var page = this;
loadJob(page);
@ -389,18 +403,4 @@
$(ApiClient).off(".syncJobPage");
});
window.SyncJobPage = {
onSubmit: function () {
var form = this;
var page = $(form).parents('.page');
saveJob(page);
return false;
}
};
})();

View File

@ -430,7 +430,17 @@
});
}
$(document).on('pageinit', "#userProfilesPage", function () {
function onSubmit() {
var form = this;
var page = $(form).parents('.page');
inviteUser(page);
return false;
}
$(document).on('pageinitdepends', "#userProfilesPage", function () {
var page = this;
@ -439,25 +449,13 @@
showInvitePopup(page);
});
}).on('pagebeforeshow', "#userProfilesPage", function () {
$('.addUserForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pagebeforeshowready', "#userProfilesPage", function () {
var page = this;
loadData(page);
});
window.UserProfilesPage = {
onSubmit: function () {
var form = this;
var page = $(form).parents('.page');
inviteUser(page);
return false;
}
};
})(document, window, jQuery);

View File

@ -4,7 +4,7 @@
<title>${TitleSync}</title>
</head>
<body>
<div id="syncActivityPage" data-role="page" class="page type-interior syncConfigurationPage syncActivityPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Sync">
<div id="syncActivityPage" data-role="page" class="page type-interior syncConfigurationPage syncActivityPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Sync" data-require="scripts/syncactivity,scripts/taskbutton">
<div data-role="content">
<div class="content-primary">

View File

@ -4,7 +4,7 @@
<title>${TitleSync}</title>
</head>
<body>
<div id="syncJobPage" data-role="page" class="page type-interior syncConfigurationPage syncJobPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Sync">
<div id="syncJobPage" data-role="page" class="page type-interior syncConfigurationPage syncJobPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Sync" data-require="scripts/syncjob">
<div data-role="content">
<div class="content-primary">
@ -23,9 +23,6 @@
</div>
</div>
</div>
<script type="text/javascript">
$('.syncJobForm').off('submit', SyncJobPage.onSubmit).on('submit', SyncJobPage.onSubmit);
</script>
</div>
</body>
</html>

View File

@ -0,0 +1,148 @@
(function () {
// Reports media playback to the device for lock screen control
var currentPlayer;
var lastPlayerState;
function updatePlayerState(state, eventName) {
if (!state.NowPlayingItem) {
hideMediaControls();
return;
}
// dummy this up
if (eventName == 'init') {
eventName = 'positionchange';
}
lastPlayerState = state;
var playState = state.PlayState || {};
var nameHtml = MediaController.getNowPlayingNameHtml(state.NowPlayingItem) || '';
var parts = nameHtml.split('<br/>');
var artist = parts.length == 1 ? '' : parts[0];
var title = parts[parts.length - 1];
var album = state.NowPlayingItem.Album || '';
var duration = state.NowPlayingItem.RunTimeTicks ? (state.NowPlayingItem.RunTimeTicks / 10000000) : 0;
var position = playState.PositionTicks ? (playState.PositionTicks / 10000000) : 0;
var isPaused = playState.IsPaused || false;
var canSeek = playState.CanSeek || false;
var url = '';
var imgHeight = 200;
var nowPlayingItem = state.NowPlayingItem;
if (nowPlayingItem.PrimaryImageTag) {
url = ApiClient.getScaledImageUrl(nowPlayingItem.PrimaryImageItemId, {
type: "Primary",
height: imgHeight,
tag: nowPlayingItem.PrimaryImageTag
});
} else if (nowPlayingItem.ThumbImageTag) {
url = ApiClient.getScaledImageUrl(nowPlayingItem.ThumbImageItemId, {
type: "Thumb",
height: imgHeight,
tag: nowPlayingItem.ThumbImageTag
});
}
else if (nowPlayingItem.BackdropImageTag) {
url = ApiClient.getScaledImageUrl(nowPlayingItem.BackdropItemId, {
type: "Backdrop",
height: imgHeight,
tag: nowPlayingItem.BackdropImageTag,
index: 0
});
}
MainActivity.updateMediaSession(eventName, title, artist, album, parseInt(duration), parseInt(position), url, canSeek, isPaused);
}
function onStateChanged(e, state) {
updatePlayerState(state, e.type);
}
function onPlaybackStart(e, state) {
console.log('nowplaying event: ' + e.type);
var player = this;
player.beginPlayerUpdates();
onStateChanged.call(player, e, state);
}
function onPlaybackStopped(e, state) {
console.log('nowplaying event: ' + e.type);
var player = this;
player.endPlayerUpdates();
hideMediaControls();
}
function releaseCurrentPlayer() {
if (currentPlayer) {
$(currentPlayer).off('.cordovaremote');
currentPlayer.endPlayerUpdates();
currentPlayer = null;
hideMediaControls();
}
}
function hideMediaControls() {
MainActivity.hideMediaSession();
}
function bindToPlayer(player) {
releaseCurrentPlayer();
currentPlayer = player;
console.log('binding remotecontrols to MediaPlayer');
player.getPlayerState().done(function (state) {
if (state.NowPlayingItem) {
player.beginPlayerUpdates();
}
onStateChanged.call(player, { type: 'init' }, state);
});
$(player).on('playbackstart.cordovaremote', onPlaybackStart)
.on('playbackstop.cordovaremote', onPlaybackStopped)
.on('playstatechange.cordovaremote', onStateChanged)
.on('positionchange.cordovaremote', onStateChanged);
}
Dashboard.ready(function () {
console.log('binding remotecontrols to MediaController');
$(MediaController).on('playerchange', function () {
bindToPlayer(MediaController.getCurrentPlayer());
});
bindToPlayer(MediaController.getCurrentPlayer());
});
})();

View File

@ -371,12 +371,18 @@
self.volumeDown = function () {
self.setVolume(getCurrentVolume() - 2);
sendMessageToDevice({
options: {},
command: 'VolumeDown'
});
};
self.volumeUp = function () {
self.setVolume(getCurrentVolume() + 2);
sendMessageToDevice({
options: {},
command: 'VolumeUp'
});
};
self.setVolume = function (vol) {

View File

@ -4,7 +4,7 @@
<title>${TitleUsers}</title>
</head>
<body>
<div id="userProfilesPage" data-role="page" class="page type-interior userProfilesPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Users">
<div id="userProfilesPage" data-role="page" class="page type-interior userProfilesPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Users" data-require="scripts/userprofilespage">
<div data-role="content">
<div class="content-primary">
@ -84,9 +84,6 @@
</div>
</div>
<script type="text/javascript">
$('.addUserForm').off('submit', UserProfilesPage.onSubmit).on('submit', UserProfilesPage.onSubmit);
</script>
</div>
</body>
</html>

View File

@ -4,7 +4,7 @@
<title>Emby</title>
</head>
<body>
<div id="wizardLibraryPage" data-role="page" class="page standalonePage wizardPage mediaLibraryPage" data-require="scripts/medialibrarypage">
<div id="wizardLibraryPage" data-role="page" class="page standalonePage wizardPage mediaLibraryPage" data-require="scripts/medialibrarypage,scripts/taskbutton">
<div data-role="content">