* configs

* fix lint errors
This commit is contained in:
sbcgua 2018-12-30 09:05:17 +02:00 committed by Lars Hvam
parent f1a0307fa9
commit ceb7a6d02a
4 changed files with 126 additions and 107 deletions

View File

@ -15,6 +15,7 @@
<item>/.gitignore</item> <item>/.gitignore</item>
<item>/CODE_OF_CONDUCT.md</item> <item>/CODE_OF_CONDUCT.md</item>
<item>/abaplint.json</item> <item>/abaplint.json</item>
<item>/.eslintrc.yaml</item>
</IGNORE> </IGNORE>
</DATA> </DATA>
</asx:values> </asx:values>

14
.eslintrc.yaml Normal file
View File

@ -0,0 +1,14 @@
---
parserOptions:
ecmaVersion: 5
env:
browser: true
extends:
- eslint:recommended
rules:
quotes: ['error', 'double', { 'avoidEscape': true }]
semi: ['error', 'always', { 'omitLastInOneLineBlock': true}]
no-console: off
indent: ['error', 2]
no-trailing-spaces: ['error']
no-unused-vars: ['warn']

View File

@ -4,14 +4,16 @@
"pretest": "abaplint --version && abaplint \"src/**/*.*\"", "pretest": "abaplint --version && abaplint \"src/**/*.*\"",
"test": "abapmerge src/zabapgit.prog.abap > zabapgit.abap", "test": "abapmerge src/zabapgit.prog.abap > zabapgit.abap",
"_disabled_posttest": "abaplint zabapgit.abap", "_disabled_posttest": "abaplint zabapgit.abap",
"lint": "abaplint \"src/**/*.*\"" "lint": "abaplint \"src/**/*.*\"",
"eslint": "eslint src"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/larshp/abapGit.git" "url": "git+https://github.com/larshp/abapGit.git"
}, },
"devDependencies": { "devDependencies": {
"abaplint": "^1.5.0",
"abapmerge": "^0.11.0", "abapmerge": "^0.11.0",
"abaplint": "^1.5.0" "eslint": "^5.11.1"
} }
} }

View File

