2017-01-21 18:31:47 +01:00
var browser _autodetect = true ;
var usebrowser = "chrome" ;
2017-03-13 20:34:59 +01:00
var debugmsg = true ;
2017-01-21 18:31:47 +01:00
if ( browser _autodetect ) {
2017-03-02 20:06:53 +01:00
if ( typeof browser === "undefined" ) {
if ( chrome ) {
browser = chrome ;
usebrowser = "chrome" ;
2017-01-21 18:31:47 +01:00
}
}
else
usebrowser = "firefox" ;
}
else {
if ( usebrowser == "chrome" )
browser = chrome ;
}
2016-12-07 23:58:43 +01:00
function showAbout ( ) {
2017-01-19 21:29:54 +01:00
clearPage ( ) ;
2016-12-07 23:58:43 +01:00
2017-01-19 21:29:54 +01:00
document . getElementById ( "about" ) . classList . remove ( "hide" ) ;
2016-12-07 23:58:43 +01:00
document . getElementById ( "tab_about" ) . classList . add ( "tab-selected" ) ;
}
function showShortcuts ( ) {
2017-01-19 21:29:54 +01:00
clearPage ( ) ;
2016-12-07 23:58:43 +01:00
document . getElementById ( "uw_shortcuts" ) . classList . remove ( "hide" ) ;
2017-01-19 21:29:54 +01:00
document . getElementById ( "tab_shortcuts" ) . classList . add ( "tab-selected" ) ;
}
function showGeneralSettings ( ) {
clearPage ( ) ;
document . getElementById ( "general_settings" ) . classList . remove ( "hide" ) ;
document . getElementById ( "tab_general_settings" ) . classList . add ( "tab-selected" ) ;
}
2017-03-02 20:06:53 +01:00
function showSites ( ) {
clearPage ( ) ;
document . getElementById ( "uw_sites" ) . classList . remove ( "hide" ) ;
document . getElementById ( "tab_sites" ) . classList . add ( "tab-selected" ) ;
}
2017-01-19 21:29:54 +01:00
function clearPage ( ) {
// Hide you sections
document . getElementById ( "uw_shortcuts" ) . classList . add ( "hide" ) ;
2016-12-07 23:58:43 +01:00
document . getElementById ( "about" ) . classList . add ( "hide" ) ;
2017-01-19 21:29:54 +01:00
document . getElementById ( "general_settings" ) . classList . add ( "hide" ) ;
2017-03-02 20:06:53 +01:00
document . getElementById ( "uw_sites" ) . classList . add ( "hide" ) ;
2016-12-07 23:58:43 +01:00
2017-01-19 21:29:54 +01:00
// Hide you tabs
document . getElementById ( "tab_shortcuts" ) . classList . remove ( "tab-selected" ) ;
2016-12-07 23:58:43 +01:00
document . getElementById ( "tab_about" ) . classList . remove ( "tab-selected" ) ;
2017-01-19 21:29:54 +01:00
document . getElementById ( "tab_general_settings" ) . classList . remove ( "tab-selected" ) ;
2017-03-02 20:06:53 +01:00
document . getElementById ( "tab_sites" ) . classList . remove ( "tab-selected" ) ;
2016-12-07 23:58:43 +01:00
}
function saveopts ( ) {
2017-01-19 21:29:54 +01:00
var actions = [ "fitw" , "fith" , "reset" , "zoom" , "unzoom" , "ar219" , "ar169" , "ar1610" , "ar43" , "autoar" ] ;
2016-12-07 23:58:43 +01:00
var new _keybinds = { } ;
// Preberemo naš obrazec in iz njega naredimo nov objekt z bližnjicami.
// Let's read our form and make a new object with keybinds.
for ( var i = 0 ; i < actions . length ; i ++ ) {
var action = actions [ i ] ;
var targetAR = "" ;
if ( action == "ar219" ) {
action = "char" ;
targetAR = ( 21 / 9 ) ;
}
if ( action == "ar169" ) {
action = "char" ;
targetAR = ( 16 / 9 ) ;
}
if ( action == "ar1610" ) {
action = "char" ;
targetAR = ( 16 / 10 ) ;
}
if ( action == "ar43" ) {
action = "char" ;
targetAR = ( 4 / 3 ) ;
}
if ( targetAR != "" ) {
var keybind = {
action : action ,
targetAR : targetAR ,
key : document . querySelector ( "#" + actions [ i ] + "_letter" ) . value . toLowerCase ( ) . replace ( /[^a-z0-9]/ , "" ) ,
modifiers : [ ]
}
}
else {
var keybind = {
action : action ,
key : document . querySelector ( "#" + actions [ i ] + "_letter" ) . value . toLowerCase ( ) . replace ( /[^a-z0-9]/ , "" ) ,
modifiers : [ ]
}
}
if ( document . querySelector ( "#" + actions [ i ] + "_ctrl" ) . checked )
keybind . modifiers . push ( "ctrl" ) ;
if ( document . querySelector ( "#" + actions [ i ] + "_alt" ) . checked )
keybind . modifiers . push ( "alt" ) ;
if ( document . querySelector ( "#" + actions [ i ] + "_shift" ) . checked )
keybind . modifiers . push ( "shift" ) ;
new _keybinds [ i ] = keybind ;
}
// Preveriti moramo, da nismo dvema možnostima dodali isto bližnjico.
// We need to check if all keybinds are unique.
var fail = false ;
for ( var i = 0 ; i < actions . length ; i ++ )
document . querySelector ( "#" + actions [ i ] + "_letter" ) . classList . remove ( "dup_keybinds" ) ;
for ( var i = 0 ; i < actions . length ; i ++ ) {
if ( new _keybinds [ i ] . key == "" )
continue ;
for ( var j = i + 1 ; j < actions . length ; j ++ ) {
if ( new _keybinds [ i ] . key == new _keybinds [ j ] . key ) {
if ( compareModifiers ( new _keybinds [ i ] . modifiers , new _keybinds [ j ] . modifiers ) ) {
fail = true ;
document . querySelector ( "#" + actions [ i ] + "_letter" ) . classList . add ( "dup_keybinds" ) ;
document . querySelector ( "#" + actions [ j ] + "_letter" ) . classList . add ( "dup_keybinds" ) ;
}
}
}
}
if ( ! fail ) {
browser . storage . local . set ( { ultrawidify _keybinds : new _keybinds } ) ;
}
}
2017-01-19 21:29:54 +01:00
function saveAutoar ( ) {
setopt ( { ultrawidify _autoar : document . querySelector ( "#enable_autoar" ) . checked } ) ;
}
2017-02-22 13:53:40 +01:00
function saveUI ( ) {
var show _ui = document . querySelector ( "#enable_ui" ) ;
var ui _compact = document . querySelector ( "#enable_ui_compact" ) ;
var optionLine = document . getElementById ( "compact_ui_suboption" ) ;
if ( show _ui . checked ) {
ui _compact . disabled = false ;
optionLine . classList . remove ( "hide" ) ;
setopt ( { ultrawidify _ui : ui _compact . checked ? "compact" : "all" } ) ;
}
else {
ui _compact . disabled = true ;
optionLine . classList . add ( "hide" ) ;
setopt ( { ultrawidify _ui : "none" } ) ;
}
}
2017-01-19 21:29:54 +01:00
// setopt in getopt. Shranita oz. dobita stvari iz skladišča
// setopt, getopt. They set/get stuff from the storage
function setopt ( item ) {
browser . storage . local . set ( item ) ;
}
function getopt ( prop , callback ) {
2017-01-21 18:31:47 +01:00
if ( usebrowser == "chrome" )
browser . storage . local . get ( prop , callback ) ;
else
browser . storage . local . get ( prop ) . then ( callback ) ;
2017-01-19 21:29:54 +01:00
}
2016-12-07 23:58:43 +01:00
function compareModifiers ( a , b ) {
//NOTE: to je precej slab in neprenoslijv način primerjanja dveh tabel, ampak za naš primer deluje dovolj
// dobro, saj 'ctrl' vedno pride pred 'alt' in 'alt' vedno pride pred 'shift' (če se sploh pojavijo).
//NOTE: this is bad and totally unfoolproof practice. In our example comparing arrays the way we do works
// because values ALWAYS appear in the same order: 'ctrl' always appears before 'alt' (or it doesn't
// appear at all). 'alt' always appears before 'shift' (or it doesn't appear at all).
if ( a . length != b . length )
return false ;
var match = true ;
for ( var i = 0 ; i < a . length ; i ++ )
match &= a [ i ] == b [ i ]
return match ;
}
function printerr ( err ) {
console . log ( err ) ;
}
function gotopts ( opts ) {
2017-03-02 20:06:53 +01:00
if ( ! opts . ultrawidify _keybinds ) {
console . log ( "ultrawidify keybinds are undefined. the fuck?" , opts ) ;
return ;
}
2016-12-07 23:58:43 +01:00
var KEYBINDS = Object . keys ( opts . ultrawidify _keybinds ) . map ( function ( key ) { return opts . ultrawidify _keybinds [ key ] ; } ) ;
2017-03-02 20:06:53 +01:00
// google chrome is really the untermensch browse // google chrome is really the untermensch browserr
2017-01-19 21:29:54 +01:00
var actions = [ "fitw" , "fith" , "reset" , "zoom" , "unzoom" , "ar219" , "ar169" , "ar1610" , "ar43" , "autoar" ] ;
2016-12-07 23:58:43 +01:00
for ( var i = 0 ; i < actions . length ; i ++ ) {
document . querySelector ( "#" + actions [ i ] + "_letter" ) . classList . remove ( "dup_keybinds" ) ;
document . querySelector ( "#" + actions [ i ] + "_letter" ) . value = KEYBINDS [ i ] . key ;
for ( var j = 0 ; j < KEYBINDS [ i ] . modifiers . length ; j ++ ) {
if ( KEYBINDS [ i ] . modifiers [ j ] == "ctrl" )
document . querySelector ( "#" + actions [ i ] + "_ctrl" ) . checked = true ;
if ( KEYBINDS [ i ] . modifiers [ j ] == "alt" )
document . querySelector ( "#" + actions [ i ] + "_alt" ) . checked = true ;
if ( KEYBINDS [ i ] . modifiers [ j ] == "shift" )
document . querySelector ( "#" + actions [ i ] + "_shift" ) . checked = true ;
}
}
}
2017-02-22 13:53:40 +01:00
function gotar ( opts ) {
}
function gotui ( opts ) {
var show _ui = document . querySelector ( "#enable_ui" ) ;
var ui _compact = document . querySelector ( "#enable_ui_compact" ) ;
var optionLine = document . getElementById ( "compact_ui_suboption" ) ;
if ( opts . ultrawidify _ui == "all" ) {
show _ui . checked = true ;
ui _compact . checked = false ;
optionLine . classList . remove ( "hide" ) ;
}
else if ( opts . ultrawidify _ui == "compact" ) {
show _ui . checked = true ;
ui _compact . checked = true ;
optionLine . classList . remove ( "hide" ) ;
}
else if ( opts . ultrawidify _ui == "none" ) {
show _ui . checked = false ;
ui _compact . checked = false ;
optionLine . classList . add ( "hide" ) ;
}
}
2017-03-02 20:06:53 +01:00
function gotsites ( opts ) {
var list = document . getElementById ( "uw_sites_list" ) ;
if ( list )
list . remove ( ) ;
var anchor = document . getElementById ( "uw_sites_body" ) ;
list = document . createElement ( "div" ) ;
list . id = "uw_sites_list" ;
list . className = "uw_sites" ;
anchor . appendChild ( list ) ;
uw _sites = opts . ultrawidify _siterules ;
console . log ( "opts" , opts ) ;
2017-03-13 20:34:59 +01:00
for ( type in { "official" : 1 , "non-official" : 1 , "custom" : 1 , "add new site" : 1 } ) { // unparalleled laziness!
2017-03-02 20:06:53 +01:00
var head = document . createElement ( "div" ) ;
head . className = "sites_header" ;
head . textContent = type . charAt ( 0 ) . toUpperCase ( ) + type . slice ( 1 ) ;
var category _desc = document . createElement ( "div" ) ;
if ( type == "official" ) {
2017-03-14 23:51:03 +01:00
category _desc . innerHTML = "These sites are officially supported by the extension developer. These sites should always work. <small>(Pro tip: if you don't want extension to run on some of the following sites, uncheck the checkbox for that site)</small>" ;
2017-03-02 20:06:53 +01:00
}
else if ( type == "non-official" ) {
category _desc . textContent = "Sites in this category have been contribued by third parties. These sites will probably work, but the developer couldn't test whether they work or not." ;
}
else if ( type == "custom" ) {
category _desc . textContent = "In this section, you can define rules for sites that aren't supported either officially or non-officially. See [todo: link] contributing for details. If you define a custom site, please consider sharing configuration on github (see contributing for details)." ;
}
2017-03-13 20:34:59 +01:00
else if ( type == "add new site" ) {
category _desc . textContent = "Add a custom site by filling the form below." ;
}
2017-03-02 20:06:53 +01:00
list . append ( head ) ;
list . append ( category _desc ) ;
2017-03-13 20:34:59 +01:00
var category _counter = 0 ;
2017-03-02 20:06:53 +01:00
for ( site in uw _sites ) {
if ( uw _sites [ site ] . type == type ) {
var entry = document . createElement ( "div" ) ;
var displayedInfo = document . createElement ( "div" ) ;
displayedInfo . id = site + "_display" ;
displayedInfo . className = "uw_options_line site_details" ;
var siteTitle = document . createElement ( "div" ) ;
siteTitle . className = "site_name" ;
{
var sitecb = mkcb ( site , uw _sites [ site ] . enabled , true ) ;
var editTitle = mkebox ( site , site )
editTitle . className = "site_title_ebox" ;
siteTitle . append ( sitecb ) ;
siteTitle . append ( editTitle ) ;
var editBtn = document . createElement ( "div" ) ;
editBtn . textContent = "« edit »" ;
editBtn . className = "inline_button" ;
2017-03-13 20:34:59 +01:00
editBtn . id = site + "_edit_button" ;
editBtn . addEventListener ( "click" , function ( ) { var site = this . id ; site = site . replace ( "_edit_button" , "" ) ; enableEditing ( site ) } ) ;
var saveBtn = document . createElement ( "div" ) ;
saveBtn . textContent = "« save »" ;
saveBtn . className = "inline_button hide" ;
saveBtn . id = site + "_save_button" ;
2017-03-14 23:51:03 +01:00
saveBtn . addEventListener ( "click" , function ( ) { var site = this . id ; site = site . replace ( "_save_button" , "" ) ; getSiteOpts ( site ) } ) ;
2017-03-02 20:06:53 +01:00
2017-03-13 20:34:59 +01:00
var cancelBtn = document . createElement ( "div" ) ;
cancelBtn . textContent = "« cancel »" ;
cancelBtn . className = "inline_button hide" ;
cancelBtn . id = site + "_cancel_button" ;
cancelBtn . addEventListener ( "click" , function ( ) { var site = this . id ; site = site . replace ( "_cancel_button" , "" ) ; enableEditing ( site ) } ) ;
2017-03-02 20:06:53 +01:00
siteTitle . append ( editBtn ) ;
2017-03-13 20:34:59 +01:00
siteTitle . append ( saveBtn ) ;
siteTitle . append ( cancelBtn ) ;
2017-03-02 20:06:53 +01:00
}
2017-03-14 23:51:03 +01:00
var siteDetails = document . createElement ( "div" ) ;
siteDetails . id = site + "_conf_details" ;
siteDetails . classList = "hide" ;
2017-03-02 20:06:53 +01:00
var urlRules = document . createElement ( "div" ) ;
{
var urlRulesLabel = document . createElement ( "span" ) ;
urlRulesLabel . textContent = "URL rule: " ;
2017-03-14 23:51:03 +01:00
urlRulesEbox = mkebox ( site , uw _sites [ site ] . urlRules [ 0 ] , "url_rules" ) ;
2017-03-02 20:06:53 +01:00
urlRules . append ( urlRulesLabel ) ;
urlRules . append ( urlRulesEbox ) ;
}
var playerElement = document . createElement ( "div" ) ;
{
var playerName = document . createElement ( "div" ) ;
var playerNameLabel = document . createElement ( "span" ) ;
playerNameLabel . textContent = "id of the player container:" ;
2017-03-14 23:51:03 +01:00
var playerNameEbox = mkebox ( site , uw _sites [ site ] . player . name , "player_name" ) ;
2017-03-02 20:06:53 +01:00
playerName . append ( playerNameLabel ) ;
playerName . append ( playerNameEbox ) ;
var playerClass = document . createElement ( "div" ) ;
var pcb = document . createElement ( "input" ) ;
2017-03-13 20:34:59 +01:00
pcb . className = site + "_ebox" ;
2017-03-02 20:06:53 +01:00
pcb . type = "checkbox" ;
pcb . name = site + "_pccb_name" ;
pcb . id = site + "_pccb_id" ;
pcb . checked = uw _sites [ site ] . player . isClass ;
pcb . disabled = true ;
var pcblabel = document . createElement ( "span" ) ;
pcblabel . textContent = " Name of the player container is a class" ;
playerClass . append ( pcb ) ;
playerClass . append ( pcblabel ) ;
playerElement . append ( playerName ) ;
playerElement . append ( playerClass ) ;
}
var iframe _playerName = document . createElement ( "div" ) ;
var ipn _label = document . createElement ( "span" ) ;
ipn _label . textContent = "id of the player container when in an iframe:" ;
2017-03-14 23:51:03 +01:00
ipn _ebox = mkebox ( site , uw _sites [ site ] . iframe ? uw _sites [ site ] . iframe . name : "" , "iframe_name" ) ;
2017-03-02 20:06:53 +01:00
iframe _playerName . append ( ipn _label ) ;
iframe _playerName . append ( ipn _ebox ) ;
var iframe _playerClass = document . createElement ( "div" ) ;
var ipc _label = document . createElement ( "span" ) ;
ipc _label . textContent = " Name of the player container is a class" ;
2017-03-14 23:51:03 +01:00
var ipc _cb = mkcb ( site , uw _sites [ site ] . iframe ? uw _sites [ site ] . iframe . isClass : false , "iframe_class" ) ;
2017-03-02 20:06:53 +01:00
iframe _playerClass . append ( ipc _cb ) ;
iframe _playerClass . append ( ipc _label ) ;
var imdbar = document . createElement ( "div" ) ;
2017-03-14 23:51:03 +01:00
var imdbar _cb = mkcb ( site , uw _sites [ site ] . autoar _imdb , "imdbar" ) ;
2017-03-02 20:06:53 +01:00
var imdbar _label = document . createElement ( "span" ) ;
imdbar _label . textContent = " This site supports automatic aspect ratio detection" ;
imdbar . append ( imdbar _cb ) ;
imdbar . append ( imdbar _label ) ;
var imdbar _title = document . createElement ( "div" ) ;
var it _label = document . createElement ( "span" ) ;
it _label . textContent = "id of the element containing video title:" ;
2017-03-14 23:51:03 +01:00
it _ebox = mkebox ( site , uw _sites [ site ] . iframe ? uw _sites [ site ] . iframe . name : "" , "imdbar_title" ) ;
2017-03-02 20:06:53 +01:00
imdbar _title . append ( it _label ) ;
imdbar _title . append ( it _ebox ) ;
var imdbar _class = document . createElement ( "div" ) ;
var ic _label = document . createElement ( "span" ) ;
ic _label . textContent = " Name of the title container is a class" ;
2017-03-14 23:51:03 +01:00
var ic _cb = mkcb ( site , uw _sites [ site ] . iframe ? uw _sites [ site ] . iframe . isClass : false , "imdbar_class" ) ;
2017-03-02 20:06:53 +01:00
imdbar _class . append ( ic _cb ) ;
imdbar _class . append ( ic _label ) ;
2017-03-14 23:51:03 +01:00
siteDetails . append ( urlRules ) ;
siteDetails . append ( playerElement ) ;
siteDetails . append ( iframe _playerName ) ;
siteDetails . append ( iframe _playerClass ) ;
2017-03-02 20:06:53 +01:00
2017-03-14 23:51:03 +01:00
siteDetails . append ( imdbar ) ;
siteDetails . append ( imdbar _title ) ;
siteDetails . append ( imdbar _class ) ;
displayedInfo . append ( siteTitle ) ;
displayedInfo . append ( siteDetails ) ;
2017-03-02 20:06:53 +01:00
entry . append ( displayedInfo ) ;
list . append ( entry ) ;
category _counter ++ ;
}
}
if ( ! category _counter ) {
var noEntriesMsg = document . createElement ( "div" ) ;
noEntriesMsg . textContent = "There's no entries in this category yet" ;
noEntriesMsg . classList = "red" ;
list . append ( noEntriesMsg ) ;
}
2017-03-13 20:34:59 +01:00
if ( site == "dummy" ) {
enableEditing ( "dummy" ) ;
}
2017-03-02 20:06:53 +01:00
}
}
2017-03-14 23:51:03 +01:00
function mkebox ( site , value , id ) {
2017-03-02 20:06:53 +01:00
var ebox = document . createElement ( "input" ) ;
ebox . className = "site_details details_ebox " + site + "_ebox" ,
2017-03-14 23:51:03 +01:00
ebox . id = site + "_" + id + "_ebox" ;
2017-03-02 20:06:53 +01:00
ebox . type = "text" ;
ebox . value = value ;
ebox . disabled = true ;
return ebox ;
}
2017-03-14 23:51:03 +01:00
function mkcb ( site , checked , id , forceEnable ) {
2017-03-02 20:06:53 +01:00
var cb = document . createElement ( "input" ) ;
2017-03-13 20:34:59 +01:00
cb . className = site + "_ebox" ,
2017-03-02 20:06:53 +01:00
cb . type = "checkbox" ;
cb . name = site + "_cb_name" ;
2017-03-14 23:51:03 +01:00
cb . id = site + "_" + id + "_cb" ;
2017-03-02 20:06:53 +01:00
cb . checked = checked ;
if ( ! forceEnable )
cb . disabled = true ;
return cb ;
}
2017-03-13 20:34:59 +01:00
function enableEditing ( site ) {
2017-03-14 23:51:03 +01:00
showSiteDetails ( site ) ;
2017-03-13 20:34:59 +01:00
if ( debugmsg )
console . log ( "uw settings :: enableEditing | enabling editing for" , site ) ;
var formElements = document . getElementsByClassName ( site + "_ebox" ) ;
if ( ! formElements )
return ;
if ( debugmsg )
console . log ( "form elements: " , formElements ) ;
for ( var i = 0 ; i < formElements . length ; i ++ ) {
formElements [ i ] . disabled = false ;
}
var editButton = document . getElementById ( site + "_edit_button" ) ;
if ( editButton )
editButton . classList . add ( "hide" ) ;
else
return ;
try {
document . getElementById ( site + "_save_button" ) . classList . remove ( "hide" ) ;
document . getElementById ( site + "_cancel_button" ) . classList . remove ( "hide" ) ;
} catch ( e ) { } ;
}
function disableEditing ( site ) {
var formElements = document . getElementsByClassName ( site + "_ebox" ) ;
if ( ! formElements )
return ;
for ( var i = 0 ; i < formElements . length ; i ++ ) {
formElements [ i ] . disabled = true ;
}
var editButton = document . getElementById ( site + "_edit_button" ) ;
if ( editButton )
editButton . classList . remove ( "hide" ) ;
else
return ;
try {
document . getElementById ( site + "_save_button" ) . classList . add ( "hide" ) ;
document . getElementById ( site + "_cancel_button" ) . classList . add ( "hide" ) ;
} catch ( e ) { } ;
}
2017-03-14 23:51:03 +01:00
function showSiteDetails ( site ) {
try {
document . getElementById ( site + "_conf_details" ) . classList . remove ( "hide" ) ;
} catch ( me _outside _how _about _that ) { }
}
function hideSiteDetails ( site ) {
try {
document . getElementById ( site + "_conf_details" ) . classList . add ( "hide" ) ;
} catch ( me _outside _how _about _that ) { }
}
function getSiteOpts ( site ) {
var newOptions = { } ;
newOptions . urlRules = [ document . getElementById ( site + "_url_rules_ebox" ) . value ] ;
newOptions . player = { } ;
newOptions . player . name = document . getElementById ( site + "_player_name_ebox" ) . value ;
newOptions . player . isClass = document . getElementById ( site + "_pccb_id" ) . checked ;
newOptions . iframe = { } ;
newOptions . iframe . name = document . getElementById ( site + "_iframe_name_ebox" ) . value ;
newOptions . iframe . isClass = document . getElementById ( site + "_iframe_class_cb" ) . checked ;
newOptions . autoar _imdb = { } ;
newOptions . autoar _imdb . enabled = document . getElementById ( site + "_imdbar_cb" ) . value ;
newOptions . autoar _imdb . title = document . getElementById ( site + "_imdbar_title_ebox" ) . value ;
newOptions . autoar _imdb . isClass = document . getElementById ( site + "_imdbar_class_cb" ) . checked ;
console . log ( newOptions ) ; //TODO: delete this logline
return newOptions ;
}
function setSiteOpts ( site , opts ) {
document . getElementById ( site + "_url_rules_ebox" ) . value = opts . urlRules [ 0 ] ;
document . getElementById ( site + "_player_name_ebox" ) . value = opts . player . name ;
document . getElementById ( site + "_pccb_id" ) . checked = opts . player . isClass ;
if ( opts . iframe ) {
document . getElementById ( site + "_iframe_name_ebox" ) . value = opts . iframe . name ;
document . getElementById ( site + "_iframe_class_cb" ) . checked = opts . iframe . isClass ;
}
if ( opts . autoar _imdb ) {
document . getElementById ( site + "_imdbar_cb" ) . checked = opts . autoar _imdb . enabled ;
if ( opts . autoar _imdb . enabled ) {
document . getElementById ( site + "_imdbar_title_ebox" ) . value = opts . autoar _imdb . title ;
document . getElementById ( site + "_imdbar_class_cb" ) . value = opts . autoar _imdb . isClass
}
}
}
2016-12-07 23:58:43 +01:00
function loadopts ( ) {
2017-02-22 13:53:40 +01:00
getopt ( "ultrawidify_keybinds" , gotopts ) ;
// getopt("ultrawidify_autoar", gotar)
getopt ( "ultrawidify_ui" , gotui ) ;
2017-03-02 20:06:53 +01:00
getopt ( "ultrawidify_siterules" , gotsites ) ;
// We build ui for 'site options' here
// buildSites();
2017-03-13 20:34:59 +01:00
2016-12-07 23:58:43 +01:00
}
2017-01-19 21:29:54 +01:00
// page init
2016-12-07 23:58:43 +01:00
document . addEventListener ( "DOMContentLoaded" , loadopts ) ;
document . querySelector ( "#tab_shortcuts" ) . addEventListener ( "click" , showShortcuts ) ;
document . querySelector ( "#tab_about" ) . addEventListener ( "click" , showAbout ) ;
2017-01-19 21:29:54 +01:00
document . querySelector ( "#tab_general_settings" ) . addEventListener ( "click" , showGeneralSettings ) ;
2017-03-02 20:06:53 +01:00
document . querySelector ( "#tab_sites" ) . addEventListener ( "click" , showSites ) ;
2016-12-07 23:58:43 +01:00
document . querySelector ( "#kb_save" ) . addEventListener ( "click" , saveopts ) ;
document . querySelector ( "#kb_cancel" ) . addEventListener ( "click" , loadopts ) ;
2017-01-19 21:29:54 +01:00
document . querySelector ( "#enable_autoar" ) . addEventListener ( "click" , saveAutoar ) ;
2017-02-22 13:53:40 +01:00
document . querySelector ( "#enable_ui" ) . addEventListener ( "click" , saveUI ) ;
document . querySelector ( "#enable_ui_compact" ) . addEventListener ( "click" , saveUI ) ;
2017-01-21 18:31:47 +01:00
getopt ( "ultrawidify_autoar" , function ( obj ) { document . querySelector ( "#enable_autoar" ) . checked = obj . ultrawidify _autoar } ) ;