From 421d1881e5633b397689486b9d24a6c8eea95a4c Mon Sep 17 00:00:00 2001 From: Willem Date: Mon, 14 Mar 2016 01:50:47 +0100 Subject: [PATCH] Added unknown resource type error --- README.md | 1 + es5-ff-spa-loader.js | 13 +++++++++---- example/app_server/example.js | 6 +++--- example/app_server/www_static/js/example-app.js | 8 ++++++++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5f7c78a..02f067e 100644 --- a/README.md +++ b/README.md @@ -223,6 +223,7 @@ Add unit tests for any new or changed functionality. Lint and test your code. * Added json accept header on assets resources list. * Added cb errors on assets resources json parse + result obj. * Renamed cssData type to dss for enum easiness. +* Added unknown resource type error. ### 0.1.1 * Moved websql delete timeout to cleanServerlUrl for faster boot. diff --git a/es5-ff-spa-loader.js b/es5-ff-spa-loader.js index e2d470b..5355dba 100644 --- a/es5-ff-spa-loader.js +++ b/es5-ff-spa-loader.js @@ -534,6 +534,9 @@ tag = document.createElement('script'); tag.type = 'text/javascript'; } + if (tag === null) { + return cb('Unknown resource type: '+resource.type); + } tag.appendChild(document.createTextNode(data)); document.getElementsByTagName('head')[0].appendChild(tag); @@ -789,16 +792,18 @@ cacheSetValue('meta','server_resources',resources, function (err) { if (err !== null) { return cb(err); } utilRunStack('loadResources', resources, loadResourceStep , function (err) { - if (err !== null) { return cb(err); } - cleanupCache(resources,false,cb); // only clean when fetched + cached progressBar.done(); + if (err === null) { + cleanupCache(resources,false,cb); // only clean when fetched + cached + } else { + cb(err); + } }); }); } else { utilRunStack('loadResources', resources, loadResourceStep , function (err) { - if (err !== null) { return cb(err); } - cb(); progressBar.done(); + cb(err); // done or error }); } }, true); diff --git a/example/app_server/example.js b/example/app_server/example.js index 7cfe5bf..57b626f 100644 --- a/example/app_server/example.js +++ b/example/app_server/example.js @@ -14,7 +14,7 @@ var clientResourcesWeb = []; var clientResources = { js: [], css: [], - cssData: [] + dss: [] }; var addClientResource = function(clientResource, resourceType) { @@ -59,9 +59,9 @@ var createClientResourceFetchList = function() { var urlCss = clientResources.css[clientResourceIdxCss]; fetchList.push({url:urlCss,type:'css'}); } - for (var clientResourceIdxCssData in clientResources.cssData) { + for (var clientResourceIdxCssData in clientResources.dss) { var urlCssData = clientResources.cssData[clientResourceIdxCssData]; - fetchList.push({url:urlCssData,type:'cssData'}); + fetchList.push({url:urlCssData,type:'dss'}); } return fetchList; }; diff --git a/example/app_server/www_static/js/example-app.js b/example/app_server/www_static/js/example-app.js index b6ba062..7ee69f3 100644 --- a/example/app_server/www_static/js/example-app.js +++ b/example/app_server/www_static/js/example-app.js @@ -4,6 +4,14 @@ document.title = 'FFSpaLoader Example'; var serverUrl = window.FFServerUrl; console.log('FFExample provided serverUrl \"'+serverUrl+'\"'); +// TODO for 0.2.1 +//var tplCache = FFSpaLoader.factory.cache.websql({table: 'angular_tpl'}); +//tplCache.cacheOpen(function(err) { +// tplCache.cacheSetValue('key123','value456',function(err) { +// console.log('FFExample local value cached'); +// }); +//}); + $(document.createElement('div')).attr('id', 'wrapper').appendTo($('body')); $(document.createElement('div')).attr('ng-controller', 'ApplicationController').attr('ng-include', '\''+serverUrl+'/example-ui/thtml/header\'').appendTo($('#wrapper')); $(document.createElement('div')).attr('id', 'page-wrapper').appendTo($('#wrapper'));