diff options
author | zefanja <zefanja@freenet.de> | 2013-07-13 19:37:04 +0200 |
---|---|---|
committer | zefanja <zefanja@freenet.de> | 2013-07-13 19:37:04 +0200 |
commit | dbe994f06deed37c4d8c6741d9c4139a9bbeb8cf (patch) | |
tree | 55268c865c47abd1936ac7ebe068ba9ee3b0de1e | |
parent | f95ccd9d57fb256ff6e10b94b6e8cd320c6648a6 (diff) | |
download | biblez-ng-dbe994f06deed37c4d8c6741d9c4139a9bbeb8cf.tar.gz |
* initial commit
* basic UI
-rw-r--r-- | .gitmodules | 6 | ||||
-rw-r--r-- | assets/biblez128.png | bin | 0 -> 12285 bytes | |||
-rw-r--r-- | assets/biblez256.png | bin | 0 -> 33017 bytes | |||
-rw-r--r-- | assets/biblez32.png | bin | 0 -> 1986 bytes | |||
-rw-r--r-- | assets/biblez48.png | bin | 0 -> 3313 bytes | |||
-rw-r--r-- | assets/biblez512.png | bin | 0 -> 88508 bytes | |||
-rw-r--r-- | assets/biblez64.png | bin | 0 -> 4774 bytes | |||
-rw-r--r-- | assets/modules.png | bin | 0 -> 1471 bytes | |||
-rw-r--r-- | debug.html | 2 | ||||
m--------- | lib/sword | 0 | ||||
-rw-r--r-- | manifest.webapp | 16 | ||||
-rw-r--r-- | source/App.js | 37 | ||||
-rw-r--r-- | source/api.js | 42 | ||||
-rw-r--r-- | source/main.js | 80 | ||||
-rw-r--r-- | source/moduleManager.js | 80 | ||||
-rw-r--r-- | source/package.js | 6 |
16 files changed, 253 insertions, 16 deletions
diff --git a/.gitmodules b/.gitmodules index ce2a034..0d79390 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,9 @@ [submodule "lib/layout"] path = lib/layout url = ../../enyojs/layout.git +[submodule "lib/require"] + path = lib/require + url = https://github.com/jrburke/requirejs.git +[submodule "lib/sword"] + path = lib/sword + url = https://github.com/zefanja/swordjs.git diff --git a/assets/biblez128.png b/assets/biblez128.png Binary files differnew file mode 100644 index 0000000..17ca536 --- /dev/null +++ b/assets/biblez128.png diff --git a/assets/biblez256.png b/assets/biblez256.png Binary files differnew file mode 100644 index 0000000..77d5b11 --- /dev/null +++ b/assets/biblez256.png diff --git a/assets/biblez32.png b/assets/biblez32.png Binary files differnew file mode 100644 index 0000000..1e7eb23 --- /dev/null +++ b/assets/biblez32.png diff --git a/assets/biblez48.png b/assets/biblez48.png Binary files differnew file mode 100644 index 0000000..5360fc8 --- /dev/null +++ b/assets/biblez48.png diff --git a/assets/biblez512.png b/assets/biblez512.png Binary files differnew file mode 100644 index 0000000..640e333 --- /dev/null +++ b/assets/biblez512.png diff --git a/assets/biblez64.png b/assets/biblez64.png Binary files differnew file mode 100644 index 0000000..0e35909 --- /dev/null +++ b/assets/biblez64.png diff --git a/assets/modules.png b/assets/modules.png Binary files differnew file mode 100644 index 0000000..bc5158a --- /dev/null +++ b/assets/modules.png @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> - <title>Enyo Bootplate App</title> + <title>SwordJS Demo</title> <link rel="shortcut icon" href="assets/favicon.ico"/> <!-- --> <meta http-equiv="Content-Type" content="text/html; charset=utf8"/> diff --git a/lib/sword b/lib/sword new file mode 160000 +Subproject 29a46db41bf00150350557d0a24d5a48a2c84dd diff --git a/manifest.webapp b/manifest.webapp new file mode 100644 index 0000000..f705244 --- /dev/null +++ b/manifest.webapp @@ -0,0 +1,16 @@ +{ + "name": "swordJS Demo", + "description": "A demo app to show the status of sword.js", + "launch_path": "/", + "icons": { + "128": "/assets/biblez128.png" + }, + "developer": { + "name": "zefanjas", + "url": "http://zefanjas.de" + }, + "default_locale": "en", + "permissions": { + "systemXHR": {} + } +}
\ No newline at end of file diff --git a/source/App.js b/source/App.js index fa74204..6894c22 100644 --- a/source/App.js +++ b/source/App.js @@ -1,17 +1,26 @@ enyo.kind({ name: "App", - kind: "FittableRows", - fit: true, - components:[ - {kind: "onyx.Toolbar", content: "Hello World"}, - {kind: "enyo.Scroller", fit: true, components: [ - {name: "main", classes: "nice-padding", allowHtml: true} - ]}, - {kind: "onyx.Toolbar", components: [ - {kind: "onyx.Button", content: "Tap me", ontap: "helloWorldTap"} - ]} - ], - helloWorldTap: function(inSender, inEvent) { - this.$.main.addContent("The button was tapped.<br/>"); - } + kind: "Panels", + fit: true, + classes: "app-panels", + arrangerKind: "CardArranger", + draggable: false, + components: [ + {name: "main", kind: "biblez.main", onOpenModuleManager: "openModuleManager"}, + {name: "moduleManager", kind: "biblez.moduleManager", onBack: "handleBack"} + //{name: "settings"} + ], + + rendered: function () { + this.inherited(arguments); + this.setIndex(1); + }, + + handleBack: function (inSender, inEvent) { + this.setIndex(0); + }, + + openModuleManager: function (inSender, inEvent) { + this.setIndex(1); + } }); diff --git a/source/api.js b/source/api.js new file mode 100644 index 0000000..1d465da --- /dev/null +++ b/source/api.js @@ -0,0 +1,42 @@ +var api = { + /* Set the value of item[key] to the stringified version of obj. */ + set: function(name, obj){ + localStorage.setItem(name, JSON.stringify(obj)); + }, + + /* Get the item with the key 'name'. */ + get: function(name){ + var result; + if(typeof name === "string") { + result = localStorage.getItem(name); + } + + if(typeof result === "string"){ + return JSON.parse(result); + } else if(typeof result === "object" && result !== null) { + enyo.log("OBJECT: " + result); + throw "ERROR [Storage.get]: getItem returned an object. Should be a string."; + } else if(typeof result === "undefined" || result === null){ + //throw "ERROR: [Storage.get]: getItem returned a falsey value. Should be a string."; + return result; + } + }, + + /* Remove the item with the key 'name'. */ + remove: function(name){ + if(typeof name === "string") { + localStorage.removeItem(name); + } else { + throw "ERROR [Storage.remove]: 'name' was not a String."; + } + }, + + /* Returns length of all localStorage objects. */ + __getSize: function(){ + var i, count = 0; + for(i = 0; i < localStorage.length; i++){ + count += localStorage.getItem(localStorage.key()).length; + } + return count; + } +};
\ No newline at end of file diff --git a/source/main.js b/source/main.js new file mode 100644 index 0000000..2e4cdb2 --- /dev/null +++ b/source/main.js @@ -0,0 +1,80 @@ +enyo.kind({ + name: "biblez.main", + kind: "FittableRows", + fit: true, + events: { + onOpenModuleManager: "" + }, + components:[ + //{kind: "Signals", onSwordReady: "getBible"}, + {kind: "onyx.MoreToolbar", components: [ + {content: "", name: "bible"}, + {kind: "onyx.InputDecorator", components: [ + {kind: "onyx.Input", placeholder: "Enter a passage...", onchange: "handlePassage"} + ]} + ]}, + {kind: "enyo.Scroller", fit: true, components: [ + {kind: "onyx.Spinner", name: "spinner", classes: "onyx-light"}, + {name: "main", classes: "nice-padding", allowHtml: true} + ]}, + {kind: "onyx.MoreToolbar", components: [ + {kind: "onyx.IconButton", src: "assets/modules.png", ontap: "doOpenModuleManager"} + //{kind: "onyx.Button", content: "Delete all Modules", ontap: "clearDB"}, + //{kind: "onyx.Button", content: "Install ESV", esv: true, ontap: "handleInstallTap"}, + //{kind: "Input", type: "file", onchange: "handleInstallTap"} + ]} + ], + + bible: null, + + create: function () { + this.inherited(arguments); + this.$.spinner.stop(); + this.getBible(); + }, + + + + getBible: function (inSender, inEvent) { + sword.moduleMgr.getModules(enyo.bind(this, function(inError, inModules) { + if(inModules.length !== 0) { + this.bible = inModules[0]; + this.$.bible.setContent(this.bible.config.moduleKey); + } + })); + }, + + handleInstallTap: function (inSender, inEvent) { + this.$.spinner.start(); + self = this; + self.$.main.setContent("Installing Module..."); + var blob = "ESV.zip"; + if (!inSender.esv) + blob = inEvent.target.files[0]; + sword.installMgr.installModule(blob, function (inError, inId) { + //console.log(inError, inId); + if(!inError) + sword.moduleMgr.getModule(inId, function (inError, inModule) { + //console.log(inError, inModule); + self.bible = inModule; + self.$.spinner.stop(); + if(!inError) { + self.$.main.setContent(enyo.json.stringify(inModule.config)); + self.$.bible.setContent(inModule.config.moduleKey); + } + }); + }); + }, + + clearDB: function () { + sword.dataMgr.clearDatabase(); + }, + + handlePassage: function (inSender, inEvent) { + //console.log("PASSAGE", inSender.getValue()); + this.bible.renderText(inSender.getValue(), enyo.bind(this, function (inError, inText) { + //console.log(inError, inText); + this.$.main.setContent(inText); + })); + } +}); diff --git a/source/moduleManager.js b/source/moduleManager.js new file mode 100644 index 0000000..f518dcb --- /dev/null +++ b/source/moduleManager.js @@ -0,0 +1,80 @@ +enyo.kind({ + name: "biblez.moduleManager", + kind: "enyo.FittableRows", + fit: true, + classes: "app-panels", + arrangerKind: "CollapsingArranger", + events: { + onBack: "" + }, + components: [ + {kind: "onyx.MoreToolbar", components: [ + {kind: "onyx.Button", content: $L("<"), ontap: "doBack"}, + {content: $L("Module Manager")}, + {kind: "onyx.PickerDecorator", components: [ + {}, + {name: "repoPicker", kind: "onyx.Picker"} + ]} + ]}, + {name: "panel", kind: "Panels", components: [ + {name: "panelLang", components: [ + {name: "langList", kind: "List", fit: true, onSetupItem: "setupLangItem", components: [ + {classes: "item", ontap: "itemTap", components: [ + {name: "lang"}, + {name: "index", style: "float: right;"} + ]} + ]} + ]}, + {name: "panelModules"}, + {name: "panelDescription"} + ]} + + ], + + lang: [], + repos: [], + modules: [], + + rendered: function () { + this.inherited(arguments); + if (!api.get("lastRepoUpdate")) + this.getRepos(); + else + this.setupRepoPicker(); + }, + + getRepos: function () { + sword.installMgr.getRepositories(enyo.bind(this, function (inError, inRepos) { + console.log(inError, inRepos); + api.set("repos", inRepos); + api.set("lastRepoUpdate", {time: new Date().getTime()}); + this.setupRepoPicker(inRepos); + })); + }, + + setupRepoPicker: function (inRepos) { + if(!inRepos) + inRepos = api.get("repos"); + + var items = []; + inRepos.forEach(function(repo,idx) { + if (repo.name === "CrossWire") items.push({content: repo.name, index: idx, active: true}); + else items.push({content: repo.name, index: idx}); + }); + + this.repos = inRepos; + this.$.repoPicker.createComponents(items, {owner: this}); + this.$.repoPicker.render(); + + + }, + + setupLangItem: function(inSender, inEvent) { + var data = this.lang[inEvent.index]; + //this.$.name.setContent(data.name); + //this.$.index.setContent(inEvent.index); + }, + handleLanguage: function(inSender, inEvent) { + //alert("You tapped on row: " + inEvent.index); + } +});
\ No newline at end of file diff --git a/source/package.js b/source/package.js index 6203d25..33f98ad 100644 --- a/source/package.js +++ b/source/package.js @@ -2,6 +2,10 @@ enyo.depends( "$lib/layout", "$lib/onyx", // To theme Onyx using Theme.less, change this line to $lib/onyx/source, //"Theme.less", // uncomment this line, and follow the steps described in Theme.less - "App.css", + "$lib/sword/sword.min.js", + "App.css", + "api.js", + "main.js", + "moduleManager.js", "App.js" ); |