// followlines.js - JavaScript utilities for followlines UI // // Copyright 2017 Logilab SA // // This software may be used and distributed according to the terms of the // GNU General Public License version 2 or any later version. //** Install event listeners for line block selection and followlines action */ document.addEventListener('DOMContentLoaded', function() { var sourcelines = document.getElementsByClassName('sourcelines')[0]; if (typeof sourcelines === 'undefined') { return; } // URL to complement with "linerange" query parameter var targetUri = sourcelines.dataset.logurl; if (typeof targetUri === 'undefined') { return; } // Tag of children of "sourcelines" element on which to add "line // selection" style. var selectableTag = sourcelines.dataset.selectabletag; if (typeof selectableTag === 'undefined') { return; } var isHead = parseInt(sourcelines.dataset.ishead || "0"); //* position "element" on top-right of cursor */ function positionTopRight(element, event) { var x = (event.clientX + 10) + 'px', y = (event.clientY - 20) + 'px'; element.style.top = y; element.style.left = x; } // retrieve all direct *selectable* children of class="sourcelines" // element var selectableElements = Array.prototype.filter.call( sourcelines.children, function(x) { return x.tagName === selectableTag }); var btnTitleStart = 'start following lines history from here'; var btnTitleEnd = 'terminate line block selection here'; //** return a var button = document.createElement('button'); button.textContent = 'x'; buttonDiv.appendChild(button); div.appendChild(buttonDiv); //