Skip to content

Commit

Permalink
Merge pull request #2 from ftlabs/localdata
Browse files Browse the repository at this point in the history
tweaked README, data-o-crossword-data can now handle json text
  • Loading branch information
railsagainstignorance authored Jan 10, 2017
2 parents d432fd5 + 7aa1c70 commit 367c93a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
16 changes: 12 additions & 4 deletions src/js/oCrossword.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 367c93a

Please sign in to comment.