use localStorage without new global

This commit is contained in:
j 2016-02-29 14:46:59 +05:30
parent a3c1081964
commit dddd39aaa6
2 changed files with 7 additions and 8 deletions

View file

@ -300,7 +300,7 @@ function loadVideo(videoFile) {
Ox.oshash(videoFile, function(hash) { Ox.oshash(videoFile, function(hash) {
videoHash = hash; videoHash = hash;
var storageKey = 'txt_' + videoHash; var storageKey = 'txt_' + videoHash;
if (storageKey in storage) { if (storageKey in localStorage) {
loadTxt(); loadTxt();
} }
}); });

View file

@ -1,6 +1,5 @@
var url = "https://speedtrans.pad.ma"; var url = "https://speedtrans.pad.ma";
var storage = window.localStorage;
//elem = string (elementId to make TextArea) //elem = string (elementId to make TextArea)
var TextArea = function(elem) { var TextArea = function(elem) {
@ -381,16 +380,16 @@ User.prototype.init = function() {
User.prototype.set_pref = function(key, val) { User.prototype.set_pref = function(key, val) {
var that = this; var that = this;
storage[key] = val; localStorage[key] = val;
this.callbacks[key](val); this.callbacks[key](val);
} }
User.prototype.get_pref = function(key) { User.prototype.get_pref = function(key) {
var that = this; var that = this;
if (typeof storage[key] === 'undefined') { if (typeof localStorage[key] === 'undefined') {
storage[key] = that.defaults[key]; localStorage[key] = that.defaults[key];
} }
return storage[key]; return localStorage[key];
} }
User.prototype.set_prefs = function(keyvals) { User.prototype.set_prefs = function(keyvals) {
@ -412,12 +411,12 @@ User.prototype.get_prefs = function(keys) {
User.prototype.set_txt = function(filename, txt) { User.prototype.set_txt = function(filename, txt) {
var that = this; var that = this;
storage['txt_' + filename] = txt; localStorage['txt_' + filename] = txt;
} }
User.prototype.get_txt = function(filename) { User.prototype.get_txt = function(filename) {
var that = this; var that = this;
return storage['txt_' + filename]; return localStorage['txt_' + filename];
} }
function loadCuts(url, id) { function loadCuts(url, id) {