Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New createCodeSnippet2 function in codedoc.js #1370

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions packages/geoview-core/public/templates/codedoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,28 @@ function createCodeSnippet() {
}
}

function createCodeSnippetUsingIDs() {
// Enhanced code snippet generator which allows to associate a script id with a code snippet script (og function is using indexes)
// and write down different code snippet spreaded in the dom tree (og function always reuses 'script' variable which is the last script tag found in the dom)
// Get all scripts on page which has an id
const scripts = Array.prototype.filter.call(document.getElementsByTagName('script'), (obj) => {
return obj.getAttribute('id') !== null;
});

// Loop on each script
for (let i = 0; i < scripts.length; i++) {
// Try to find a codeSnippet flag interested in that script
const script = scripts[i];
const el = document.getElementById(`${script.id}CS`);
if (el !== null) {
el.innerHTML = `<pre>${script.textContent
.replace('//create snippets\n', '')
.replace('createConfigSnippet();\n', '')
.replace('createCodeSnippet();\n', '')}</pre>`;
}
}
}

function createConfigSnippet() {
let j = 0;
// inject configuration snippet inside panel
Expand Down
Loading