Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
|
|
@ -0,0 +1,8 @@
|
|||
;'use strict';(function(exports){var UserDictionary=function UserDictionary(){this._wordSet=null;this._saveQueue=null;this._dbStore=null;this._started=false;};UserDictionary.prototype.start=function(){if(this._started){console.error('UserDictionary: attempting to start twice');return;}
|
||||
this._started=true;this._saveQueue=Promise.resolve();this._dbStore=new PromiseStorage(this.DB_NAME);this._dbStore.start();};UserDictionary.prototype.stop=function(){if(this._started){this._wordSet=null;this._saveQueue=null;this._dbStore.stop();}};UserDictionary.prototype.DB_NAME='UserDictLatin';UserDictionary.prototype.getList=function(){if(!this._started){return Promise.reject('UserDictionary not started');}
|
||||
return this._dbStore.getItem('wordlist').then(list=>{list=list||[];this._wordSet=new Set(list);return this._wordSet;}).catch(e=>{e&&console.error(e);this._wordSet=new Set([]);return this._wordSet;});};UserDictionary.prototype._saveDict=function(){var wordList=Array.from(this._wordSet);wordList=wordList.sort((a,b)=>a.toLocaleLowerCase().localeCompare(b.toLocaleLowerCase()));this._wordSet=new Set(wordList);var dictBlob=0===wordList.length?undefined:new WordListConverter(wordList).toBlob();var p=this._saveQueue.then(()=>{this._dbStore.setItems({'wordlist':wordList,'dictblob':dictBlob});return wordList;});this._saveQueue=p;this._saveQueue=this._saveQueue.catch(e=>{console.error(e);});return p;};UserDictionary.prototype.addWord=function(word){if(!this._started){return Promise.reject('UserDictionary not started');}
|
||||
word=word.trim();if(this._wordSet.has(word)){return Promise.reject('existing');}
|
||||
this._wordSet.add(word);return this._saveDict();};UserDictionary.prototype.updateWord=function(oldWord,word){if(!this._started){return Promise.reject('UserDictionary not started');}
|
||||
word=word.trim();if(oldWord===word){return Promise.resolve(Array.from(this._wordSet));}
|
||||
this._wordSet.delete(oldWord);if(this._wordSet.has(word)){return this._saveDict().then(()=>Promise.reject('existing'));}else{this._wordSet.add(word);return this._saveDict();}};UserDictionary.prototype.removeWord=function(word){if(!this._started){return Promise.reject('UserDictionary not started');}
|
||||
this._wordSet.delete(word);return this._saveDict();};UserDictionary.prototype._getBlob=function(){return this._dbStore.getItem('dictblob');};exports.UserDictionary=UserDictionary;})(window);
|
||||
Loading…
Reference in a new issue