$(".solution>h3,.details>h3,.tip>h3,.question>h3,.hands_on>h3,.comment>h3").click(function(event) {
$(">*:not(h3)", $(this).parent()).toggle(400);
$(">span.fold-unfold", this).toggleClass("fa-plus-square fa-minus-square");
});
$("blockquote.solution>.box-title>button,blockquote.details>.box-title>button,blockquote.tip>.box-title>button,blockquote.question>.box-title>button,blockquote.hands_on>.box-title>button,blockquote.comment>.box-title>button").click(function(event) {
var button;
if(event.target.nodeName === "BUTTON"){
button = $(event.target)
} else {
button = $(event.target).parents("button");
}
var parentBlockquote = button.parents("blockquote")[0];
$(">*:not(.box-title)", parentBlockquote).toggleClass("box-collapsed");
$(">span.fold-unfold", button).toggleClass("fa-plus-square fa-minus-square");
$(this).attr("aria-expanded",
$(">span.fold-unfold", this).hasClass("fa-plus-square") ?
"false" : "true"
);
});
$(".solution>h3,.details>h3,.tip>h3").each(function() {
$(">*:not(h3)", $(this.parent)).toggle("box-collapsed");
$(this).append("<span role='button' class='fold-unfold fa fa-plus-square'></span>");
});
$("blockquote.solution,blockquote.details,blockquote.tip").each(function() {
$(">.box-title>button", this).click();
});
$("section#tutorial-content .hands_on,section#tutorial-content .hands-on").each((idx, el) => {
var box_id = $(".box-title", el).attr("id");
$(el).append(`
<p class="text-muted post-faq-box hide-when-printing" style="text-align:right;font-size:0.9rem;">
<a href="#${box_id}">Link to here</a> |
<i class="far fa-question-circle" aria-hidden="true"></i> <a href="./faqs/">FAQs</a> |
<a href="https://gitter.im/Galaxy-Training-Network/Lobby">Gitter Chat</a> |
<a href="https://help.galaxyproject.org">Help Forum</a>
</p>`
);
})
function cyoaChoice(text, cyoaId){
if(text !== undefined && text !== null){
var loc = new URL(document.location)
try {
localStorage.setItem(`${cyoaId}-${loc.pathname}`, text);
} catch(e) {
}
var inputs = document.querySelectorAll(`#${cyoaId} input`),
options = [...inputs].map(x => x.value),
nonMatchingOptions = options.filter(x => x !== text);
nonMatchingOptions.forEach(value => {
document.querySelectorAll(`.${value}`).forEach(el => el.classList.add("gtn-cyoa-hidden"));
})
document.querySelectorAll(`.${text}`).forEach(el => el.classList.remove("gtn-cyoa-hidden"));
var input_el = document.querySelector(`input[value="${text}"]`)
if(input_el) {
input_el.checked = true;
}
}
}
function cyoaDefault(defaultOption, cyoaId){
var loc = new URL(document.location)
var urlOption = loc.searchParams.get(cyoaId);
if(urlOption){
cyoaChoice(urlOption, cyoaId);
return;
}
var lsOption;
try {
lsOption = localStorage.getItem(`${cyoaId}-${loc.pathname}`);
} catch(e) {
}
if(lsOption !== null && lsOption !== undefined){
cyoaChoice(lsOption, cyoaId);
return;
}
var currentlySelected = [...document.querySelectorAll("input[name='cyoa']")].filter(x => x.checked)[0];
if(currentlySelected){
cyoaChoice(currentlySelected, cyoaId);
return;
}
cyoaChoice(defaultOption, cyoaId);
}
(function (window, document) {
function onDocumentReady(fn) {
if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading") {
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
onDocumentReady(function () {
var withAnswers = (new URL(document.location)).searchParams.get("with-answers");
if (withAnswers !== null) {
$(".solution>.box-title button,.details>.box-title button").click();
}
var expandAll = (new URL(document.location)).searchParams.get("expand-all");
if (expandAll !== null) {
$(".solution>.box-title button,.details>.box-title button,.tip>.box-title button").click();
}
if (window.location.href.indexOf("faqs") > -1) {
$(".hands_on>.box-title,.question>.box-title,.comment>.box-title").click();
}
var handsOnOnly = (new URL(document.location)).searchParams.get("only-hands-on");
if(handsOnOnly !== null) {
$(".tutorial .container .col-sm-10>:not(.hands_on)").hide()
}
});
})(window, document);
function fixDiffPresentation(codeBlock){
codeBlock.childNodes.forEach(x => {
if(x.nodeName == '#text'){
x.textContent = x.textContent.split('\n').map(q => { return q.startsWith(" ") ? q.slice(1) : q }).join('\n')
} else {
if(!(x.nodeName.toLowerCase() === 'span' && x.classList[0] === 'notranslate')){
var fixed = $(x).text().split('\n').map(q => { return q.slice(1) }).join('\n');
$(x).text(fixed);
}
}
})
}
document.querySelectorAll("article.topic-admin section#tutorial-content div.language-diff pre code").forEach(codeBlock => fixDiffPresentation(codeBlock))
document.querySelectorAll("article.topic-data-science section#tutorial-content div.language-diff pre code").forEach(codeBlock => fixDiffPresentation(codeBlock))
document.querySelectorAll('div.highlight').forEach((snippet) => {
var gtn_snippet_pres = [...snippet.childNodes].filter(x => x.tagName == "PRE")
if(gtn_snippet_pres && gtn_snippet_pres.length > 0){
gtn_snippet_pres[0].insertAdjacentHTML('beforebegin','<button class="btn btn-light" data-clipboard-snippet tabindex="0"><i class="fa fa-copy"></i> Copy</button>');
}
});
var clipboardSnippets=new ClipboardJS('[data-clipboard-snippet]',{
target:function(trigger){return trigger.nextElementSibling;
}});
document.querySelectorAll("blockquote[cite],blockquote[author]").forEach(bq => {
let bq_cite = bq.getAttribute("cite");
let bq_url = bq_cite ? `<cite class="text-muted"><a href="${bq_cite}"><i>Source</i></a></cite>` : "";
let bq_author = bq.getAttribute("author") ? "— " + bq.getAttribute("author") + " " : "";
bq.insertAdjacentHTML("beforeend", `<footer>${bq_author}${bq_url}</footer>`)
})