/
strings.js
42 lines (37 loc) · 1.16 KB
/
strings.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* Modified from "Building iPhone Apps with HTML, CSS, and Javascript" by Jonathan Stark */
var hist = [];
var startUrl = "data/contents.html";
$(document).ready(function(){
if(navigator.userAgent.toLowerCase().indexOf('iphone') != -1 ||
navigator.userAgent.toLowerCase().indexOf('android') != -1) {
$('a#refresh').click(function() {
window.applicationCache.update();
});
loadPage(startUrl);
} else {
loadPage("badbrowser.html")
}
});
function loadPage(url) {
scrollTo(0,0);
$('#container').load(url + ' #content', function(){
var title = $('h2').html() || 'Strings to Go';
$('h1').html(title);
$('h2').remove();
$('.leftButton').remove();
hist.unshift({'url':url, 'title':title});
if(hist.length > 1) {
$('#header').append('<div class="leftButton">' + hist[1].title + "</div>");
$('#header .leftButton').click(function(e){
$(e.target).addClass('clicked');
var thisPage = hist.shift();
var previousPage = hist.shift();
loadPage(previousPage.url);
});
}
$('#container a').click(function(e){
e.preventDefault();
loadPage(e.target.href);
});
});
}