@ -14,14 +14,16 @@ if (!Function.prototype.bind) {
} }
var aArgs = Array.prototype.slice.call(arguments, 1), var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this, fToBind = this,
fNOP = function() {}, fNOP = function() {},
fBound = function() { fBound = function() {
return fToBind.apply(this instanceof fNOP return fToBind.apply(
? this this instanceof fNOP
: oThis, ? this
aArgs.concat(Array.prototype.slice.call(arguments))); : oThis,
}; aArgs.concat(Array.prototype.slice.call(arguments))
);
};
if (this.prototype) { if (this.prototype) {
fNOP.prototype = this.prototype; fNOP.prototype = this.prototype;
@ -35,8 +37,8 @@ if (!Function.prototype.bind) {
// String includes polyfill, taken from https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/String/includes // String includes polyfill, taken from https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/String/includes
if (!String.prototype.includes) { if (!String.prototype.includes) {
String.prototype.includes = function(search, start) { String.prototype.includes = function(search, start) {
'use strict'; "use strict";
if (typeof start !== 'number') { if (typeof start !== "number") {
start = 0; start = 0;
} }
@ -132,11 +134,11 @@ function perfOut(prefix) {
} }
var keys = Object.keys(totals); var keys = Object.keys(totals);
for (var i = keys.length - 1; i >= 0; i--) { for (var j = keys.length - 1; j >= 0; j--) {
console.log(prefix console.log(prefix
+ " " + keys[i] + ": " + " " + keys[j] + ": "
+ totals[keys[i]].time.toFixed(3) + "ms" + totals[keys[j]].time.toFixed(3) + "ms"
+ " (" + totals[keys[i]].count.toFixed() +")"); + " (" + totals[keys[j]].count.toFixed() +")");
} }
} }
@ -154,7 +156,7 @@ function perfClear() {
// somehow only functions on window are visible for the select tag // somehow only functions on window are visible for the select tag
window.onTagTypeChange = function(oSelectObject){ window.onTagTypeChange = function(oSelectObject){
var sValue = oSelectObject.value; var sValue = oSelectObject.value;
submitSapeventForm({ 'type': sValue }, "change_tag_type", "post"); submitSapeventForm({ type: sValue }, "change_tag_type", "post");
}; };
/********************************************************** /**********************************************************
@ -163,12 +165,12 @@ window.onTagTypeChange = function(oSelectObject){
// somehow only functions on window are visible for the select tag // somehow only functions on window are visible for the select tag
window.onOrderByChange = function(oSelectObject){ window.onOrderByChange = function(oSelectObject){
var sValue = oSelectObject.value; var sValue = oSelectObject.value;
submitSapeventForm({ 'orderBy': sValue }, "change_order_by", "post"); submitSapeventForm({ orderBy: sValue }, "change_order_by", "post");
}; };
window.onDirectionChange = function(oSelectObject){ window.onDirectionChange = function(oSelectObject){
var sValue = oSelectObject.value; var sValue = oSelectObject.value;
submitSapeventForm({ 'direction': sValue }, "direction", "post"); submitSapeventForm({ direction: sValue }, "direction", "post");
}; };
/********************************************************** /**********************************************************
@ -202,7 +204,7 @@ function StageHelper(params) {
remove: "R", remove: "R",
ignore: "I", ignore: "I",
reset: "?", reset: "?",
isValid: function (status) { return "ARI?".indexOf(status) == -1; } isValid: function (status) { return "ARI?".indexOf(status) == -1 }
}; };
this.TEMPLATES = { this.TEMPLATES = {
@ -222,7 +224,7 @@ StageHelper.prototype.setHooks = function() {
this.dom.objectSearch.onkeypress = this.onFilter.bind(this); this.dom.objectSearch.onkeypress = this.onFilter.bind(this);
window.onbeforeunload = this.onPageUnload.bind(this); window.onbeforeunload = this.onPageUnload.bind(this);
window.onload = this.onPageLoad.bind(this); window.onload = this.onPageLoad.bind(this);
} };
// Detect column index // Detect column index
StageHelper.prototype.detectColumns = function() { StageHelper.prototype.detectColumns = function() {
@ -234,7 +236,7 @@ StageHelper.prototype.detectColumns = function() {
} }
return colIndex; return colIndex;
} };
// Store table state on leaving the page // Store table state on leaving the page
StageHelper.prototype.onPageUnload = function() { StageHelper.prototype.onPageUnload = function() {
@ -265,10 +267,11 @@ StageHelper.prototype.onTableClick = function (event) {
var target = event.target || event.srcElement; var target = event.target || event.srcElement;
if (!target) return; if (!target) return;
var td;
if (target.tagName === "A") { if (target.tagName === "A") {
var td = target.parentNode; td = target.parentNode;
} else if (target.tagName === "TD") { } else if (target.tagName === "TD") {
var td = target; td = target;
if (td.children.length === 1 && td.children[0].tagName === "A") { if (td.children.length === 1 && td.children[0].tagName === "A") {
target = td.children[0]; target = td.children[0];
} else return; } else return;
@ -285,7 +288,7 @@ StageHelper.prototype.onTableClick = function (event) {
this.iterateStageTab(true, function (row) { this.iterateStageTab(true, function (row) {
if (row.style.display !== "none" // Not filtered out if (row.style.display !== "none" // Not filtered out
&& row.className === targetRow.className // Same context as header && row.className === targetRow.className // Same context as header
) { ) {
this.updateRow(row, status); this.updateRow(row, status);
} }
}); });
@ -297,11 +300,11 @@ StageHelper.prototype.onTableClick = function (event) {
// Search object // Search object
StageHelper.prototype.onFilter = function (e) { StageHelper.prototype.onFilter = function (e) {
if ( // Enter hit or clear, IE SUCKS ! if ( // Enter hit or clear, IE SUCKS !
e.type === "input" && !e.target.value && this.lastFilterValue e.type === "input" && !e.target.value && this.lastFilterValue
|| e.type === "keypress" && e.which === 13 ) { || e.type === "keypress" && e.which === 13 ) {
this.applyFilterValue(e.target.value); this.applyFilterValue(e.target.value);
submitSapeventForm({ 'filterValue': e.target.value }, "stage_filter", "post"); submitSapeventForm({ filterValue: e.target.value }, "stage_filter", "post");
} }
}; };
@ -339,10 +342,10 @@ StageHelper.prototype.applyFilterToRow = function (row, filter) {
// Update DOM // Update DOM
row.style.display = isVisible ? "" : "none"; row.style.display = isVisible ? "" : "none";
for (var i = targets.length - 1; i >= 0; i--) { for (var j = targets.length - 1; j >= 0; j--) {
if (targets[i].isChanged) targets[i].elem.innerHTML = targets[i].newHtml; if (targets[j].isChanged) targets[j].elem.innerHTML = targets[j].newHtml;
} }
} };
// Get how status should affect object counter // Get how status should affect object counter
StageHelper.prototype.getStatusImpact = function (status) { StageHelper.prototype.getStatusImpact = function (status) {
@ -353,7 +356,7 @@ StageHelper.prototype.getStatusImpact = function (status) {
} else { } else {
return (status !== this.STATUS.reset) ? 1 : 0; return (status !== this.STATUS.reset) ? 1 : 0;
} }
} };
// Update table line // Update table line
StageHelper.prototype.updateRow = function (row, newStatus) { StageHelper.prototype.updateRow = function (row, newStatus) {
@ -367,7 +370,7 @@ StageHelper.prototype.updateRow = function (row, newStatus) {
} }
this.choiseCount += this.getStatusImpact(newStatus) - this.getStatusImpact(oldStatus); this.choiseCount += this.getStatusImpact(newStatus) - this.getStatusImpact(oldStatus);
} };
// Update Status cell (render set of commands) // Update Status cell (render set of commands)
StageHelper.prototype.updateRowStatus = function (row, status) { StageHelper.prototype.updateRowStatus = function (row, status) {
@ -377,7 +380,7 @@ StageHelper.prototype.updateRowStatus = function (row, status) {
} else { } else {
row.cells[this.colIndex["status"]].classList.add(this.HIGHLIGHT_STYLE); row.cells[this.colIndex["status"]].classList.add(this.HIGHLIGHT_STYLE);
} }
} };
// Update Command cell (render set of commands) // Update Command cell (render set of commands)
StageHelper.prototype.updateRowCommand = function (row, status) { StageHelper.prototype.updateRowCommand = function (row, status) {
@ -389,19 +392,19 @@ StageHelper.prototype.updateRowCommand = function (row, status) {
} else { } else {
cell.innerHTML = this.TEMPLATES.cmdReset; cell.innerHTML = this.TEMPLATES.cmdReset;
} }
} };
// Update menu items visibility // Update menu items visibility
StageHelper.prototype.updateMenu = function () { StageHelper.prototype.updateMenu = function () {
this.dom.commitBtn.style.display = (this.choiseCount > 0) ? "" : "none"; this.dom.commitBtn.style.display = (this.choiseCount > 0) ? "" : "none";
this.dom.commitAllBtn.style.display = (this.choiseCount > 0) ? "none" : ""; this.dom.commitAllBtn.style.display = (this.choiseCount > 0) ? "none" : "";
this.dom.fileCounter.innerHTML = this.choiseCount.toString(); this.dom.fileCounter.innerHTML = this.choiseCount.toString();
} };
// Submit stage state to the server // Submit stage state to the server
StageHelper.prototype.submit = function () { StageHelper.prototype.submit = function () {
submitSapeventForm(this.collectData(), this.formAction); submitSapeventForm(this.collectData(), this.formAction);
} };
// Extract data from the table // Extract data from the table
StageHelper.prototype.collectData = function () { StageHelper.prototype.collectData = function () {
@ -410,7 +413,7 @@ StageHelper.prototype.collectData = function () {
data[row.cells[this.colIndex["name"]].innerText] = row.cells[this.colIndex["status"]].innerText; data[row.cells[this.colIndex["name"]].innerText] = row.cells[this.colIndex["status"]].innerText;
}); });
return data; return data;
} };
// Table iteration helper // Table iteration helper
StageHelper.prototype.iterateStageTab = function (changeMode, cb /*, ...*/) { StageHelper.prototype.iterateStageTab = function (changeMode, cb /*, ...*/) {
@ -425,7 +428,7 @@ StageHelper.prototype.iterateStageTab = function (changeMode, cb /*, ...*/) {
for (var b = 0, bN = table.tBodies.length; b < bN; b++) { for (var b = 0, bN = table.tBodies.length; b < bN; b++) {
var tbody = table.tBodies[b]; var tbody = table.tBodies[b];
for (var r = 0, rN = tbody.rows.length; r < rN; r++) { for (var r = 0, rN = tbody.rows.length; r < rN; r++) {
args = [tbody.rows[r]].concat(restArgs); var args = [tbody.rows[r]].concat(restArgs);
cb.apply(this, args); // callback cb.apply(this, args); // callback
} }
} }
@ -434,7 +437,7 @@ StageHelper.prototype.iterateStageTab = function (changeMode, cb /*, ...*/) {
this.dom.stageTab.style.display = ""; this.dom.stageTab.style.display = "";
window.scrollTo(0, scrollOffset); window.scrollTo(0, scrollOffset);
} }
} };
/********************************************************** /**********************************************************
* Check list wrapper * Check list wrapper
@ -446,11 +449,11 @@ function CheckListWrapper(id, cbAction) {
this.id.onclick = this.onClick.bind(this); this.id.onclick = this.onClick.bind(this);
} }
CheckListWrapper.prototype.onClick = function(e) { CheckListWrapper.prototype.onClick = function(e) { // eslint-disable-line no-unused-vars
// Get nodes // Get nodes
var target = event.target || event.srcElement; var target = event.target || event.srcElement;
if (!target) return; if (!target) return;
if (target.tagName !== "A") { target = target.parentNode; } // icon clicked if (target.tagName !== "A") { target = target.parentNode } // icon clicked
if (target.tagName !== "A") return; if (target.tagName !== "A") return;
if (target.parentNode.tagName !== "LI") return; if (target.parentNode.tagName !== "LI") return;
@ -477,7 +480,7 @@ CheckListWrapper.prototype.onClick = function(e) {
// Action callback // Action callback
this.cbAction(nodeLi.getAttribute("data-aux"), option, newState); this.cbAction(nodeLi.getAttribute("data-aux"), option, newState);
} };
/********************************************************** /**********************************************************
* Diff page logic * Diff page logic
@ -524,17 +527,17 @@ DiffHelper.prototype.applyFilter = function (attr, target, state) {
div.style.display = state ? "" : "none"; div.style.display = state ? "" : "none";
} }
}); });
} };
// Action on stage -> save visible diffs as state for stage page // Action on stage -> save visible diffs as state for stage page
DiffHelper.prototype.onStage = function (e) { DiffHelper.prototype.onStage = function (e) { // eslint-disable-line no-unused-vars
if (window.sessionStorage) { if (window.sessionStorage) {
var data = this.buildStageCache(); var data = this.buildStageCache();
window.sessionStorage.setItem(this.pageSeed, JSON.stringify(data)); window.sessionStorage.setItem(this.pageSeed, JSON.stringify(data));
} }
var getParams = {key: this.repoKey, seed: this.pageSeed}; var getParams = {key: this.repoKey, seed: this.pageSeed};
submitSapeventForm(getParams, this.stageAction, "get"); submitSapeventForm(getParams, this.stageAction, "get");
} };
// Collect visible diffs // Collect visible diffs
DiffHelper.prototype.buildStageCache = function () { DiffHelper.prototype.buildStageCache = function () {
@ -546,7 +549,7 @@ DiffHelper.prototype.buildStageCache = function () {
} }
}); });
return list; return list;
} };
// Table iterator // Table iterator
DiffHelper.prototype.iterateDiffList = function (cb /*, ...*/) { DiffHelper.prototype.iterateDiffList = function (cb /*, ...*/) {
@ -556,10 +559,10 @@ DiffHelper.prototype.iterateDiffList = function (cb /*, ...*/) {
for (var i = 0, iN = diffList.children.length; i < iN; i++) { for (var i = 0, iN = diffList.children.length; i < iN; i++) {
var div = diffList.children[i]; var div = diffList.children[i];
if (div.className !== "diff") continue; if (div.className !== "diff") continue;
args = [div].concat(restArgs); var args = [div].concat(restArgs);
cb.apply(this, args); // callback cb.apply(this, args); // callback
} }
} };
// Highlight Filter button if filter is activate // Highlight Filter button if filter is activate
DiffHelper.prototype.highlightButton = function(state) { DiffHelper.prototype.highlightButton = function(state) {
@ -578,7 +581,7 @@ DiffHelper.prototype.highlightButton = function(state) {
// News announcement // News announcement
function toggleDisplay(divId) { function toggleDisplay(divId) {
var div = document.getElementById(divId); var div = document.getElementById(divId);
if (div) div.style.display = (div.style.display) ? '' : 'none'; if (div) div.style.display = (div.style.display) ? "" : "none";
} }
function KeyNavigation() { function KeyNavigation() {
@ -603,7 +606,7 @@ KeyNavigation.prototype.onkeydown = function(oEvent) {
}; };
KeyNavigation.prototype.getLiSelected = function() { KeyNavigation.prototype.getLiSelected = function() {
return document.querySelector('li .selected'); return document.querySelector("li .selected");
}; };
KeyNavigation.prototype.getActiveElement = function () { KeyNavigation.prototype.getActiveElement = function () {
@ -614,7 +617,7 @@ KeyNavigation.prototype.getActiveElementParent = function () {
return this.getActiveElement().parentElement; return this.getActiveElement().parentElement;
}; };
KeyNavigation.prototype.onEnterOrSpace = function (oEvent) { KeyNavigation.prototype.onEnterOrSpace = function (oEvent) { // eslint-disable-line no-unused-vars
// Enter or space clicks the selected link // Enter or space clicks the selected link
@ -639,9 +642,9 @@ KeyNavigation.prototype.onArrowDown = function (oEvent) {
// we deselect the current li and select the next sibling // we deselect the current li and select the next sibling
liNext = oActiveElementParent.nextElementSibling; liNext = oActiveElementParent.nextElementSibling;
if (liNext) { if (liNext) {
liSelected.classList.toggle('selected'); liSelected.classList.toggle("selected");
liNext.firstElementChild.focus(); liNext.firstElementChild.focus();
oActiveElementParent.classList.toggle('selected'); oActiveElementParent.classList.toggle("selected");
oEvent.preventDefault(); oEvent.preventDefault();
} }
@ -651,7 +654,7 @@ KeyNavigation.prototype.onArrowDown = function (oEvent) {
// the right element should have been activated in fnTooltipActivate // the right element should have been activated in fnTooltipActivate
liNext = this.getActiveElement().nextElementSibling; liNext = this.getActiveElement().nextElementSibling;
if (liNext) { if (liNext) {
liNext.classList.toggle('selected'); liNext.classList.toggle("selected");
liNext.firstElementChild.firstElementChild.focus(); liNext.firstElementChild.firstElementChild.focus();
oEvent.preventDefault(); oEvent.preventDefault();
} }
@ -669,9 +672,9 @@ KeyNavigation.prototype.onArrowUp = function (oEvent) {
if (liSelected && liPrevious) { if (liSelected && liPrevious) {
liSelected.classList.toggle('selected'); liSelected.classList.toggle("selected");
liPrevious.firstElementChild.focus(); liPrevious.firstElementChild.focus();
this.getActiveElementParent().classList.toggle('selected'); this.getActiveElementParent().classList.toggle("selected");
oEvent.preventDefault(); oEvent.preventDefault();
} }
@ -684,7 +687,7 @@ function enableArrowListNavigation() {
var oKeyNavigation = new KeyNavigation(); var oKeyNavigation = new KeyNavigation();
document.addEventListener('keydown', oKeyNavigation.onkeydown.bind(oKeyNavigation)); document.addEventListener("keydown", oKeyNavigation.onkeydown.bind(oKeyNavigation));
} }
@ -694,14 +697,14 @@ function LinkHints(sLinkHintKey, sColor){
this.oTooltipMap = {}; this.oTooltipMap = {};
this.bTooltipsOn = false; this.bTooltipsOn = false;
this.sPending = ""; this.sPending = "";
this.aTooltipElements = document.querySelectorAll('a span'); this.aTooltipElements = document.querySelectorAll("a span");
} }
LinkHints.prototype.fnRenderTooltip = function (oTooltip, iTooltipCounter) { LinkHints.prototype.fnRenderTooltip = function (oTooltip, iTooltipCounter) {
if (this.bTooltipsOn) { if (this.bTooltipsOn) {
oTooltip.classList.remove('hidden'); oTooltip.classList.remove("hidden");
} else { } else {
oTooltip.classList.add('hidden'); oTooltip.classList.add("hidden");
} }
oTooltip.innerHTML = iTooltipCounter; oTooltip.innerHTML = iTooltipCounter;
oTooltip.style.backgroundColor = this.sColor; oTooltip.style.backgroundColor = this.sColor;
@ -750,12 +753,12 @@ LinkHints.prototype.fnRemoveAllTooltips = function () {
this.bTooltipsOn = false; this.bTooltipsOn = false;
[].forEach.call(this.aTooltipElements, function (oTooltip) { [].forEach.call(this.aTooltipElements, function (oTooltip) {
oTooltip.classList.add('hidden'); oTooltip.classList.add("hidden");
}); });
}; };
LinkHints.prototype.fnFilterTooltips = function (sPending) { LinkHints.prototype.fnFilterTooltips = function (sPending) { // eslint-disable-line no-unused-vars
Object Object
.keys(this.oTooltipMap) .keys(this.oTooltipMap)
@ -767,10 +770,10 @@ LinkHints.prototype.fnFilterTooltips = function (sPending) {
if (regex.test(sKey)) { if (regex.test(sKey)) {
// we have a partial match, grey out the matched part // we have a partial match, grey out the matched part
oTooltip.innerHTML = sKey.replace(regex, "<div style='display:inline;color:lightgray'>" + this.sPending + '</div>'); oTooltip.innerHTML = sKey.replace(regex, "<div style='display:inline;color:lightgray'>" + this.sPending + "</div>");
} else { } else {
// and hide the not matched tooltips // and hide the not matched tooltips
oTooltip.classList.add('hidden'); oTooltip.classList.add("hidden");
} }
}.bind(this)); }.bind(this));
@ -882,10 +885,10 @@ function Hotkeys(oKeyMap){
} }
Hotkeys.prototype.showHotkeys = function() { Hotkeys.prototype.showHotkeys = function() {
var elHotkeys = document.querySelector('#hotkeys'); var elHotkeys = document.querySelector("#hotkeys");
if (elHotkeys) { if (elHotkeys) {
elHotkeys.style.display = (elHotkeys.style.display) ? '' : 'none'; elHotkeys.style.display = (elHotkeys.style.display) ? "" : "none";
} }
}; };
@ -901,13 +904,12 @@ Hotkeys.prototype.getSapEvent = function(sSapEvent) {
var aSapEvents = document.querySelectorAll('a[href^="sapevent:' + sSapEvent + '"]'); var aSapEvents = document.querySelectorAll('a[href^="sapevent:' + sSapEvent + '"]');
var aFilteredAndNormalizedSapEvents = var aFilteredAndNormalizedSapEvents =
[].map.call(aSapEvents, function(oSapEvent){ [].map.call(aSapEvents, function(oSapEvent){
return fnNormalizeSapEventHref(sSapEvent, oSapEvent); return fnNormalizeSapEventHref(sSapEvent, oSapEvent);
}) }).filter(function(elem){
.filter(function(elem){ // remove false positives
// remove false positives return (elem && !elem.includes("sapevent:"));
return (elem && !elem.includes("sapevent:")); });
});
return (aFilteredAndNormalizedSapEvents && aFilteredAndNormalizedSapEvents[0]); return (aFilteredAndNormalizedSapEvents && aFilteredAndNormalizedSapEvents[0]);
@ -916,7 +918,7 @@ Hotkeys.prototype.getSapEvent = function(sSapEvent) {
Hotkeys.prototype.onkeydown = function(oEvent){ Hotkeys.prototype.onkeydown = function(oEvent){
if (oEvent.defaultPrevented) { if (oEvent.defaultPrevented) {
return; return;
} }
var activeElementType = ((document.activeElement && document.activeElement.nodeName) || ""); var activeElementType = ((document.activeElement && document.activeElement.nodeName) || "");
@ -938,8 +940,8 @@ function setKeyBindings(oKeyMap){
var oHotkeys = new Hotkeys(oKeyMap); var oHotkeys = new Hotkeys(oKeyMap);
document.addEventListener('keypress', oHotkeys.onkeydown.bind(oHotkeys)); document.addEventListener("keypress", oHotkeys.onkeydown.bind(oHotkeys));
setTimeout(function(){ setTimeout(function(){
var div = document.getElementById("hotkeys-hint"); var div = document.getElementById("hotkeys-hint");
if (div) div.style.opacity = 0.2; if (div) div.style.opacity = 0.2;
}, 4900); }, 4900);
@ -958,20 +960,20 @@ function CSSPatchClassCombination(sClassLinkClicked, sClassCorrespondingLink){
function Patch() { function Patch() {
this.CSS_CLASS = { this.CSS_CLASS = {
ADD: 'add', ADD: "add",
REMOVE: 'remove', REMOVE: "remove",
PATCH: 'patch', PATCH: "patch",
PATCH_ACTIVE: 'patch-active' PATCH_ACTIVE: "patch-active"
}; };
this.ID = { this.ID = {
STAGE: 'stage', STAGE: "stage",
PATCH_ADD_ALL: 'patch_add_all', PATCH_ADD_ALL: "patch_add_all",
PATCH_REMOVE_ALL: 'patch_remove_all' PATCH_REMOVE_ALL: "patch_remove_all"
}; };
this.ACTION = { this.ACTION = {
PATCH_STAGE: 'patch_stage' PATCH_STAGE: "patch_stage"
}; };
this.ADD_REMOVE = new CSSPatchClassCombination(this.CSS_CLASS.ADD, this.CSS_CLASS.REMOVE); this.ADD_REMOVE = new CSSPatchClassCombination(this.CSS_CLASS.ADD, this.CSS_CLASS.REMOVE);
@ -999,8 +1001,8 @@ Patch.prototype.registerClickHandlerAllFile = function(){
// registers the link handlers for add and remove all changes for a file // registers the link handlers for add and remove all changes for a file
this.registerClickHandlerForPatchLinkAll('#' + this.ID.PATCH_ADD_ALL, this.ADD_REMOVE); this.registerClickHandlerForPatchLinkAll("#" + this.ID.PATCH_ADD_ALL, this.ADD_REMOVE);
this.registerClickHandlerForPatchLinkAll('#' + this.ID.PATCH_REMOVE_ALL, this.REMOVE_ADD); this.registerClickHandlerForPatchLinkAll("#" + this.ID.PATCH_REMOVE_ALL, this.REMOVE_ADD);
}; };
@ -1011,11 +1013,11 @@ Patch.prototype.registerClickHandlerForPatchLink = function(oClassCombination) {
// e.g. if you click on 'add' add is deactivated and 'remove' // e.g. if you click on 'add' add is deactivated and 'remove'
// is activated. // is activated.
var elLinkAll = document.querySelectorAll('.' + this.CSS_CLASS.PATCH + ' a.' + oClassCombination.sClassLinkClicked); var elLinkAll = document.querySelectorAll("." + this.CSS_CLASS.PATCH + " a." + oClassCombination.sClassLinkClicked);
[].forEach.call(elLinkAll,function(elLink){ [].forEach.call(elLinkAll,function(elLink){
elLink.addEventListener('click',function(oEvent){ elLink.addEventListener("click",function(oEvent){
this.togglePatchActiveForClassLink(oEvent, elLink, oClassCombination); this.togglePatchActiveForClassLink(oEvent, elLink, oClassCombination);
}.bind(this)); }.bind(this));
@ -1050,15 +1052,15 @@ Patch.prototype.getCorrespodingLinkId = function(sClickedLinkId, oClassCombinati
// //
// and vice versa // and vice versa
var oRegexPatchClassPrefix = new RegExp('^' + oClassCombination.sClassLinkClicked ); var oRegexPatchClassPrefix = new RegExp("^" + oClassCombination.sClassLinkClicked );
return sClickedLinkId.replace(oRegexPatchClassPrefix, oClassCombination.sClassCorrespondingLink); return sClickedLinkId.replace(oRegexPatchClassPrefix, oClassCombination.sClassCorrespondingLink);
}; };
Patch.prototype.escape = function(sFileName){ Patch.prototype.escape = function(sFileName){
return sFileName return sFileName
.replace(/\./g,'\\.') .replace(/\./g, "\\.")
.replace(/\#/g,'\\#'); .replace(/#/g, "\\#");
}; };
Patch.prototype.patchLinkClickAll = function(oClassCombination) { Patch.prototype.patchLinkClickAll = function(oClassCombination) {
@ -1073,7 +1075,7 @@ Patch.prototype.patchLinkClickAll = function(oClassCombination) {
oEvent.preventDefault(); oEvent.preventDefault();
} };
}; };
Patch.prototype.registerClickHandlerForPatchLinkAll = function(sSelector, oClassCombination){ Patch.prototype.registerClickHandlerForPatchLinkAll = function(sSelector, oClassCombination){
@ -1081,15 +1083,15 @@ Patch.prototype.registerClickHandlerForPatchLinkAll = function(sSelector, oClass
var elAll = document.querySelectorAll(sSelector); var elAll = document.querySelectorAll(sSelector);
[].forEach.call(elAll, function(elem){ [].forEach.call(elAll, function(elem){
elem.addEventListener('click', this.patchLinkClickAll(oClassCombination).bind(this)); elem.addEventListener("click", this.patchLinkClickAll(oClassCombination).bind(this));
}.bind(this)); }.bind(this));
}; };
Patch.prototype.registerStagePatch = function registerStagePatch(){ Patch.prototype.registerStagePatch = function registerStagePatch(){
var elStage = document.querySelector('#' + this.ID.STAGE); var elStage = document.querySelector("#" + this.ID.STAGE);
elStage.addEventListener('click', this.stagePatch.bind(this)); elStage.addEventListener("click", this.stagePatch.bind(this));
// for hotkeys // for hotkeys
window.stagePatch = function(){ window.stagePatch = function(){
@ -1102,10 +1104,10 @@ Patch.prototype.stagePatch = function() {
// Collect add and remove info and submit to backend // Collect add and remove info and submit to backend
var aAddPatch = this.collectActiveElementsForSelector('.' + this.CSS_CLASS.PATCH +' a.' + this.CSS_CLASS.ADD); var aAddPatch = this.collectActiveElementsForSelector("." + this.CSS_CLASS.PATCH +" a." + this.CSS_CLASS.ADD);
var aRemovePatch = this.collectActiveElementsForSelector('.' + this.CSS_CLASS.PATCH + ' a.' + this.CSS_CLASS.REMOVE); var aRemovePatch = this.collectActiveElementsForSelector("." + this.CSS_CLASS.PATCH + " a." + this.CSS_CLASS.REMOVE);
submitSapeventForm({'add': aAddPatch, 'remove': aRemovePatch}, this.ACTION.PATCH_STAGE, "post"); submitSapeventForm({"add": aAddPatch, "remove": aRemovePatch}, this.ACTION.PATCH_STAGE, "post");
}; };
@ -1137,20 +1139,20 @@ function registerStagePatch(){
/********************************************************** /**********************************************************
* Page branch overview * Page branch overview
* *
* Hovering a commit node in the branch overview will show * Hovering a commit node in the branch overview will show
* a popup with the commit details. Single click on a node * a popup with the commit details. Single click on a node
* will fix the popup, so that users can select text. The * will fix the popup, so that users can select text. The
* fixation is removed when any node is hovered or the popup * fixation is removed when any node is hovered or the popup
* is closed via 'X'. * is closed via 'X'.
* *
**********************************************************/ **********************************************************/
function BranchOverview() { function BranchOverview() {
this.bFixed = false; this.bFixed = false;
this.elCurrentCommit = { this.elCurrentCommit = {
style : { style : {
display: 'none' display: "none"
} }
}; };
} }
@ -1158,19 +1160,19 @@ function BranchOverview() {
BranchOverview.prototype.toggleCommit = function(sSha1, bFixPopup) { BranchOverview.prototype.toggleCommit = function(sSha1, bFixPopup) {
// If the popup is fixed, we just remove the fixation. // If the popup is fixed, we just remove the fixation.
// The popup will then be hidden by the next call of hideCommit // The popup will then be hidden by the next call of hideCommit
if (this.bFixed) { if (this.bFixed) {
this.bFixed = false; this.bFixed = false;
return; return;
} }
// We hide the previous shown commit popup // We hide the previous shown commit popup
this.elCurrentCommit.style.display = 'none'; this.elCurrentCommit.style.display = "none";
// Display the new commit popup if sha1 is supplied // Display the new commit popup if sha1 is supplied
if (sSha1){ if (sSha1){
this.elCurrentCommit = document.getElementById(sSha1); this.elCurrentCommit = document.getElementById(sSha1);
this.elCurrentCommit.style.display = ''; this.elCurrentCommit.style.display = "";
// and fix the popup so that the next hideCommit won't hide it. // and fix the popup so that the next hideCommit won't hide it.
this.bFixed = bFixPopup; this.bFixed = bFixPopup;
@ -1190,6 +1192,6 @@ BranchOverview.prototype.showCommit = function(event){
}; };
// Called by commit:mouseout // Called by commit:mouseout
BranchOverview.prototype.hideCommit = function (event){ BranchOverview.prototype.hideCommit = function (event){ // eslint-disable-line no-unused-vars
this.toggleCommit(); this.toggleCommit();
}; };