function Draft(id, lang) { if (!lang) lang = 'en' this.id = id this.lang = lang } extend(Draft.prototype, { setLang: function(lang) { this.lang = lang }, getForLang: function(lang, what) { return LS.getItem(this.key(what, lang)) || '' }, key: function(what, lang) { if (!lang) lang = null if (lang === null) lang = this.lang return 'draft_'+this.id+'_'+what+'__'+lang }, reset: function(langs) { var types = ['title', 'text']; for (var i = 0; i < types.length; i++) { var what = types[i]; for (var j = 0; j < langs.length; j++) LS.removeItem(this.key(what, langs[i])); } }, get: function(what) { switch (what) { case 'title': return this.getTitle(); case 'text': return this.getText(); case 'keywords': return this.getKeywords() } }, set: function(what, val) { switch (what) { case 'title': return this.setTitle(val); case 'text': return this.setText(val); case 'keywords': return this.setKeywords(val); } }, getTitle: function() { return LS.getItem(this.key('title')) || '' }, getText: function() { return LS.getItem(this.key('text')) || '' }, getKeywords: function() { return LS.getItem(this.key('keywords')) || '' }, setTitle: function(val) { LS.setItem(this.key('title'), val) }, setText: function(val) { LS.setItem(this.key('text'), val) }, setKeywords: function(val) { LS.setItem(this.key('keywords'), val) } });