mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-15 20:35:23 +03:00
Chrome Apps don't get window.localStorage
This commit is contained in:
parent
a156ebd31e
commit
9fa5cca011
3 changed files with 43 additions and 18 deletions
|
@ -59,8 +59,27 @@ var GUI_control = function () {
|
|||
else if (navigator.appVersion.indexOf("Linux") != -1) this.operating_system = "Linux";
|
||||
else if (navigator.appVersion.indexOf("X11") != -1) this.operating_system = "UNIX";
|
||||
else this.operating_system = "Unknown";
|
||||
|
||||
// Check the method of execution
|
||||
this.nwGui = null;
|
||||
try {
|
||||
this.nwGui = require('nw.gui');
|
||||
this.Mode = GUI_Modes.NWJS;
|
||||
} catch (ex) {
|
||||
if (window.chrome && chrome.storage && chrome.storage.local) {
|
||||
this.Mode = GUI_Modes.ChromeApp;
|
||||
} else {
|
||||
this.Mode = GUI_Modes.Other;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const GUI_Modes = {
|
||||
NWJS: "NW.js",
|
||||
ChromeApp: "Chrome",
|
||||
Other: "Other"
|
||||
}
|
||||
|
||||
// Timer managing methods
|
||||
|
||||
// name = string
|
||||
|
@ -358,5 +377,16 @@ GUI_control.prototype.selectDefaultTabWhenConnected = function() {
|
|||
});
|
||||
};
|
||||
|
||||
GUI_control.prototype.isChromeApp = function () {
|
||||
return this.Mode == GUI_Modes.ChromeApp;
|
||||
}
|
||||
GUI_control.prototype.isNWJS = function () {
|
||||
return this.Mode == GUI_Modes.NWJS;
|
||||
}
|
||||
GUI_control.prototype.isOther = function () {
|
||||
return this.Mode == GUI_Modes.Other;
|
||||
}
|
||||
|
||||
|
||||
// initialize object into GUI variable
|
||||
var GUI = new GUI_control();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue