display version, date and sizes

This commit is contained in:
rolux 2012-06-17 13:10:29 +02:00
parent a8ba135bf3
commit 123f81183e
2 changed files with 32 additions and 13 deletions

View file

@ -40,6 +40,7 @@ Ox.load(function() {
});
},
data: {
downloads: {},
html: {},
pages: [
{id: 'about', title: 'About'},
@ -218,7 +219,8 @@ Ox.load(function() {
app.state.loaded = true;
},
loadData: function(callback) {
var url = 'https://oxjs.org/dev/Ox/json/Ox.json';
var url = 'https://oxjs.org/downloads/downloads.json';
url = 'downloads/downloads.json'
Ox.getJSON('index.json?' + Ox.random(1000000), function(data) {
app.data = Ox.extend(app.data, data);
app.data.pages.forEach(function(page) {
@ -228,7 +230,7 @@ Ox.load(function() {
if (Ox.len(app.html) == app.data.pages.length) {
if (navigator.onLine) {
Ox.getJSON(url, function(data) {
app.data.version = data.version;
app.data.downloads = data;
callback();
});
} else {
@ -295,15 +297,29 @@ Ox.load(function() {
/\b(Ox\.[\w\$]+)/g,
'<a href="#doc/$1" class="OxMonospace doclink">$1</a>'
],
size: [
/\{size\.(\w+)\}/g,
function(match, key) {
return app.data.downloads ? ' (' + Ox.formatValue(
app.data.downloads.size[key], 'B'
) + ')' : '';
}
],
version: [
'{version}',
function() {
var current = 'You\'re currently running version <code>'
+ Ox.VERSION + '</code>.',
latest = 'The latest version is <code>'
+ app.data.version + '</code>.';
return app.data.version ? latest + (
app.data.version == Ox.VERSION ? '' : ' ' + current
var version = app.data.downloads.version,
current = 'You\'re currently running version '
+ Ox.VERSION + '.',
latest = 'The latest version is ' + version + ' ('
+ app.data.downloads.date
.replace('T', ' ')
.replace('Z', ' UTC')
+ ').';
return version ? latest + (
/:\/\/oxjs.org\//.test(window.location.href) ? ''
: version == Ox.VERSION ? ' You\'re up to date.'
: ' ' + current
) : current;
}
]
@ -493,9 +509,11 @@ Ox.load(function() {
var $element = Ox.Container();
$('<div>')
.addClass('OxSelectable page')
.html(app.html[page].replace(
app.re.version[0], app.re.version[1]
))
.html(
app.html[page]
.replace(app.re.size[0], app.re.size[1])
.replace(app.re.version[0], app.re.version[1])
)
.appendTo($element);
return $element;
},

View file

@ -8,12 +8,13 @@
$ bzr branch http://code.0x2620.org/oxjs
$ tools/build/build.py</pre>
</p>
<p>Or download &nbsp;<a href="https://oxjs.org/downloads/OxJS.latest.build.tar.gz"><code>OxJS.latest.source.tar.gz</code></a></p>
<p>Or download &nbsp;<a href="https://oxjs.org/downloads/OxJS.latest.build.tar.gz"><code>OxJS.latest.source.tar.gz</code></a>{size.source}.</p>
<p>Start with &nbsp;<code>OxJS/index.html</code>. It's this website.</p>
<br>
<h2><b>Build</b></h2>
<p>Minified production version.</p>
<p>Download &nbsp;<a href="https://oxjs.org/downloads/OxJS.latest.build.tar.gz"><code>OxJS.latest.build.tar.gz</code></a>, or get <code>Ox.js</code> only: &nbsp;<a href="https://oxjs.org/oxjs/build/Ox.js"><code>Ox.js</code></a></p>
<p>Download &nbsp;<a href="https://oxjs.org/downloads/OxJS.latest.build.tar.gz"><code>OxJS.latest.build.tar.gz</code></a>{size.build}.</p>
<p>Or get <code>Ox.js</code> only: &nbsp;<a href="https://oxjs.org/oxjs/build/Ox.js"><code>Ox.js</code></a>{size.minified}</p>
<br>
<h2><b>Getting Started</b></h2>
<pre>&lt;!DOCTYPE HTML&gt;