pandotdoslashra/js/pandora.js

257 lines
14 KiB
JavaScript
Raw Normal View History

2012-06-19 20:59:40 +00:00
Ox.getJSON('json/pandora.json?' + +new Date(), function(pandora) {
2012-04-21 11:44:51 +00:00
2012-04-18 09:33:42 +00:00
$(function() {
var $body = $('body'),
2012-04-19 18:50:58 +00:00
$icon = $('#icon'),
2012-04-18 09:33:42 +00:00
$menu = $('<div>').attr({id: 'menu'}).appendTo($body),
$page = $('<div>').attr({id: 'page'}).appendTo($body),
2024-01-07 16:04:00 +00:00
$head = $('<h1>').appendTo($page);
2012-04-18 09:33:42 +00:00
$text = $('<div>').appendTo($page);
$prevButton = $('<span>')
.addClass('button')
.attr({id: 'prevButton', title: 'previous'})
.html('&lt;='),
$nextButton = $('<span>')
.addClass('button')
.attr({id: 'nextButton', title: 'next'})
.html('=&gt;'),
tourIndex = 0;
Ox.forEach(pandora.pages, function(data, page) {
var $element, text;
if (page == 'home') {
2012-04-18 09:33:42 +00:00
$element = $('<img>')
.attr({id: 'icon', src: 'png/icon256.png'})
.appendTo($body);
} else {
$element = $('<div>')
2012-04-21 11:44:51 +00:00
.addClass(page)
2012-04-18 09:33:42 +00:00
.html(page)
.appendTo($menu);
}
$element.bind({
click: function() {
window.location.hash = page == 'home' ? '' : page;
2012-04-18 09:33:42 +00:00
}
});
2010-08-03 18:35:31 +00:00
});
2012-04-18 09:33:42 +00:00
window.onhashchange = loadPage;
loadPage();
2017-03-26 18:53:58 +00:00
Ox.get('/ra-head', function(data) {
var hash = window.location.hash.substr(1).split('.'),
page = hash[0],
2014-10-10 17:13:26 +00:00
version = data.split(' ')[0],
2019-07-19 11:50:55 +00:00
torrent = 'magnet:?xt=urn:btih:adfa6c6f8684d4f6db11316ecf83eeeb159619b9&dn=pandora-r6164&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969',
torrentInfo = 'pandora-r6164.torrent, 3.2&nbsp;GiB'
2012-06-20 11:26:08 +00:00
pandora.pages.download = pandora.pages.download.replace(
2014-10-10 17:13:26 +00:00
/{version}/g, ' The latest revision is r' + version + '.'
).replace(/{torrent}/g, torrent).replace(/{torrentInfo}/g, torrentInfo)
page == 'download' && loadPage();
});
2012-04-18 09:33:42 +00:00
function loadPage() {
2012-04-21 11:44:51 +00:00
var hash = window.location.hash.substr(1).split('.'),
page = hash[0] || 'home',
2012-04-21 11:44:51 +00:00
part = parseInt(hash[1], 10) || 1,
2012-04-18 09:33:42 +00:00
text;
if (!pandora.pages[page]) {
window.location.hash = '';
} else {
document.title = 'pan.do/ra - open media archive - ' + page;
$('#icon').add('#menu > div').removeClass('selected');
(page == 'home' ? $('#icon') : $('#menu > .' + page))
.addClass('selected');
2012-04-18 09:33:42 +00:00
if (page == 'news') {
text = pandora.pages.news.map(function(item) {
return '<div class="title">' + item[0] + '</div>'
2012-04-19 18:50:58 +00:00
+ '<div class="date">'
+ Ox.formatDate(Ox.parseDate(item[1]), '%A, %B %e, %Y')
2012-04-19 18:50:58 +00:00
+ '</div>'
2012-04-18 09:33:42 +00:00
+ '<div class="text">' + item[2] + '</div>';
}).join('');
} else if (page == 'faq') {
text = pandora.pages.faq.map(function(item) {
return '<div class="title"><b>' + item[0] + '</b></div>'
+ '<div class="text">' + item[1] + '</div>';
}).join('');
} else if (page == 'tour') {
text = $('<div>')
.append(
2012-04-19 18:50:58 +00:00
$('<div>')
.addClass('tour')
.append(
$('<img>')
.addClass('tour')
.attr({
2012-04-21 11:44:51 +00:00
src: pandora.pages.tour[part - 1][0]
2012-04-19 18:50:58 +00:00
})
)
.bind({
click: function(e) {
var $this = $(this), timeout;
if (!$this.hasClass('zoom')) {
$($this.children()[0]).stop().animate({
width: '1280px',
height: '800px',
marginLeft: Math.round(
(384 - window.scrollX - e.clientX) * 11/9
) + 'px',
marginTop: Math.round(
(113 - window.scrollY - e.clientY) * 11/9
) + 'px'
}, 250, function() {
var event;
$this.addClass('zoom').bind({
mouseenter: function(e) {
timeout && clearTimeout(timeout);
$this.bind({
mousemove: function(e) {
event = e;
}
})
$($this.children()[0]).animate({
width: '1280px',
height: '800px',
marginLeft: Math.round(
(384 - window.scrollX - e.clientX) * 11/9
) + 'px',
marginTop: Math.round(
(113 - window.scrollY - e.clientY) * 11/9
) + 'px'
}, 250, function() {
$($this.children()[0]).animate({
marginLeft: Math.round(
(384 - window.scrollX - (event || e).clientX) * 11/9
) + 'px',
marginTop: Math.round(
(113 - window.scrollY - (event || e).clientY) * 11/9
) + 'px'
}, 250, function() {
$this.unbind('mousemove').bind({
mousemove: function(e) {
$($this.children()[0]).stop().css({
width: '1280px',
height: '800px',
marginLeft: Math.round(
(384 - window.scrollX - e.clientX) * 11/9
) + 'px',
marginTop: Math.round(
(113 - window.scrollY - e.clientY) * 11/9
) + 'px'
});
}
});
});
});
},
mousemove: function(e) {
$($this.children()[0]).stop().css({
width: '1280px',
height: '800px',
marginLeft: Math.round(
(384 - window.scrollX - e.clientX) * 11/9
) + 'px',
marginTop: Math.round(
(113 - window.scrollY - e.clientY) * 11/9
) + 'px'
});
},
mouseleave: function() {
timeout = setTimeout(function() {
$($this.children()[0]).stop().animate({
width: '576px',
height: '360px',
marginLeft: 0,
marginTop: 0
}, 250, function() {
$this.unbind('mousemove');
});
timeout = 0;
}, 500);
}
});
});
} else {
$this.unbind('mouseenter').unbind('mousemove').unbind('mouseleave');
$($this.children()[0]).stop().animate({
width: '576px',
height: '360px',
marginLeft: 0,
marginTop: 0
}, 250, function() {
$this.removeClass('zoom');
});
}
}
})
2012-04-18 09:33:42 +00:00
)
.append(
2012-04-21 11:44:51 +00:00
$('<p>').html(pandora.pages.tour[part - 1][1])
2012-04-18 09:33:42 +00:00
);
2010-08-03 18:35:31 +00:00
} else {
text = pandora.pages[page].replace('{version}', '');
2010-08-03 18:35:31 +00:00
}
2012-04-18 09:33:42 +00:00
$head.empty().append(
page == 'home' ? 'pan.do/ra &mdash; open media archive'
2012-04-18 09:33:42 +00:00
: page == 'tour' ? $('<span>')
2012-04-21 11:44:51 +00:00
.addClass('button' + (page == 1 ? 'disabled' : ''))
2012-04-18 09:33:42 +00:00
.attr({title: 'first'})
.html('tour')
.click(function() {
2012-04-21 11:44:51 +00:00
window.location.hash = 'tour';
2012-04-18 09:33:42 +00:00
})
: page
);
2012-04-19 18:50:58 +00:00
$text.empty().append(text);
2024-01-07 16:04:00 +00:00
if (page == 'tour') {
2012-04-21 11:44:51 +00:00
$prevButton[
part == 1 ? 'addClass' : 'removeClass'
]('disabled')
2012-04-18 09:33:42 +00:00
.click(function() {
2012-04-21 11:44:51 +00:00
window.location.hash = 'tour.' + (part - 1);
2012-04-18 09:33:42 +00:00
})
.appendTo($head);
2012-04-21 11:44:51 +00:00
$nextButton[
part == pandora.pages.tour.length
? 'addClass' : 'removeClass'
]('disabled')
2012-04-18 09:33:42 +00:00
.click(function() {
2012-04-21 11:44:51 +00:00
window.location.hash = 'tour.' + (part + 1);
2012-04-18 09:33:42 +00:00
})
.appendTo($head);
2010-08-03 18:35:31 +00:00
}
2012-04-18 09:33:42 +00:00
}
}
function loadTour(delta) {
tourIndex = delta == 0 ? 0
: Ox.mod(tourIndex + delta, pandora.pages.tour.length);
$('.button').removeClass('disabled');
if (tourIndex == 0) {
$prevButton.addClass('disabled');
} else if (tourIndex == pandora.pages.tour.length - 1) {
$nextButton.addClass('disabled');
2010-08-03 18:35:31 +00:00
}
2012-04-18 09:33:42 +00:00
var $img = $text.find('img'),
$p = $text.find('p'),
src = pandora.pages.tour[tourIndex][0]
$('<img>')
.load(function() {
$img.css({opacity: 1}).attr({src: src});
$p.css({opacity: 1}).html(pandora.pages.tour[tourIndex][1]);
})
.attr({
src: src
});
$img.css({opacity: 0.25});
$p.css({opacity: 0.25});
2012-04-19 18:50:58 +00:00
}
2012-04-18 09:33:42 +00:00
});
2012-04-21 11:44:51 +00:00
2010-08-03 18:35:31 +00:00
});