Fixed some problems.

This commit is contained in:
Tamius Han 2017-12-17 22:56:07 +01:00
parent 66cc44ab6d
commit c9719a163a
8 changed files with 70 additions and 151 deletions

15
js/conf/ExtensionConf.js Normal file
View File

@ -0,0 +1,15 @@
// blacklist - ban blacklist.
// whitelist - ban all except whitelist
// none - ban all
var _ec_mode = "blacklist"
var _ec_init = function() {
console.log("pls implement");
console.log("this: ", this);
}
ExtensionConf = {
mode: _ec_mode,
init: _ec_init
}

View File

@ -55,7 +55,7 @@ var DEFAULT_KEYBINDINGS = [
key: "a",
modifiers: []
}
};
];
// functions
@ -70,12 +70,12 @@ var _kbd_callback = function(keys) {
}
var _kbd_setup_init = function() {
StorageManager.getopt("keybinds", _kbd_callback);
return StorageManager.getopt("keybinds", _kbd_callback);
}
var _kbd_setup_apply = function(var keybinds){
var _kbd_setup_apply = function(keybinds){
if(Debug.debug || Debug.keyboard)
console.log("uw::keydownSetup | starting keybord shortcut setup");
@ -161,6 +161,6 @@ var _kbd_setup_apply = function(var keybinds){
// _kbd_setup_init();
var Keybinds = {
init: _kbd_setup_init(),
apply: _kbd_setup_apply()
init: _kbd_setup_init,
apply: _kbd_setup_apply
}

View File

@ -4,6 +4,10 @@
if(Debug.debug)
console.log("Loading: Settings.js");
var _se_init = function(){
console.log("pls load settings from localstorage here");
}
Settings = {
arDetect: {
enabled: "global",
@ -17,5 +21,6 @@ Settings = {
},
miscFullscreenSettings: {
videoFloat: "center",
}
},
init: _se_init
}

View File

@ -42,10 +42,10 @@ var _sc_prepareNonfsPlayer = function(){
}
var _sc_getMode = function(site){
if(! SITES[site] )
if(! this.sites[site] )
return "global";
return SITES[site].enabled;
return this.sites[site].enabled;
}
@ -53,14 +53,14 @@ var _sc_getMode = function(site){
var _sc_callback = function(conf) {
if (conf === null || conf === {} || conf === [] || conf == ""){
StorageManager.setopt( {"sitesconf": _sc_SITES} );
SITES = _sc_SITES;
this.sites = _sc_SITES;
}
SITES = conf;
this.sites = conf;
}
var _sc_init = function() {
StorageManager.getopt("sitesconf", _kbd_callback);
return StorageManager.getopt("sitesconf", _sc_callback);
}
@ -129,22 +129,13 @@ var _sc_SITES = {
}
}
}
"vid.me": {
enabled: "global",
type: "official",
autoAr: {
passive: false;
active: true;
nonfs: true;
}
}
}
_sc_init();
var SitesConf = {
nonfsArDetectEnabled: _sc_nonfsAutoar,
getPlayerTag: _sc_getPlayerTag,
prepareNonfsPlayer: _sc_prepareNonfsPlayer,
getMode: _sc_getMode
getMode: _sc_getMode,
init: _sc_init,
sites: null
}

View File

@ -1,116 +0,0 @@
var UW_UI_BUTTONS = {
fitw: {
native_bar: true,
has_submenu: false,
button: true,
icon: "/res/img/ytplayer-icons/fitw.png",
text: "Fit to width",
onclick: function(){ changeCSS("fit", "fitw") }
},
fith: {
native_bar: true,
has_submenu: false,
button: true,
icon: "/res/img/ytplayer-icons/fith.png",
text: "Fit to height",
onclick: function(){ changeCSS("fit", "fith") }
},
reset: {
native_bar: true,
has_submenu: false,
button: true,
icon: "/res/img/ytplayer-icons/reset.png",
text: "Reset",
onclick: function(){ changeCSS("reset", "reset") }
},
zoom: {
native_bar: true,
has_submenu: false,
button: true,
icon: "/res/img/ytplayer-icons/zoom.png",
text: "Zoom",
onclick: function(){ changeCSS("fit", "zoom") }
},
unzoom: {
native_bar: true,
has_submenu: false,
button: true,
icon: "/res/img/ytplayer-icons/unzoom.png",
text: "Unzoom",
onclick: function(){ changeCSS("fit", "unzoom") }
},
zoom: {
native_bar: true,
has_submenu: false,
button: true,
icon: "/res/img/ytplayer-icons/zoom.png",
text: "Reset",
onclick: function(){ changeCSS("fit", "zoom") }
},
autoar: {
native_bar: false,
has_submenu: false,
button: false,
text: "Detect aspect ratio via 3rd party",
onclick: function(){ manual_autoar()}
},
settings: {
native_bar: true,
button: true,
icon: "/res/img/ytplayer-icons/settings.png",
text: "Settings",
has_submenu: true,
submenu: [ "fitw","fith","reset","zoom","unzoom","autoar","ar" ],
top_level: true,
submenu_id: "uw_settings_menu",
onclick: function(){ toggleMenu("uw_settings_menu") }
},
ar: {
native_bar: false,
button: false,
text: "Force aspect ratio",
has_submenu: true,
submenu: [ "ar219", "ar169", "ar1610", "ar43" ],
submenu_id: "uw_force_ar_menu",
onclick: function(){ showMenu("uw_force_ar_menu") }
},
ar219: {
native_bar: false,
button: false,
text: "21:9",
has_submenu: false,
onclick: function(){ changeCSS("char", ( 21/9 )); }
},
ar169: {
native_bar: false,
button: false,
text: "16:9",
has_submenu: false,
onclick: function(){ changeCSS("char", ( 16/9 )); }
},
ar1610: {
native_bar: false,
button: false,
text: "16:10",
has_submenu: false,
onclick: function(){ changeCSS("char", ( 1.6 )); }
},
ar43: {
native_bar: false,
button: false,
text: "4:3",
has_submenu: false,
onclick: function(){ changeCSS("char", ( 4/3 )); }
}
}
var UW_UI_BANLIST = {
youtube: {
autoar: "all"
},
netflix: {
settings: "all"
}
}

View File

@ -2,16 +2,16 @@
// setopt, getopt, delopt. They set/get/delete stuff from the storage
var _sm_setopt = function(item){
browser.storage.local.set(item);
return browser.storage.local.set(item);
}
var _sm_getopt = function(prop, callback){
if(BrowserDetect.usebrowser == "chrome")
browser.storage.local.get(prop, callback);
return browser.storage.local.get(prop, callback);
else
browser.storage.local.get(prop).then(callback);
return browser.storage.local.get(prop).then(callback);
}
var _sm_delopt = function(item){
browser.storage.local.remove(item);
return browser.storage.local.remove(item);
}
var StorageManager = {

View File

@ -3,15 +3,33 @@ if(Debug.debug)
// load all settings from localStorage:
async function main(){
if(Debug.debug)
console.log("loading configuration ...");
// start autoar and setup everything
// load settings
Settings.init();
var scpromise = SitesConf.init();
var kbpromise = Keybinds.init();
ExtensionConf.init();
console.log(scpromise);
// počakamo, da so nastavitve naložene
// wait for settings to load
await scpromise;
await kbpromise;
$(document).ready(function() {
if(Debug.debug)
console.log("configuration should be loaded now");
// start autoar and setup everything
// $(document).ready(function() {
if(Debug.debug)
console.log("uw::document.ready | document is ready. Starting ar script ...");
//
if(SitesConf.getMode(window.location.hostname) == "blacklist" ){
if(Debug.debug)
console.log("uw::document.ready | site", window.location.hostname, "is blacklisted.");
@ -19,13 +37,13 @@ $(document).ready(function() {
return;
}
if( ExtensionConf.getMode() == "none" ){
if( ExtensionConf.mode == "none" ){
if(Debug.debug)
console.log("uw::document.ready | Extension is soft-disabled via popup");
return;
}
if( ExtensionConf.getMode() == "whitelist" && SitesConf.getMode(window.location.hostname) != "whitelist"){
if( ExtensionConf.mode == "whitelist" && SitesConf.getMode(window.location.hostname) != "whitelist"){
if(Debug.debug)
console.log("uw::document.ready | extension is set to run on whitelisted sites only, but site ", window.location.hostname, "is not on whitelist.");
@ -34,7 +52,6 @@ $(document).ready(function() {
ArDetect.arSetup();
document.addEventListener("mozfullscreenchange", function( event ) {
if(FullScreenDetect.isFullScreen()){
// full screen is on
@ -44,4 +61,7 @@ $(document).ready(function() {
}
});
});
// });
}
main();

View File

@ -17,10 +17,14 @@
"js": [
"js/dep/jquery-3.1.1.js",
"js/lib/BrowserDetect.js",
"js/lib/StorageManager.js",
"js/conf/Debug.js",
"js/conf/Settings.js",
"js/conf/SitesConf.js",
"js/conf/Status.js",
"js/conf/ExtensionConf.js",
"js/lib/FullScreenDetect.js",