-
-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix on getSettings/localStorage for Chrome OS version
- Loading branch information
llaske
committed
Jan 5, 2017
1 parent
471a286
commit 3fa165a
Showing
15 changed files
with
841 additions
and
841 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,33 @@ | ||
var l10n_s; | ||
|
||
requirejs.config({ | ||
baseUrl: "lib", | ||
paths: { | ||
activity: "../js" | ||
} | ||
baseUrl: "lib", | ||
paths: { | ||
activity: "../js" | ||
} | ||
}); | ||
|
||
requirejs(["activity/activity"]); | ||
|
||
requirejs(["webL10n","sugar-web/env"], function(l10n, env) { | ||
l10n_s = l10n; //global declaration of translate interface | ||
requirejs(["webL10n","sugar-web/env","sugar-web/datastore"], function(l10n, env ,datastore) { | ||
l10n_s = l10n; //global declaration of translate interface | ||
|
||
getSettings(function(settings) { //globally setting language from sugar settings | ||
datastore.localStorage.load(function() { | ||
getSettings(function(settings) { //globally setting language from sugar settings | ||
l10n_s.language.code = settings.language; | ||
}); | ||
}); | ||
|
||
function getSettings(callback) { | ||
var defaultSettings = { | ||
name: "", | ||
language: navigator.language | ||
language: (typeof chrome != 'undefined' && chrome.app && chrome.app.runtime) ? chrome.i18n.getUILanguage() : navigator.language | ||
}; | ||
if (!env.isSugarizer()) { | ||
callback(defaultSettings); | ||
return; | ||
} | ||
if (typeof chrome != 'undefined' && chrome.app && chrome.app.runtime) { | ||
var loadedSettings = JSON.parse(values.sugar_settings); | ||
chrome.storage.local.get('sugar_settings', function(values) { | ||
callback(loadedSettings); | ||
}); | ||
} else { | ||
var loadedSettings = JSON.parse(localStorage.sugar_settings); | ||
callback(loadedSettings); | ||
} | ||
loadedSettings = datastore.localStorage.getValue('sugar_settings'); | ||
callback(loadedSettings); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,34 @@ | ||
var l10n_s; | ||
|
||
requirejs.config({ | ||
baseUrl: "lib", | ||
paths: { | ||
activity: "../js" | ||
} | ||
baseUrl: "lib", | ||
paths: { | ||
activity: "../js" | ||
} | ||
}); | ||
|
||
requirejs(["activity/activity"]); | ||
|
||
requirejs(["webL10n","sugar-web/env","moment-with-locales.min"], function(l10n, env, moment) { | ||
l10n_s = l10n; //global declaration of translate interface | ||
requirejs(["webL10n","sugar-web/env","moment-with-locales.min","sugar-web/datastore"], function(l10n, env, moment,datastore) { | ||
l10n_s = l10n; //global declaration of translate interface | ||
|
||
getSettings(function(settings) { //globally setting language from sugar settings | ||
datastore.localStorage.load(function() { | ||
getSettings(function(settings) { //globally setting language from sugar settings | ||
l10n_s.language.code = settings.language; | ||
moment.locale(settings.language); | ||
}); | ||
}); | ||
|
||
function getSettings(callback) { | ||
function getSettings(callback) { | ||
var defaultSettings = { | ||
name: "", | ||
language: navigator.language | ||
language: (typeof chrome != 'undefined' && chrome.app && chrome.app.runtime) ? chrome.i18n.getUILanguage() : navigator.language | ||
}; | ||
if (!env.isSugarizer()) { | ||
callback(defaultSettings); | ||
return; | ||
} | ||
if (typeof chrome != 'undefined' && chrome.app && chrome.app.runtime) { | ||
var loadedSettings = JSON.parse(values.sugar_settings); | ||
chrome.storage.local.get('sugar_settings', function(values) { | ||
callback(loadedSettings); | ||
}); | ||
} else { | ||
var loadedSettings = JSON.parse(localStorage.sugar_settings); | ||
callback(loadedSettings); | ||
} | ||
loadedSettings = datastore.localStorage.getValue('sugar_settings'); | ||
callback(loadedSettings); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,34 @@ | ||
var l10n_s; | ||
|
||
requirejs.config({ | ||
baseUrl: "lib", | ||
paths: { | ||
activity: "../js" | ||
} | ||
baseUrl: "lib", | ||
paths: { | ||
activity: "../js" | ||
} | ||
}); | ||
|
||
requirejs(["activity/activity"]); | ||
|
||
requirejs(["webL10n","sugar-web/env","moment-with-locales.min"], function(l10n, env, moment) { | ||
l10n_s = l10n; //global declaration of translate interface | ||
requirejs(["webL10n","sugar-web/env","moment-with-locales.min","sugar-web/datastore"], function(l10n, env, moment,datastore) { | ||
l10n_s = l10n; //global declaration of translate interface | ||
|
||
getSettings(function(settings) { //globally setting language from sugar settings | ||
datastore.localStorage.load(function() { | ||
getSettings(function(settings) { //globally setting language from sugar settings | ||
l10n_s.language.code = settings.language; | ||
moment.locale(settings.language); | ||
}); | ||
}); | ||
|
||
function getSettings(callback) { | ||
var defaultSettings = { | ||
name: "", | ||
language: navigator.language | ||
language: (typeof chrome != 'undefined' && chrome.app && chrome.app.runtime) ? chrome.i18n.getUILanguage() : navigator.language | ||
}; | ||
if (!env.isSugarizer()) { | ||
callback(defaultSettings); | ||
return; | ||
} | ||
if (typeof chrome != 'undefined' && chrome.app && chrome.app.runtime) { | ||
var loadedSettings = JSON.parse(values.sugar_settings); | ||
chrome.storage.local.get('sugar_settings', function(values) { | ||
callback(loadedSettings); | ||
}); | ||
} else { | ||
var loadedSettings = JSON.parse(localStorage.sugar_settings); | ||
callback(loadedSettings); | ||
} | ||
loadedSettings = datastore.localStorage.getValue('sugar_settings'); | ||
callback(loadedSettings); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.