mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-29 08:50:58 +01:00
ceb522427e
Summary: Nobody knows that it's possible to highlight more lines because there's no interface for it. Test Plan: Highlighted: - single line - top to bottom - bottom to top - inside to outside Reviewers: Korvin, epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D3150
78 lines
1.8 KiB
JavaScript
78 lines
1.8 KiB
JavaScript
/**
|
|
* @provides javelin-behavior-diffusion-line-linker
|
|
* @requires javelin-behavior
|
|
* javelin-stratcom
|
|
* javelin-dom
|
|
* javelin-uri
|
|
*/
|
|
|
|
JX.behavior('diffusion-line-linker', function() {
|
|
|
|
var origin = null;
|
|
var target = null;
|
|
var root = null;
|
|
|
|
function getRowNumber(tr) {
|
|
var th = JX.DOM.find(tr, 'th', 'diffusion-line-link');
|
|
return +(th.textContent || th.innerText);
|
|
}
|
|
|
|
JX.Stratcom.listen(
|
|
'mousedown',
|
|
'diffusion-line-link',
|
|
function(e) {
|
|
if (e.isRightButton()) {
|
|
return;
|
|
}
|
|
origin = e.getNode('tag:tr');
|
|
target = origin;
|
|
root = e.getNode('diffusion-source');
|
|
e.kill();
|
|
});
|
|
|
|
JX.Stratcom.listen(
|
|
'mouseover',
|
|
'diffusion-source',
|
|
function(e) {
|
|
if (!origin || e.getNode('diffusion-source') !== root) {
|
|
return;
|
|
}
|
|
target = e.getNode('tag:tr');
|
|
|
|
var highlighting = false;
|
|
var source = null;
|
|
var trs = JX.DOM.scry(root, 'tr');
|
|
for (var i = 0; i < trs.length; i++) {
|
|
if (!highlighting && (trs[i] === origin || trs[i] === target)) {
|
|
highlighting = true;
|
|
source = trs[i];
|
|
}
|
|
JX.DOM.alterClass(trs[i], 'highlighted', highlighting);
|
|
if (trs[i] === (source === origin ? target : origin)) {
|
|
highlighting = false;
|
|
}
|
|
}
|
|
});
|
|
|
|
JX.Stratcom.listen(
|
|
'mouseup',
|
|
null,
|
|
function(e) {
|
|
if (!origin) {
|
|
return;
|
|
}
|
|
|
|
var o = getRowNumber(origin);
|
|
var t = getRowNumber(target);
|
|
var lines = (o == t ? o : Math.min(o, t) + '-' + Math.max(o, t));
|
|
var th = JX.DOM.find(origin, 'th', 'diffusion-line-link');
|
|
var uri = JX.DOM.find(th, 'a').href;
|
|
uri = uri.replace(/(.*\$)\d+/, '$1' + lines);
|
|
|
|
origin = null;
|
|
target = null;
|
|
e.kill();
|
|
JX.$U(uri).go();
|
|
});
|
|
|
|
});
|