Skip to content

Commit

Permalink
split out config.init()
Browse files Browse the repository at this point in the history
  • Loading branch information
hibiyasleep committed Aug 21, 2017
1 parent 90f0801 commit f20247d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions share/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,15 +509,14 @@ const COLUMN_INDEX = {
o = null
}

if(!o) { // anyway, it's empty, let's populate localStorage
localStorage.setItem('kagerou_config', JSON.stringify(localConfig))
this.config = localConfig
if(!o) {
this.init()
} else {
this.config = {}

for(let k in localConfig) {
if(CONFIG_KEY_SHOULD_OVERRIDE.indexOf(k) != -1) {
if(k == 'tabs' && o[k].length == 0) {
if(CONFIG_KEY_SHOULD_OVERRIDE.indexOf(k) !== -1) {
if(k === 'tabs' && o[k].length === 0) {
this.config[k] = localConfig[k]
} else {
this.config[k] = o[k]
Expand All @@ -533,6 +532,16 @@ const COLUMN_INDEX = {
return this.config
}

init() {
let localConfig = copy(CONFIG_DEFAULT)
this.config = localConfig
let lang = (navigator.language || '').split('-')[0]
if(['ko', 'en', 'ja', 'de'].indexOf(lang) !== -1){
this.set('lang', lang)
}
this.save()
}

loadStyle(path, section) {
let variables = copy(this.config.style)

Expand Down

0 comments on commit f20247d

Please sign in to comment.