From 4d07bcc04c514dd36e74ff4060ca3f43f06ac142 Mon Sep 17 00:00:00 2001 From: Chris Gathercole Date: Tue, 10 Jan 2017 15:49:10 +0000 Subject: [PATCH 1/2] tweaked README, data-o-crossword-data can now handle json text as well as a url to a json resource --- README.md | 27 +++++++++++++++++++++++++-- src/js/oCrossword.js | 16 ++++++++++++---- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d619496..c6c7fa9 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,35 @@ # o-crossword -# Features it could do with: +An experimental Origami component to implement a responsive crossword. + +## To build this locally + +* set up the Origami [Manual build process](http://origami.ft.com/docs/developer-guide/modules/building-modules/) + * checkout clone of o-crossword repo + * cd to repo code + * check node and ruby are installed + * $ `npm install -g gulp` + * $ `npm install -g origami-build-tools` + * $ `obt build` +* deploy locally as described in the [Origami build tools doc](https://github.com/Financial-Times/origami-build-tools#developing-modules-locally) + * $ `obt demo --runServer --watch` + * $ see a demo of it running at http://0.0.0.0:8080/demos/local/basic.html +* [Bower linking a component](https://oncletom.io/2013/live-development-bower-component/) +* general Origami [Developer Guide](http://origami.ft.com/docs/developer-guide/) + +## main code + +* src/js/oCrossword.js + +# Old notes + +## Features it could do with: * Toggle for changing side of preview bar * Note pad for * Touch/scroll functionality did not work on iPhone -# Testing Script +## Testing Script NB: The preview bar refers to the green and blue clues thumbnail on small screen. diff --git a/src/js/oCrossword.js b/src/js/oCrossword.js index e102c4e..7984a63 100644 --- a/src/js/oCrossword.js +++ b/src/js/oCrossword.js @@ -126,10 +126,18 @@ function OCrossword(rootEl) { if (this.rootEl !== undefined) { if (this.rootEl.dataset.oCrosswordData) { - return fetch(this.rootEl.dataset.oCrosswordData) - .then(res => res.json()) - .then(json => buildGrid(rootEl, json)) - .then(() => this.assemble()); + if (this.rootEl.dataset.oCrosswordData.startsWith('http')) { + return fetch(this.rootEl.dataset.oCrosswordData) + .then(res => res.json()) + .then(json => buildGrid(rootEl, json)) + .then(() => this.assemble()); + } else { // assume this is json text + return new Promise(() => { + let json = JSON.parse(this.rootEl.dataset.oCrosswordData); + buildGrid(rootEl, json); + }) + .then(() => this.assemble()); + } } else { this.assemble(); } From 7aa1c709ee3a2b77762e114b7b9c7876b1ec6160 Mon Sep 17 00:00:00 2001 From: Chris Gathercole Date: Tue, 10 Jan 2017 15:55:10 +0000 Subject: [PATCH 2/2] bumped minor version to signify new functionlity --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2820eb8..ced3527 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "o-crossword", - "version": "0.2.6", + "version": "0.3.0", "description": "FT-branded crosswords", "devDependencies": { "babel-loader": "^5.3.2",