automated terminal push
This commit is contained in:
86
docs/assets/js/modal-popup.js
Executable file
86
docs/assets/js/modal-popup.js
Executable file
@@ -0,0 +1,86 @@
|
||||
gitbook.events.bind("page.change", function() {
|
||||
let doc = $('section.markdown-section');
|
||||
let modalContent = $(`
|
||||
<span id="modal" class="modal-background">
|
||||
<p class="modal-content">
|
||||
<span id="close-btn" class="close">×</span>
|
||||
<span class="modal-title">Learn Programming<br> and Start a Tech Job!</span>
|
||||
<span class="button-wrapper">
|
||||
<a target="_blank" href="https://learn.softuni.org/catalog?utm_source=Python&utm_medium=pop+up&utm_campaign=free+programming+books">Enroll Now</a>
|
||||
</span>
|
||||
<span class="upper-text">
|
||||
<span><b>Begin</b> your <b>IT career</b> with a <b>our online training programs</b> for <b>Java</b> and <b>JavaScript</b>.
|
||||
Learn <b>coding</b>, <b>data structures</b>, <b>object-oriented programming</b>, <b>databases</b>, <b>back-end</b>,
|
||||
<b>Web</b>, <b>RESTful APIs</b>, <b>front-end</b>, <b>MySQL</b>, <b>Hibernate</b>, <b>Spring</b>, <b>Node.js</b>, <b>Angular</b>
|
||||
and <b>React</b>.
|
||||
Study in your own <b>time</b> and <b>own pace</b>.</span>
|
||||
</span>
|
||||
<span class="middle-text">
|
||||
<span class="middle-text-title">You can <b>succeed</b> even if you are:</span>
|
||||
<span>✅ <b>Novice</b> - no prior programming knowledge is needed.</span>
|
||||
<span>✅ <b>Working</b> - keep your other commitments and still succeed.</span>
|
||||
<span>✅ <b>Busy</b> - spend 2-3 hours per day and become a skilled programmer.</span>
|
||||
<span>✅ <b>Insecure</b> - get career advise and land your dream job.</span>
|
||||
</span>
|
||||
<span class="lower-text">
|
||||
<span>Learn <b>programming</b>: from zero to your first IT job! <b>Start</b> now!</span>
|
||||
</span>
|
||||
</p>
|
||||
</span>
|
||||
`);
|
||||
doc.prepend(modalContent);
|
||||
|
||||
let modalPopupElement = document.getElementById("modal");
|
||||
let bookBodyElement = document.querySelector("div.book-body");
|
||||
let oldBookBodyLeft = "0";
|
||||
let oldBookBodyCSSTransform = "none";
|
||||
let bookSummaryElement = document.querySelector("div.book-summary");
|
||||
let oldBookSummaryLeft = "0";
|
||||
|
||||
function showPopup() {
|
||||
modalPopupElement.style.display = "block";
|
||||
|
||||
// Switch off 'CSS transform' for the book body (it breaks the modal popup)
|
||||
oldBookBodyCSSTransform = bookBodyElement.style.transform;
|
||||
bookBodyElement.style.transform = "none";
|
||||
bookBodyElement.style.webkitTransform = "none";
|
||||
bookBodyElement.style.MozTransform = "none";
|
||||
|
||||
// Hide the 'book summary' tab
|
||||
oldBookSummaryLeft = bookSummaryElement.style.left;
|
||||
bookSummaryElement.style.left = "-100%";
|
||||
|
||||
// Arrange the book body on the left
|
||||
oldBookBodyLeft = bookBodyElement.style.left;
|
||||
bookBodyElement.style.left = "0";
|
||||
}
|
||||
|
||||
function hidePopup() {
|
||||
modalPopupElement.style.display = "none";
|
||||
|
||||
// Restore 'CSS transform' for the book body (to its previous state before the popup)
|
||||
bookBodyElement.style.transform = oldBookBodyCSSTransform;
|
||||
bookBodyElement.style.webkitTransform = oldBookBodyCSSTransform;
|
||||
bookBodyElement.style.MozTransform = oldBookBodyCSSTransform;
|
||||
|
||||
// Restore the 'book summary' tab (to its previous state before the popup)
|
||||
bookSummaryElement.style.left = oldBookSummaryLeft;
|
||||
|
||||
// Restore the book body position (to its previous state before the popup)
|
||||
bookBodyElement.style.left = oldBookBodyLeft;
|
||||
}
|
||||
|
||||
// Wait some time and display the modal popup
|
||||
setTimeout(showPopup, 10000);
|
||||
|
||||
// Close button --> hide the modal popup
|
||||
let button = document.getElementById("close-btn");
|
||||
button.onclick = hidePopup;
|
||||
|
||||
// Global click --> hide the modal popup
|
||||
window.onclick = function(event) {
|
||||
if (event.target == modalPopupElement) {
|
||||
hidePopup();
|
||||
}
|
||||
}
|
||||
});
|
||||
34
docs/assets/js/repl.it-code-runner.js
Executable file
34
docs/assets/js/repl.it-code-runner.js
Executable file
@@ -0,0 +1,34 @@
|
||||
gitbook.events.bind("page.change", function() {
|
||||
let runCodeLinks = $("p:contains('тествате примера онлайн:') a");
|
||||
for (let link of runCodeLinks) {
|
||||
if (typeof(link.href) == "string" && link.href.startsWith("https://repl.it/")) {
|
||||
// A repl.it link is found --> check for code box above it
|
||||
let codeBox = $(link).parent().prev();
|
||||
if (codeBox.is("pre")) {
|
||||
// A code box is found just before the code link --> inject the [Run] button
|
||||
let runButton = $("<a href='#' class='run-code-button' style='float:right'>Run</a>");
|
||||
let loadingBox = $("<span class='run-code-loading' style='float:right;display:none'>Loading …</span>");
|
||||
runButton.click(function() {
|
||||
// Replace the code box with the embedded REPL box
|
||||
loadingBox.show();
|
||||
let replBox = $('<iframe height="500px" width="100%" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>');
|
||||
replBox.attr("src", link.href + "?lite=true");
|
||||
replBox.on("load", function(event) {
|
||||
loadingBox.hide();
|
||||
});
|
||||
if (codeBox.next().is("iframe")) {
|
||||
// We have already the iframe with the Repl.it -> first remove it
|
||||
codeBox.next().remove();
|
||||
}
|
||||
codeBox.after(replBox);
|
||||
return false;
|
||||
});
|
||||
codeBox.prepend(runButton);
|
||||
codeBox.prepend(loadingBox);
|
||||
|
||||
// Delete the original REPL hyperlink from the DOM
|
||||
$(link).parent().remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
12
docs/assets/js/top-menu.js
Executable file
12
docs/assets/js/top-menu.js
Executable file
@@ -0,0 +1,12 @@
|
||||
gitbook.events.bind("page.change", function() {
|
||||
let doc = $('section.markdown-section');
|
||||
let topMenu = $(`
|
||||
<p class="topnav">
|
||||
<a class="logobox" target="_blank" href="https://softuni.org/learn/?utm_source=Python&utm_medium=logo&utm_campaign=free+programming+books"><img class="logo" src="/assets/softuni-global-logo.svg" alt="logo"></a>
|
||||
<a target="_blank" href="https://learn.softuni.org/catalog?utm_source=Python&utm_medium=top+menu&utm_campaign=free+programming+books">Learn Programming</a>
|
||||
<a target="_blank" href="https://www.youtube.com/c/CodeWithNakov">YouTube Channel</a>
|
||||
<a target="_blank" href="https://introprogramming.info">Nakov's Books</a>
|
||||
</p>
|
||||
`);
|
||||
doc.prepend(topMenu);
|
||||
});
|
||||
12
docs/assets/js/video.js
Executable file
12
docs/assets/js/video.js
Executable file
@@ -0,0 +1,12 @@
|
||||
gitbook.events.bind("page.change", function() {
|
||||
let videos = $(".video-player");
|
||||
for (let video of videos) {
|
||||
let videoText = video.innerText;
|
||||
let regex = /watch\?v=([a-zA-Z0-9_-]+)?/g;
|
||||
let matches = regex.exec(videoText) || [''];
|
||||
let videoId = matches[1];
|
||||
let iframe = "<iframe src='https://www.youtube.com/embed/" +
|
||||
videoId + "' frameborder='0' allowfullscreen>";
|
||||
$(video).html(iframe);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user