forked from meltano/meltano
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Fix eslint failures in CI (meltano#6815)
- Loading branch information
1 parent
640634b
commit d121d7f
Showing
84 changed files
with
2,212 additions
and
1,548 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,48 @@ | ||
const removeActiveClasses = function (ulElement) { | ||
const lis = ulElement.querySelectorAll('li'); | ||
Array.prototype.forEach.call(lis, function(li) { | ||
li.classList.remove('active'); | ||
}); | ||
} | ||
|
||
const getChildPosition = function (element) { | ||
var parent = element.parentNode; | ||
var i = 0; | ||
for (var i = 0; i < parent.children.length; i++) { | ||
if (parent.children[i] === element) { | ||
return i; | ||
} | ||
} | ||
const lis = ulElement.querySelectorAll('li'); | ||
Array.prototype.forEach.call(lis, function (li) { | ||
li.classList.remove('active'); | ||
}); | ||
}; | ||
|
||
throw new Error('No parent found'); | ||
const getChildPosition = function (element) { | ||
let parent = element.parentNode; | ||
for (let i = 0; i < parent.children.length; i++) { | ||
if (parent.children[i] === element) { | ||
return i; | ||
} | ||
} | ||
|
||
throw new Error('No parent found'); | ||
}; | ||
|
||
window.addEventListener('load', function () { | ||
const tabLinks = document.querySelectorAll('ul.tab li a'); | ||
const tabLinks = document.querySelectorAll('ul.tab li a'); | ||
|
||
Array.prototype.forEach.call(tabLinks, function(link) { | ||
link.addEventListener('click', function (event) { | ||
Array.prototype.forEach.call(tabLinks, function (link) { | ||
link.addEventListener( | ||
'click', | ||
function (event) { | ||
event.preventDefault(); | ||
|
||
liTab = link.parentNode; | ||
ulTab = liTab.parentNode; | ||
position = getChildPosition(liTab); | ||
let liTab = link.parentNode; | ||
let ulTab = liTab.parentNode; | ||
let position = getChildPosition(liTab); | ||
if (liTab.className.includes('active')) { | ||
return; | ||
} | ||
|
||
removeActiveClasses(ulTab); | ||
tabContentId = ulTab.getAttribute('data-tab'); | ||
tabContentElement = document.getElementById(tabContentId); | ||
let tabContentId = ulTab.getAttribute('data-tab'); | ||
let tabContentElement = document.getElementById(tabContentId); | ||
removeActiveClasses(tabContentElement); | ||
|
||
tabContentElement.querySelectorAll('li')[position].classList.add('active'); | ||
tabContentElement | ||
.querySelectorAll('li') | ||
[position].classList.add('active'); | ||
liTab.classList.add('active'); | ||
}, false); | ||
}); | ||
}, | ||
false | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,121 +1,119 @@ | ||
document.querySelectorAll(".use-termynal").forEach(node => { | ||
node.style.display = "block"; | ||
new Termynal(node, { | ||
lineDelay: 500 | ||
}); | ||
document.querySelectorAll('.use-termynal').forEach((node) => { | ||
node.style.display = 'block'; | ||
// eslint-disable-next-line no-undef | ||
new Termynal(node, { | ||
lineDelay: 500, | ||
}); | ||
}); | ||
const progressLiteralStart = "---> 100%"; | ||
const promptLiteralStart = "$ "; | ||
const customPromptLiteralStart = "# "; | ||
const termynalActivateClass = "termy"; | ||
const codeThingy = "```" | ||
const waitStart = "<---" | ||
const progressLiteralStart = '---> 100%'; | ||
const promptLiteralStart = '$ '; | ||
const customPromptLiteralStart = '# '; | ||
const termynalActivateClass = 'termy'; | ||
const codeThingy = '```'; | ||
const waitStart = '<---'; | ||
|
||
let termynals = []; | ||
|
||
function createTermynals() { | ||
document | ||
.querySelectorAll(`.${termynalActivateClass}`) | ||
.forEach(node => { | ||
const text = node.textContent; | ||
const lines = text.split("\n"); | ||
const useLines = []; | ||
let buffer = []; | ||
function saveBuffer() { | ||
if (buffer.length) { | ||
let isBlankSpace = true; | ||
buffer.forEach(line => { | ||
if (line) { | ||
isBlankSpace = false; | ||
} | ||
}); | ||
dataValue = {}; | ||
if (isBlankSpace) { | ||
dataValue["delay"] = 0; | ||
} | ||
if (buffer[buffer.length - 1] === "") { | ||
// A last single <br> won't have effect | ||
// so put an additional one | ||
buffer.push(""); | ||
} | ||
const bufferValue = buffer.join("<br>"); | ||
dataValue["value"] = bufferValue; | ||
useLines.push(dataValue); | ||
buffer = []; | ||
} | ||
} | ||
for (let line of lines) { | ||
if (line === progressLiteralStart) { | ||
saveBuffer(); | ||
useLines.push({ | ||
type: "progress" | ||
}); | ||
} else if (line.startsWith(promptLiteralStart)) { | ||
saveBuffer(); | ||
const value = line.replace(promptLiteralStart, "").trimEnd(); | ||
useLines.push({ | ||
type: "input", | ||
value: value | ||
}); | ||
} else if (line.startsWith("// ")) { | ||
saveBuffer(); | ||
const value = "💬 " + line.replace("// ", "").trimEnd(); | ||
useLines.push({ | ||
value: value, | ||
class: "termynal-comment", | ||
delay: 0 | ||
}); | ||
|
||
} else if (line == waitStart) { | ||
saveBuffer(); | ||
useLines.push({ | ||
type: "wait", | ||
delay: 1, | ||
value: "<br />" | ||
|
||
}); | ||
|
||
} else if (line.startsWith(customPromptLiteralStart)) { | ||
saveBuffer(); | ||
const promptStart = line.indexOf(promptLiteralStart); | ||
if (promptStart === -1) { | ||
console.error("Custom prompt found but no end delimiter", line) | ||
} | ||
const prompt = line.slice(0, promptStart).replace(customPromptLiteralStart, "") | ||
let value = line.slice(promptStart + promptLiteralStart.length); | ||
useLines.push({ | ||
type: "input", | ||
value: value, | ||
prompt: prompt | ||
}); | ||
} else if (line.startsWith(codeThingy)) { | ||
saveBuffer(); | ||
} | ||
else { | ||
buffer.push(line); | ||
} | ||
} | ||
saveBuffer(); | ||
const div = document.createElement("div"); | ||
node.replaceWith(div); | ||
const termynal = new Termynal(div, { | ||
lineData: useLines, | ||
noInit: true, | ||
lineDelay: 500 | ||
}); | ||
termynals.push(termynal); | ||
document.querySelectorAll(`.${termynalActivateClass}`).forEach((node) => { | ||
const text = node.textContent; | ||
const lines = text.split('\n'); | ||
const useLines = []; | ||
let buffer = []; | ||
function saveBuffer() { | ||
if (buffer.length) { | ||
let isBlankSpace = true; | ||
buffer.forEach((line) => { | ||
if (line) { | ||
isBlankSpace = false; | ||
} | ||
}); | ||
let dataValue = {}; | ||
if (isBlankSpace) { | ||
dataValue['delay'] = 0; | ||
} | ||
if (buffer[buffer.length - 1] === '') { | ||
// A last single <br> won't have effect | ||
// so put an additional one | ||
buffer.push(''); | ||
} | ||
const bufferValue = buffer.join('<br>'); | ||
dataValue['value'] = bufferValue; | ||
useLines.push(dataValue); | ||
buffer = []; | ||
} | ||
} | ||
for (let line of lines) { | ||
if (line === progressLiteralStart) { | ||
saveBuffer(); | ||
useLines.push({ | ||
type: 'progress', | ||
}); | ||
} else if (line.startsWith(promptLiteralStart)) { | ||
saveBuffer(); | ||
const value = line.replace(promptLiteralStart, '').trimEnd(); | ||
useLines.push({ | ||
type: 'input', | ||
value: value, | ||
}); | ||
} else if (line.startsWith('// ')) { | ||
saveBuffer(); | ||
const value = '💬 ' + line.replace('// ', '').trimEnd(); | ||
useLines.push({ | ||
value: value, | ||
class: 'termynal-comment', | ||
delay: 0, | ||
}); | ||
} else if (line == waitStart) { | ||
saveBuffer(); | ||
useLines.push({ | ||
type: 'wait', | ||
delay: 1, | ||
value: '<br />', | ||
}); | ||
} else if (line.startsWith(customPromptLiteralStart)) { | ||
saveBuffer(); | ||
const promptStart = line.indexOf(promptLiteralStart); | ||
if (promptStart === -1) { | ||
console.error('Custom prompt found but no end delimiter', line); | ||
} | ||
const prompt = line | ||
.slice(0, promptStart) | ||
.replace(customPromptLiteralStart, ''); | ||
let value = line.slice(promptStart + promptLiteralStart.length); | ||
useLines.push({ | ||
type: 'input', | ||
value: value, | ||
prompt: prompt, | ||
}); | ||
} else if (line.startsWith(codeThingy)) { | ||
saveBuffer(); | ||
} else { | ||
buffer.push(line); | ||
} | ||
} | ||
saveBuffer(); | ||
const div = document.createElement('div'); | ||
node.replaceWith(div); | ||
// eslint-disable-next-line no-undef | ||
const termynal = new Termynal(div, { | ||
lineData: useLines, | ||
noInit: true, | ||
lineDelay: 500, | ||
}); | ||
termynals.push(termynal); | ||
}); | ||
} | ||
|
||
function loadVisibleTermynals() { | ||
termynals = termynals.filter(termynal => { | ||
if (termynal.container.getBoundingClientRect().top - innerHeight <= 0) { | ||
termynal.init(); | ||
return false; | ||
} | ||
return true; | ||
}); | ||
termynals = termynals.filter((termynal) => { | ||
if (termynal.container.getBoundingClientRect().top - innerHeight <= 0) { | ||
termynal.init(); | ||
return false; | ||
} | ||
return true; | ||
}); | ||
} | ||
window.addEventListener("scroll", loadVisibleTermynals); | ||
window.addEventListener('scroll', loadVisibleTermynals); | ||
createTermynals(); | ||
loadVisibleTermynals(); |
Oops, something went wrong.