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

Update strapdown.js to support custom squirts and copyrights using the <squirt> and <copyright> tags in <head>. #11

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
37 changes: 25 additions & 12 deletions strapdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,18 +459,31 @@ var PR=win['PR']={'createSimpleLexer':createSimpleLexer,'registerLangHandler':re
newNode.className = "navbar navbar-fixed-top";
}
if (!navbarEl && titleEl) {
newNode.innerHTML = '<div class="navbar-inner"> <div class="container"> <div id="headline" class="brand"> </div> '
+ '<div id="headline-copyrights" class="brand">('
+ '<a title="http://lbo.k.vu/md" href="//lbesson.bitbucket.io/md/index.html?src=strapdown.js">StrapDown.js</a> v0.8, '
+ 'theme <a title="More information on this theme on bootswatch.com!" href="http://bootswatch.com/'+theme+'">'+theme+'</a>, '
+ 'thanks to <a href="https://bitbucket.org/">BitBucket</a>)</div> '
+ '<div id="headline-squirt" class="brand"> <a title="Quick reader script! Check //lbesson.bitbucket.io/squirt/ for more details" '
+ 'href="javascript:(function(){sq=window.sq;if(sq&&sq.closed){window.sq.closed&&window.document.dispatchEvent(new Event(\'squirt.again\'));}else{sq=window.sq||{};sq.version=\'0.4\';sq.host=\'//lbesson.bitbucket.io/squirt\';sq.j=document.createElement(\'script\');sq.j.src=sq.host+\'/squirt.js?src=strapdown.js\';document.body.appendChild(sq.j);}})();" '
+ '>SquirtFR?</a>'
// var scriptElMathJax = document.createElement(\'script\'); scriptElMathJax.type = \'text/x-mathjax-config\'; scriptElMathJax.innerHTML = \'MathJax.Hub.Config({ tex2jax: { inlineMath: [[\\\'$\\\',\\\'$\\\']], displayMath: [ [\\\'$$\\\',\\\'$$\\\'] ], processEscapes: false } });\'; document.body.appendChild(scriptElMathJax);
+ ' <a title="Import MathJax?" href="javascript:(function(){ var scriptElMathJax = document.createElement(\'script\'); scriptElMathJax.type = \'text/javascript\'; scriptElMathJax.src = \'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML&amp;locale=fr\'; document.head.appendChild(scriptElMathJax); })();" >MathJax?</a>'
+ ' <a title="Fetch a beacon image?" href="javascript:(function(){ var linkEl = document.createElement(\'img\'); linkEl.alt = \'GA|Analytics\'; linkEl.style = \'visibility: hidden; display: none;\'; linkEl.src = \'https://perso.crans.org/besson/beacon/14/navbar/strapdown.js?pixel\'; document.body.appendChild(linkEl); })();">Beacon?</a>' // https://ga-beacon.appspot.com/UA-38514290-14/
+ '</div> </div> </div>';
var squirts = document.getElementsByTagName("squirt");
var squirt = '<a title="Quick reader script! Check //lbesson.bitbucket.io/squirt/ for more details" '
+ 'href="javascript:(function(){sq=window.sq;if(sq&&sq.closed){window.sq.closed&&window.document.dispatchEvent(new Event(\'squirt.again\'));}else{sq=window.sq||{};sq.version=\'0.4\';sq.host=\'//lbesson.bitbucket.io/squirt\';sq.j=document.createElement(\'script\');sq.j.src=sq.host+\'/squirt.js?src=strapdown.js\';document.body.appendChild(sq.j);}})();" '
+ '>SquirtFR?</a>'
// var scriptElMathJax = document.createElement(\'script\'); scriptElMathJax.type = \'text/x-mathjax-config\'; scriptElMathJax.innerHTML = \'MathJax.Hub.Config({ tex2jax: { inlineMath: [[\\\'$\\\',\\\'$\\\']], displayMath: [ [\\\'$$\\\',\\\'$$\\\'] ], processEscapes: false } });\'; document.body.appendChild(scriptElMathJax);
+ ' <a title="Import MathJax?" href="javascript:(function(){ var scriptElMathJax = document.createElement(\'script\'); scriptElMathJax.type = \'text/javascript\'; scriptElMathJax.src = \'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML&amp;locale=fr\'; document.head.appendChild(scriptElMathJax); })();" >MathJax?</a>'
+ ' <a title="Fetch a beacon image?" href="javascript:(function(){ var linkEl = document.createElement(\'img\'); linkEl.alt = \'GA|Analytics\'; linkEl.style = \'visibility: hidden; display: none;\'; linkEl.src = \'https://perso.crans.org/besson/beacon/14/navbar/strapdown.js?pixel\'; document.body.appendChild(linkEl); })();">Beacon?</a>' // https://ga-beacon.appspot.com/UA-38514290-14/
+ '</div>';
if (squirts.length > 0) {
squirt = squirts[0].innerHTML;
for (var i = 0; i < squirts.length; i++) {
squirts[i].remove();
}
}
var copyrights = document.getElementsByTagName("copyright");
var copyright = '(<a title="http://lbo.k.vu/md" href="//lbesson.bitbucket.io/md/index.html?src=strapdown.js">StrapDown.js</a> v0.8, '
+ 'theme <a title="More information on this theme on bootswatch.com!" href="http://bootswatch.com/'+theme+'">'+theme+'</a>, '
+ 'thanks to <a href="https://bitbucket.org/">BitBucket</a>)';
if (copyrights.length > 0) {
copyright = copyrights[0].innerHTML;
for (var i = 0; i < copyrights.length; i++) {
copyrights[i].remove();
}
}
newNode.innerHTML = '<div class="navbar-inner"> <div class="container"> <div id="headline" class="brand"> </div> <div id="headline-copyrights" class="brand">' + copyright + '</div> <div id="headline-squirt" class="brand">' + squirt + '</div> </div>';
if (!(queryOrigin['nonnavbar'])) {
document.body.insertBefore(newNode, document.body.firstChild);
}
Expand Down