From ec4e9a0daed7f1194a7b2a1ebd7f9510fd13b6a1 Mon Sep 17 00:00:00 2001 From: Willem Date: Fri, 15 Jan 2016 00:59:00 +0100 Subject: [PATCH] Fixed askUrl.urlTransport and updated readme a but --- README.md | 48 +++++++++++++++++++++++++++++++++----------- es5-ff-spa-loader.js | 4 ++-- example/example.js | 2 +- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e46c690..2684b91 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,55 @@ es5-ff-spa-loader ========= -A javascript library providing server defined loading of resouces for a single page application. +A javascript library providing server defined loading of resources for a single page application. ## Installation - Use the es5-ff-spa-loader.js in header as script resource or inline in body. + npm --save install es5-ff-spa-loader (TODO) -## Usage + Then use the es5-ff-spa-loader.js in header as script resource or inline in body. - On index.html +## Usage Mobile - FFSpaLoader.start(...); + Single index.html + + FFSpaLoader.options.debug = true; + FFSpaLoader.options.server.url = 'http://myserver'; + FFSpaLoader.options.server.urlPath = '/api/path/to/spa/client/resources'; + FFSpaLoader.bootDevice(function() { + FFSpaLoader.options.cache.factory = FFSpaLoader.autoSelectCache();// need deviceready via bootDevice for sqllite. + FFSpaLoader.start(function() { + console.log('FFExample.bootstrap angular'); + angular.bootstrap( $('body'), ['exampleUI']); + }); + }); + + +## Usage Web + + Single index.html + + FFSpaLoader.options.debug = true; + FFSpaLoader.options.server.url = ''; + FFSpaLoader.options.server.urlPath = '/api/path/to/spa/client/resources'; + FFSpaLoader.options.cache.factory = FFSpaLoader.autoSelectCache(); + FFSpaLoader.start(function() { + console.log('FFExample.bootstrap angular'); + angular.bootstrap( $('body'), ['exampleUI']); + }); + +## Usage Multi Server + + Leave out the 'FFSpaLoader.options.server.url' option then the user will be promted to input + the server on first boot. ## Options - * url = The url to fetch resources list from. - * debug = Enable console debug output. - * cachePrefix = The cache key prefix. (default: 'sync-') - * cacheGetFn = example; 'function(key) {return localStorage.getItem(key);}' - * cacheSetFn = example; 'function(key,value) {localStorage.setItem(key,value);}' - * cacheDelFn = example; 'function(key) {return localStorage.removeItem(key);}' + * options.debug = Enable console debug output. ## Example Application There is a fully working express example application in the example folder. - todo ## Contributing diff --git a/es5-ff-spa-loader.js b/es5-ff-spa-loader.js index 4de14d5..a6b5e62 100644 --- a/es5-ff-spa-loader.js +++ b/es5-ff-spa-loader.js @@ -595,10 +595,10 @@ var FFSpaLoader = (/** @lends module:FFSpaLoader */function () { var formTag = document.createElement('div'); rootTag.appendChild(formTag); - if (options.urlTransport !== undefined) { + if (options.askUrl.urlTransport !== undefined) { var transportTag = document.createElement('label'); rootTag.setAttribute('for','serverInput'); - transportTag.appendChild(document.createTextNode(options.urlTransport)); + transportTag.appendChild(document.createTextNode(options.askUrl.urlTransport)); formTag.appendChild(transportTag); } var inputTag = document.createElement('input'); diff --git a/example/example.js b/example/example.js index bda2d0c..1ad0929 100644 --- a/example/example.js +++ b/example/example.js @@ -9,7 +9,7 @@ var cors = require('cors'); var morgan = require('morgan') // example options; -var serverUrl = 'http://10.11.12.216:8080'; +var serverUrl = 'http://localhost:8080'; var useInline = true; // or false var clientResourcesWeb = [];