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

View File

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

View File

@ -31,7 +31,7 @@ define(['sorttable', 'virtual-dom', 'helper'], function (SortTable, V, helper) {
table.el.classList.add('link-list');
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 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', {
className: aClass.join(' '),
onclick: router.node(d),
href: '#'
href: router.getUrl({ n: d.nodeinfo.node_id })
}, d.nodeinfo.hostname));
if (helper.hasLocation(d)) {
td0Content.push(V.h('span', { className: 'icon ion-location' }));
}

View File

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

View File

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

View File

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