_p_
var myApp = myApp || { }; // top-level namespace
myApp.bdg = {
'bdg_1' : 0 // 0 = class="badge badge-success" 1 = class="bg-danger"
, 'bdg_2' : 0
, 'bdg_3' : 0
, 'bdg_4' : 0
}
var change_badge = function(){
if (myApp.bdg.bdg_1 == 0){
myApp.bdg.bdg_1 = 1;
$(document.getElementById('bdg_1'))
.removeClass('badge badge-success')
.addClass('badge badge-danger');
}
else {
myApp.bdg.bdg_1 = 0;
$(document.getElementById('bdg_1'))
.removeClass('badge badge-danger')
.addClass('badge badge-success');
}
}
/* * * * * * * * * * * * * * * *
* engine
* * * * * * * * * * * * * * * */
myApp.engine = function(){
"use strict";
var tick = 50;
var limit = 16;
var c = 0;
var run = 1;
var heart = function(){
if (c == 0){
document.getElementById('place').innerHTML = " "; //!!  
}
else if (c == 3){
document.getElementById('place').innerHTML = "A";
}
else if (c == 9){
document.getElementById('place').innerHTML = "A B";
}
else if (c == 12){
document.getElementById('place').innerHTML = "A B D";
}
if (c < limit) {
c++;
}
else {
c = 0;
change_badge();
}
if (run == 1){
setTimeout(heart, tick);
}
} //EndOf var heart = function(){
this.start = function(){
run = 1;
heart();
}
}//EndOf myApp.engine = function(){
$(function() { //start when DOM ready
document.getElementById('place').innerHTML = " "; //!! &nbsp;
var E = new myApp.engine();
E.start();
}) //EndOf start when DOM ready