display latest version

This commit is contained in:
rolux 2012-06-17 11:19:01 +02:00
parent 48b5e9610a
commit e663eb68d8
2 changed files with 28 additions and 13 deletions

View file

@ -46,7 +46,7 @@ Ox.load(function() {
{id: 'readme', title: 'Readme'}, {id: 'readme', title: 'Readme'},
{id: 'examples', title: 'Examples'}, {id: 'examples', title: 'Examples'},
{id: 'doc', title: 'Documentation'}, {id: 'doc', title: 'Documentation'},
{id: 'downloads', title: 'Downloads'}, {id: 'download', title: 'Download'},
{id: 'development', title: 'Development'} {id: 'development', title: 'Development'}
], ],
user: { user: {
@ -218,15 +218,25 @@ Ox.load(function() {
app.state.loaded = true; app.state.loaded = true;
}, },
loadData: function(callback) { loadData: function(callback) {
Ox.getJSON('index.json?'+Ox.random(1000), function(data) { var url = 'https://oxjs.org/dev/Ox/json/Ox.json';
Ox.getJSON('index.json?' + Ox.random(1000000), function(data) {
app.data = Ox.extend(app.data, data); app.data = Ox.extend(app.data, data);
app.data.pages.forEach(function(page) { app.data.pages.forEach(function(page) {
var id = page.id == 'doc' ? 'documentation' : page.id; var id = page.id == 'doc' ? 'documentation' : page.id;
Ox.get('readme/html/_' + (id) + '.html', function(html) { Ox.get('readme/html/_' + (id) + '.html', function(html) {
app.html[id] = html; app.html[id] = html;
Ox.len(app.html) == app.data.pages.length && callback(); if (Ox.len(app.html) == app.data.pages.length) {
if (navigator.onLine) {
Ox.getJSON(url, function(data) {
app.data.version = data.version;
callback();
});
} else {
callback();
}
}
}); });
}) });
}); });
}, },
loadScreen: function(callback) { loadScreen: function(callback) {
@ -288,11 +298,13 @@ Ox.load(function() {
version: [ version: [
'{version}', '{version}',
function() { function() {
return ( var current = 'You\'re currently running version <code>'
/:\/\/oxjs.org\//.test(window.location.href) + Ox.VERSION + '</code>.',
? 'The latest version is' latest = 'The latest version is <code>'
: 'You\'re currently running version' + app.data.version + '</code>.';
) + ' <code>' + Ox.VERSION + '.</code>' return app.data.version ? latest + (
app.data.version == Ox.VERSION ? '' : ' ' + current
) : current;
} }
] ]
}, },
@ -481,7 +493,9 @@ Ox.load(function() {
var $element = Ox.Container(); var $element = Ox.Container();
$('<div>') $('<div>')
.addClass('OxSelectable page') .addClass('OxSelectable page')
.html(app.html[page].replace(app.re.version[0], app.re.version[1])) .html(app.html[page].replace(
app.re.version[0], app.re.version[1]
))
.appendTo($element); .appendTo($element);
return $element; return $element;
}, },
@ -627,7 +641,8 @@ Ox.load(function() {
set: function(data) { set: function(data) {
data = data || app.user; data = data || app.user;
window.location.hash = data.page + ( window.location.hash = data.page + (
data.item && data.item[data.page] ? '/' + data.item[data.page] : '' data.item && data.item[data.page]
? '/' + data.item[data.page] : ''
); );
return app; return app;
} }

View file

@ -1,5 +1,5 @@
<h1><b>Downloads</b></h1> <h1><b>Download</b></h1>
<p>Please note that these are pre-release versions. {version}</p> <p>{version}</p>
<br> <br>
<h2><b>Source</b></h2> <h2><b>Source</b></h2>
<p>Development version, including everything but the kitchen sink.</p> <p>Development version, including everything but the kitchen sink.</p>