Skip to content

Instantly share code, notes, and snippets.

@nowhereman
Forked from balupton/bookmark-helper.js
Created July 23, 2011 08:34
Show Gist options
  • Save nowhereman/1101191 to your computer and use it in GitHub Desktop.
Save nowhereman/1101191 to your computer and use it in GitHub Desktop.
History.js It! A bookmark for trialing History.js on your own website.

ScreenCast

See it in action here: http://vimeo.com/22396598

Usage

  1. Click the raw link for the bookmark.js file, and copy the contents into your clipboard: ctrl+a, ctrl+c for windows or cmd+a, cmd+c for mac
  2. Right click your browsers bookmark bar and select add new page, for the title use History.js It! for the url press ctrl+v for windows or cmd+v for mac

Notes

It loads in all History.js dependencies and History.js if it needs to, then it loads in the gist https://gist.github.com/854622 - if it doesn't work, evaluate that gist

Todo

  1. Support forms
  2. Support sub-pages
(function(window,undefined){
// Load Helpers
var
intervalScript, intervalJquery,
loadScript = function(scriptUrl){
var e = document.createElement('script');
e.setAttribute('src',scriptUrl);
window.document.body.appendChild(e);
return e;
};
// Load In Basic Dependencies
if ( typeof window.jQuery === 'undefined' || /^1\.[0-3]/.test(window.jQuery.fn.jquery) ) {
loadScript('https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js');
}
if ( typeof window.JSON === 'undefined' ) {
loadScript('https://raw.github.com/balupton/history.js/master/scripts/compressed/json2.js');
}
if ( typeof window.amplify === 'undefined' ) {
loadScript.apply(window,['https://raw.github.com/balupton/history.js/master/scripts/compressed/amplify.store.js']);
}
// Load In Advanced Dependencies
intervalJquery = setInterval(function(){
if ( typeof window.jQuery !== 'undefined' ) {
clearInterval(intervalJquery);
loadScript('https://raw.github.com/balupton/history.js/master/scripts/compressed/history.adapter.jquery.js');
loadScript('https://raw.github.com/balupton/history.js/master/scripts/compressed/history.js');
loadScript('https://raw.github.com/balupton/history.js/master/scripts/compressed/history.html4.js');
loadScript('https://raw.github.com/balupton/jquery-scrollto/master/scripts/jquery.scrollto.min.js');
}
},500);
// Load In Script
intervalScript = setInterval(function(){
if ( typeof window.jQuery !== 'undefined' && typeof window.JSON !== 'undefined' && typeof window.amplify !== 'undefined' && typeof window.History !== 'undefined' && typeof window.History.initHtml4 !== 'undefined' ) {
if ( window.console ) {
window.console.log('Loading in script');
}
$(loadScript('https://raw.github.com/gist/854622/ajaxify-html5.js')).bind('load',function(){
if ( typeof window.historyjsitNoAlert === 'undefined' ) {
alert('History.js It! Is ready for action!');
}
});
clearInterval(intervalScript);
}
else if ( window.console ) {
window.console.log('Waiting for dependencies to load');
}
},500);
})(window);
javascript:var%20e=document.createElement('script');e.setAttribute('src','https://raw.github.com/gist/1101191/bookmark-helper.js');document.body.appendChild(e);void(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment