diff --git a/example/buttons.html b/example/buttons.html index a8cdaacd28..c06904a18a 100644 --- a/example/buttons.html +++ b/example/buttons.html @@ -2,6 +2,7 @@ + Buttons diff --git a/example/grid.html b/example/grid.html index e69de29bb2..3717ff9e9c 100644 --- a/example/grid.html +++ b/example/grid.html @@ -0,0 +1,45 @@ + + + + + Grid + + + + +
+ + Previous + +

Willkommen!

+
+ + +
+

+ Grid +

+

+ List View +

+

+ Home +

+
+ + + + + + + + + + + + + + + diff --git a/example/listview.html b/example/listview.html index e69de29bb2..a204ea45fd 100644 --- a/example/listview.html +++ b/example/listview.html @@ -0,0 +1,45 @@ + + + + + Listview + + + + +
+ + Previous + +

Willkommen!

+
+ + +
+

+ Grid +

+

+ List View +

+

+ Home +

+
+ + + + + + + + + + + + + + + diff --git a/js/framework/framework-navigation.js b/js/framework/framework-navigation.js index 98314e1586..739b6af2ae 100644 --- a/js/framework/framework-navigation.js +++ b/js/framework/framework-navigation.js @@ -79,23 +79,65 @@ xhr.onreadystatechange = function() { if (xhr.readyState === 4) { if(xhr.status === 200) { - successRequest(xhr, options); + successPageLoad(xhr, options); } else { - failedRequest(options.url); + failedPageLoad(options.url); } } }; xhr.send(); } - function successRequest(xhr, options) { + function successPageLoad(xhr, options) { + var data = parseXHR(xhr, options); framework.isRequesting = false; } - function failedRequest(options) { + function failedPageLoad(options) { + framework.trigger("pageloadfailed"); framework.isRequesting = false; } + function parseXHR(xhr, options) { + var + container, + tmp, + data = {}; + + data.url = options.url; + + if (!xhr.responseText) return data; + + container = document.createElement('div'); + container.innerHTML = xhr.responseText; + + tmp = container.querySelector("title"); + if(tmp) { + data.title = tmp.innerText; + } else { + tmp = container.querySelector("h1"); + if(tmp) { + data.title = tmp.innerText; + } else { + data.title = data.url; + } + } + + tmp = container.querySelector("main"); + if(tmp) { + data.main = tmp.innerHTML; + } else { + tmp = container.querySelector("body"); + if(tmp) { + data.main = tmp.innerHTML; + } else { + data.main = container.innerHTML; + } + } + + return data; + } + framework.on("ready", function(){ // DOM is ready framework.addLinkListeners();