Skip to content

Instantly share code, notes, and snippets.

@entomb
Created November 8, 2013 18:12
Show Gist options
  • Save entomb/7375162 to your computer and use it in GitHub Desktop.
Save entomb/7375162 to your computer and use it in GitHub Desktop.
Cute loading icon for the title bar.
var cuteLoading = (function(){
//var sequence = "◑ ◓ ◐ ◒";
//var sequence = "◢ ◣ ◤ ◥";
//var sequence = "▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ▇ ▆ ▅ ▄ ▃ ▂ ▁";
var sequence = "✴ ✷ ✶ ✸ ✹ ✺ ❁ ❂ ❁ ✺ ✹ ✶ ✷ ✴";
var cacheTitle;
var _timeout;
function startLoading(){
if(_timeout) return this;
cacheTitle = window.document.title;
var index = 0;
var frames = sequence.split(" ");
_timeout = setInterval(function(){
index++;
if(index==frames.length){
index = 0;
}
window.document.title = frames[index] + " " + cacheTitle;
},100);
return this;
}
function stopLoading(){
if(!_timeout) return this;
clearTimeout(_timeout);
_timeout = null;
window.document.title = cacheTitle;
return this;
}
function setSequence(i){
sequence = i;
return this;
}
return {
sequence: setSequence,
start:startLoading,
stop:stopLoading,
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment