Cleanup code

This commit is contained in:
Dmitry Lyzo 2020-01-18 11:41:46 +03:00
parent 12045b81a0
commit 7c4f117b96

View File

@ -3,9 +3,6 @@
console.log('Tizen adapter'); console.log('Tizen adapter');
window.addEventListener('load', function() { window.addEventListener('load', function() {
//console.log(JSON.stringify(tizen.tvinputdevice.getSupportedKeys()));
tizen.tvinputdevice.registerKey('MediaPlay'); tizen.tvinputdevice.registerKey('MediaPlay');
tizen.tvinputdevice.registerKey('MediaPause'); tizen.tvinputdevice.registerKey('MediaPause');
tizen.tvinputdevice.registerKey('MediaTrackPrevious'); tizen.tvinputdevice.registerKey('MediaTrackPrevious');
@ -14,7 +11,6 @@ window.addEventListener('load', function() {
tizen.tvinputdevice.registerKey('MediaFastForward'); tizen.tvinputdevice.registerKey('MediaFastForward');
require(['inputManager', 'focusManager', 'viewManager', 'appRouter', 'actionsheet'], function(inputManager, focusManager, viewManager, appRouter, actionsheet) { require(['inputManager', 'focusManager', 'viewManager', 'appRouter', 'actionsheet'], function(inputManager, focusManager, viewManager, appRouter, actionsheet) {
const commands = { const commands = {
'10009': 'back', '10009': 'back',
'19': 'pause', '19': 'pause',
@ -31,22 +27,10 @@ window.addEventListener('load', function() {
var historyDepth = 0; var historyDepth = 0;
var exitPromise; var exitPromise;
//document.addEventListener('keypress', function(e) {
// console.log('keypress');
//});
//document.addEventListener('keyup', function(e) {
// console.log('keyup');
//});
document.addEventListener('keydown', function(e) { document.addEventListener('keydown', function(e) {
//console.log('keydown: keyCode: ' + e.keyCode + ' key: ' + e.key + ' location: ' + e.location);
var command = commands[e.keyCode]; var command = commands[e.keyCode];
if (command) { if (command) {
//console.log('command: ' + command);
if (command === 'back' && historyDepth < 2 && !exitPromise) { if (command === 'back' && historyDepth < 2 && !exitPromise) {
exitPromise = actionsheet.show({ exitPromise = actionsheet.show({
title: Globalize.translate('Exit?'), title: Globalize.translate('Exit?'),
@ -130,7 +114,6 @@ window.addEventListener('load', function() {
document.addEventListener('viewshow', installMutationObserver); document.addEventListener('viewshow', installMutationObserver);
window.addEventListener('pushState', function(e) { window.addEventListener('pushState', function(e) {
// Reset history on some pages // Reset history on some pages
var path = e.arguments && e.arguments[2] ? e.arguments[2] : ''; var path = e.arguments && e.arguments[2] ? e.arguments[2] : '';
@ -154,14 +137,11 @@ window.addEventListener('load', function() {
historyDepth++; historyDepth++;
isRestored = false; isRestored = false;
//console.log('history: ' + historyDepth + ', ' + historyStartup);
}); });
window.addEventListener('popstate', function() { window.addEventListener('popstate', function() {
historyDepth--; historyDepth--;
isRestored = true; isRestored = true;
//console.log('history: ' + historyDepth + ', ' + historyStartup);
}); });
// Add 'pushState' and 'replaceState' events // Add 'pushState' and 'replaceState' events