2017-10-02 23:30:40 +02:00
|
|
|
// setopt, getopt, delopt. Shrani oz. dobi oz. briše stvari iz skladišča
|
|
|
|
// setopt, getopt, delopt. They set/get/delete stuff from the storage
|
|
|
|
|
|
|
|
var _sm_setopt = function(item){
|
2017-12-17 22:56:07 +01:00
|
|
|
return browser.storage.local.set(item);
|
2017-10-02 23:30:40 +02:00
|
|
|
}
|
|
|
|
var _sm_getopt = function(prop, callback){
|
|
|
|
if(BrowserDetect.usebrowser == "chrome")
|
2017-12-17 22:56:07 +01:00
|
|
|
return browser.storage.local.get(prop, callback);
|
2017-10-02 23:30:40 +02:00
|
|
|
else
|
2017-12-17 22:56:07 +01:00
|
|
|
return browser.storage.local.get(prop).then(callback);
|
2017-12-29 23:34:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var _sm_getopt_async = async function(prop){
|
|
|
|
if(BrowserDetect.usebrowser == "chrome")
|
|
|
|
return await browser.storage.local.get(prop);
|
|
|
|
else
|
|
|
|
return await browser.storage.local.get(prop);
|
|
|
|
}
|
|
|
|
|
2017-10-02 23:30:40 +02:00
|
|
|
var _sm_delopt = function(item){
|
2017-12-17 22:56:07 +01:00
|
|
|
return browser.storage.local.remove(item);
|
2017-10-02 23:30:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var StorageManager = {
|
2017-10-17 22:17:51 +02:00
|
|
|
setopt: _sm_setopt,
|
|
|
|
getopt: _sm_getopt,
|
2017-12-29 23:34:40 +01:00
|
|
|
delopt: _sm_delopt,
|
|
|
|
getopt_async: _sm_getopt_async
|
2017-10-02 23:30:40 +02:00
|
|
|
}
|