Skip to content

Instantly share code, notes, and snippets.

@plcosta
Created April 14, 2013 20:44
Show Gist options
  • Save plcosta/5384132 to your computer and use it in GitHub Desktop.
Save plcosta/5384132 to your computer and use it in GitHub Desktop.
var count = 0;
var __actionMessage = false;
function atualizaLoad() {
var elem = $( "loadCenterContent" );
if (count == 0) {
$( "loadCenter" ).removeClassName( "loadCenterMaior" );
$( "loadCenter" ).addClassName( "loadCenter" );
elem.innerHTML = "Carregando";
}
count++;
if (count == 10) {
$( "loadCenter" ).removeClassName( "loadCenter" );
$( "loadCenter" ).addClassName( "loadCenterMaior" );
elem.innerHTML = "Ainda Carregando";
}
if (elem.innerHTML.indexOf( "....." ) != -1) {
if (count >= 10) {
$( "loadCenter" ).removeClassName( "loadCenter" );
$( "loadCenter" ).addClassName( "loadCenterMaior" );
elem.innerHTML = "Ainda Carregando";
} else {
$( "loadCenter" ).removeClassName( "loadCenterMaior" );
$( "loadCenter" ).addClassName( "loadCenter" );
elem.innerHTML = "Carregando";
}
}
elem.innerHTML = elem.innerHTML + ".";
}
function load(start) {
if (start) {
document.body.addClassName( 'waiting' );
if (!__actionMessage) {
$( "loading" ).show();
}
try {
executer.stop();
} catch (e) {
}
executer = new PeriodicalExecuter( atualizaLoad, 0.5 );
} else {
document.body.removeClassName( 'waiting' );
try {
executer.stop();
} catch (e) {
}
count = 0;
if (!__actionMessage) {
$( "loading" ).hide();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment