Skip to content
Snippets Groups Projects
Commit 70377de0 authored by Denis Laxalde's avatar Denis Laxalde
Browse files

hgweb: use a function expression for the install listener of followlines UI

We define the listener of document's "DOMContentLoaded" inline in registration
and use a function expression (anonymous) with everything inside. This makes
it clearer that this file is not a library of JavaScript functions but rather
an executable script.

(Most of changes consists of reindenting the "followlinesBox" function, so
mostly white space changes.)
parent 654e9a1c
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@
// GNU General Public License version 2 or any later version.
//** Install event listeners for line block selection and followlines action */
function installLineSelect() {
document.addEventListener('DOMContentLoaded', function() {
var sourcelines = document.getElementsByClassName('sourcelines')[0];
if (typeof sourcelines === 'undefined') {
return;
......@@ -127,5 +127,9 @@
sourcelines.addEventListener('click', lineSelectStart);
}
//** return a <div id="followlines"> and inner cancel <button> elements */
function followlinesBox(targetUri, fromline, toline) {
// <div id="followlines">
var div = document.createElement('div');
div.id = 'followlines';
......@@ -131,7 +135,5 @@
//** return a <div id="followlines"> and inner cancel <button> elements */
function followlinesBox(targetUri, fromline, toline) {
// <div id="followlines">
var div = document.createElement('div');
div.id = 'followlines';
// <div class="followlines-cancel">
var buttonDiv = document.createElement('div');
buttonDiv.classList.add('followlines-cancel');
......@@ -137,5 +139,7 @@
// <div class="followlines-cancel">
var buttonDiv = document.createElement('div');
buttonDiv.classList.add('followlines-cancel');
// <button>x</button>
var button = document.createElement('button');
button.textContent = 'x';
buttonDiv.appendChild(button);
div.appendChild(buttonDiv);
......@@ -141,11 +145,5 @@
// <button>x</button>
var button = document.createElement('button');
button.textContent = 'x';
buttonDiv.appendChild(button);
div.appendChild(buttonDiv);
// <div class="followlines-link">
var aDiv = document.createElement('div');
aDiv.classList.add('followlines-link');
// <div class="followlines-link">
var aDiv = document.createElement('div');
aDiv.classList.add('followlines-link');
......@@ -151,9 +149,9 @@
// <a href="/log/<rev>/<file>?patch=&linerange=...">
var a = document.createElement('a');
var url = targetUri + '?patch=&linerange=' + fromline + ':' + toline;
a.setAttribute('href', url);
a.textContent = 'follow lines ' + fromline + ':' + toline;
aDiv.appendChild(a);
div.appendChild(aDiv);
// <a href="/log/<rev>/<file>?patch=&linerange=...">
var a = document.createElement('a');
var url = targetUri + '?patch=&linerange=' + fromline + ':' + toline;
a.setAttribute('href', url);
a.textContent = 'follow lines ' + fromline + ':' + toline;
aDiv.appendChild(a);
div.appendChild(aDiv);
......@@ -159,4 +157,4 @@
return [div, button];
}
return [div, button];
}
......@@ -162,2 +160,2 @@
document.addEventListener('DOMContentLoaded', installLineSelect, false);
}, false);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment