[TASK] Href with working links

This commit is contained in:
Xaver Maierhofer 2017-02-04 16:14:24 +01:00
parent 66f09a2e32
commit e8ff43c6a7
No known key found for this signature in database
GPG Key ID: 7FDCE23FD2EC9FE8
10 changed files with 36 additions and 30 deletions

View File

@ -18,7 +18,7 @@ define(['helper'], function (helper) {
var a1; var a1;
if (!unknown) { if (!unknown) {
a1 = document.createElement('a'); a1 = document.createElement('a');
a1.href = '#'; a1.href = router.getUrl({ n: d.source.node_id });
a1.onclick = router.node(d.source.node); a1.onclick = router.node(d.source.node);
} else { } else {
a1 = document.createElement('span'); a1 = document.createElement('span');
@ -31,7 +31,7 @@ define(['helper'], function (helper) {
h2.appendChild(arrow); h2.appendChild(arrow);
var a2 = document.createElement('a'); var a2 = document.createElement('a');
a2.href = '#'; a2.href = router.getUrl({ n: d.target.node_id });
a2.onclick = router.node(d.target.node); a2.onclick = router.node(d.target.node);
a2.textContent = d.target.node.nodeinfo.hostname; a2.textContent = d.target.node.nodeinfo.hostname;
h2.appendChild(a2); h2.appendChild(a2);

View File

@ -286,7 +286,7 @@ define(['chroma-js', 'moment', 'tablesort', 'helper'],
var a1 = document.createElement('a'); var a1 = document.createElement('a');
a1.textContent = n.node.nodeinfo.hostname; a1.textContent = n.node.nodeinfo.hostname;
a1.classList.add('online'); a1.classList.add('online');
a1.href = '#'; a1.href = router.getUrl({ n: n.node.nodeinfo.node_id });
a1.onclick = router.node(n.node); a1.onclick = router.node(n.node);
td2.appendChild(a1); td2.appendChild(a1);
} else { } else {

View File

@ -31,7 +31,7 @@ define(['sorttable', 'virtual-dom', 'helper'], function (SortTable, V, helper) {
table.el.classList.add('link-list'); table.el.classList.add('link-list');
function renderRow(d) { function renderRow(d) {
var td1Content = [V.h('a', { href: '#', onclick: router.link(d) }, linkName(d))]; var td1Content = [V.h('a', { href: router.getUrl({ l: d.id }), onclick: router.link(d) }, linkName(d))];
var td1 = V.h('td', td1Content); var td1 = V.h('td', td1Content);
var td2 = V.h('td', { style: { color: linkScale(d.tq).hex() } }, helper.showTq(d)); var td2 = V.h('td', { style: { color: linkScale(d.tq).hex() } }, helper.showTq(d));

View File

@ -63,9 +63,8 @@ define(['sorttable', 'virtual-dom', 'helper'], function (SortTable, V, helper) {
td1Content.push(V.h('a', { td1Content.push(V.h('a', {
className: aClass.join(' '), className: aClass.join(' '),
onclick: router.node(d), onclick: router.node(d),
href: '#' href: router.getUrl({ n: d.nodeinfo.node_id })
}, d.nodeinfo.hostname)); }, d.nodeinfo.hostname));
if (helper.hasLocation(d)) { if (helper.hasLocation(d)) {
td0Content.push(V.h('span', { className: 'icon ion-location' })); td0Content.push(V.h('span', { className: 'icon ion-location' }));
} }

View File

@ -11,25 +11,19 @@ define(['helper'], function (helper) {
var running = false; var running = false;
function saveState() { function saveState() {
var e = []; var e = '#!';
if (currentView) { e += 'v:' + currentView;
e.push('v:' + currentView);
}
if (currentObject) { if (currentObject) {
if ('node' in currentObject) { if ('node' in currentObject) {
e.push('n:' + encodeURIComponent(currentObject.node.nodeinfo.node_id)); e += ';n:' + encodeURIComponent(currentObject.node.nodeinfo.node_id);
} } else if ('link' in currentObject) {
e += ';l:' + encodeURIComponent(currentObject.link.id);
if ('link' in currentObject) {
e.push('l:' + encodeURIComponent(currentObject.link.id));
} }
} }
var s = '#!' + e.join(';'); window.history.pushState(e, undefined, e);
window.history.pushState(s, undefined, s);
} }
function resetView(push) { function resetView(push) {
@ -129,6 +123,20 @@ define(['helper'], function (helper) {
return targetSet; return targetSet;
} }
self.getUrl = function getUrl(data) {
var e = '#!';
if (data.n) {
e += 'n:' + encodeURIComponent(data.n);
}
if (data.l) {
e += 'l:' + encodeURIComponent(data.l);
}
return e;
};
self.start = function start() { self.start = function start() {
running = true; running = true;

View File

@ -42,7 +42,7 @@ define(['moment', 'virtual-dom', 'helper'], function (moment, V, helper) {
td1Content.push(V.h('a', { td1Content.push(V.h('a', {
className: aClass.join(' '), className: aClass.join(' '),
onclick: router.node(d), onclick: router.node(d),
href: '#' href: router.getUrl({ n: d.nodeinfo.node_id })
}, d.nodeinfo.hostname)); }, d.nodeinfo.hostname));
if (helper.hasLocation(d)) { if (helper.hasLocation(d)) {

View File

@ -132,7 +132,6 @@ define({
return ''; return '';
} }
var tr = document.createElement('tr'); var tr = document.createElement('tr');
var th = document.createElement('th'); var th = document.createElement('th');
th.textContent = _.t(label); th.textContent = _.t(label);