cancel requests on hashchange and popstate; handle external urls in info view

This commit is contained in:
rolux 2011-10-07 19:30:02 +00:00
parent 7f3931b123
commit f8d9d032ea
2 changed files with 11 additions and 7 deletions

View file

@ -293,9 +293,11 @@ pandora.URL = (function() {
///* ///*
window.onhashchange = function() { window.onhashchange = function() {
Ox.Request.cancel();
that.parse(); that.parse();
}; };
window.onpopstate = function(e) { window.onpopstate = function(e) {
Ox.Request.cancel();
self.isPopState = true; self.isPopState = true;
if (!Ox.isEmpty(e.state)) { if (!Ox.isEmpty(e.state)) {
Ox.print('E.STATE', e.state) Ox.print('E.STATE', e.state)

View file

@ -343,7 +343,7 @@ pandora.ui.infoView = function(data) {
.css(css) .css(css)
.html( .html(
formatKey(key) + data[key].map(function(value) { formatKey(key) + data[key].map(function(value) {
return '<a href="/url=' + encodeURIComponent(value.url) + '">' + value.source + '</a>' return '<a href="' + value.url + '">' + value.source + '</a>'
}).join(', ') }).join(', ')
) )
.appendTo($text); .appendTo($text);
@ -385,18 +385,20 @@ pandora.ui.infoView = function(data) {
function formatValue(value, key) { function formatValue(value, key) {
return (Ox.isArray(value) ? value : [value]).map(function(value) { return (Ox.isArray(value) ? value : [value]).map(function(value) {
return key ? return key ?
'<a href="/' + key + '==' + value + '">' + value + '</a>' '<a href="/' + key + '=' + value + '">' + value + '</a>'
: value; : value;
}).join(', '); }).join(', ');
} }
$text.find('a').click(function(event) { $text.find('a').click(function(event) {
if (event.target.hostname == document.location.hostname && pandora.URL.push(
event.target.pathname.substr(0, 5) != '/url=') { event.target.hostname == document.location.hostname
pandora.URL.push(event.target.pathname); ? event.target.pathname
: '/url=' + encodeURIComponent(event.target.href)
);
return false; return false;
}
}); });
function renderList() { function renderList() {
pandora.api.get({ pandora.api.get({
id: data.id, id: data.id,