Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

73 lines (65 sloc) 2.547 kb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Script.JS Example</title>
<script src="../script.js" type="text/javascript"></script>
</head>
<body>
<h1>Script.JS Gists & Pasties Example</h1>
<script type="text/javascript">
var removeEmbedStyleLink = function(writes) {
var gist = this.src.indexOf('gist.github.com') != -1; // or pastie
var linksCount = gist ? 1 : 2; // pastie has clean.css besides embed.css
if ( writes ) { // defered - writes contains all document.writes
var i = -1;
while ( writes[++i] && linksCount ) {
var str = writes[i].replace(/^\s*/, "");
str = str.substring(0, 5).toLowerCase();
if (str == '<link') { writes[i] = ''; linksCount--; }
}
}
else { // loaded in-place - links are already in the DOM
var removeSiblingLink = function($elem) {
while ($elem && $elem.nodeName.toLowerCase() != 'link') {
$elem = $elem.nextSibling;
}
if ( $elem ) $elem.parentNode.removeChild($elem);
}
var startNode = this.nextSibling;
if ( ! gist ) {
while (startNode.className != 'pastie') {
startNode = startNode.nextSibling;
}
}
for ( var i=0; i<linksCount; i++ ) {
removeSiblingLink(gist ? startNode : startNode.firstChild);
}
}
};
function randomPastie() {
var base = 'http://pastie.org/';
var pasties = '2 11 42'.split(' ');
return base + pasties[ Math.floor(Math.random() * pasties.length) ] + '.js';
}
function randomGist() {
var base = 'http://gist.github.com/';
var gists = '895944 911210 919069 646529 310321'.split(' ');
return base + gists[ Math.floor(Math.random() * gists.length) ] + '.js';
}
</script>
<button onclick="script( { src: randomGist(), loaded: removeEmbedStyleLink } );">
Add a GIST (remove style)
</button>
<button onclick="script( { src: randomPastie(), loaded: removeEmbedStyleLink } );">
Add a PASTIE (remove style)
</button>
<button onclick="script( randomGist() );">
Add a GIST (with style)
</button>
<button onclick="script( randomPastie() );">
Add a PASTIE (with style)
</button>
<br/><br/>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.