[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

@ -175,7 +175,7 @@ define(['chroma-js', 'moment', 'tablesort', 'helper'],
return undefined;
}
return au.enabled ? _.t('node.activated', {branch: au.branch}) : _.t('node.deactivated');
return au.enabled ? _.t('node.activated', { branch: au.branch }) : _.t('node.deactivated');
}
function showStatImg(o, d) {
@ -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

@ -16,9 +16,9 @@ define(['helper'], function (helper) {
return n.flags.gateway;
}).map(helper.one));
stats.textContent = _.t('sidebar.nodes', {total: totalNodes, online: totalOnlineNodes}) + ' ' +
_.t('sidebar.clients', {smart_count: totalClients}) + ' ' +
_.t('sidebar.gateway', {smart_count: totalGateways});
stats.textContent = _.t('sidebar.nodes', { total: totalNodes, online: totalOnlineNodes }) + ' ' +
_.t('sidebar.clients', { smart_count: totalClients }) + ' ' +
_.t('sidebar.gateway', { smart_count: totalGateways });
timestamp.textContent = _.t('sidebar.lastUpdate') + ': ' + d.timestamp.format('DD.MM.Y HH:mm');
};

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

@ -177,7 +177,7 @@ define(['polyglot', 'moment', 'router', 'leaflet', 'gui', 'helper'],
return false;
});
window._ = new Polyglot({locale: locale, allowMissing: true});
window._ = new Polyglot({ locale: locale, allowMissing: true });
helper.getJSON('locale/' + _.locale() + '.json?' + config.cacheBreaker).then(setTranslation);
var router = new Router();

View File

@ -33,23 +33,23 @@ define(['sorttable', 'virtual-dom', 'helper'], function (SortTable, V, helper) {
return a.nodeinfo.hostname.localeCompare(b.nodeinfo.hostname);
},
reverse: false
}, {
}, {
name: 'node.uptime',
sort: function (a, b) {
return a.uptime - b.uptime;
},
reverse: true
}, {
}, {
name: 'node.links',
sort: function (a, b) {
return a.meshlinks - b.meshlinks;
},
reverse: true
}, {
}, {
name: 'node.clients',
sort: function (a, b) {
return ('clients' in a.statistics ? a.statistics.clients : -1) -
('clients' in b.statistics ? b.statistics.clients : -1);
('clients' in b.statistics ? b.statistics.clients : -1);
},
reverse: true
}];
@ -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

@ -24,7 +24,7 @@ define(function () {
if (sidebar.classList.contains('hidden') || button.offsetHeight === 0) {
return 0;
}
return sidebar.offsetWidth;
return sidebar.offsetWidth;
};
self.add = function add(d) {

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);