Created
April 21, 2013 14:52
-
-
Save juristr/5429879 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function CursorBlink(blinkregion, rate, cursorCh, window){ | |
this.blinkRegionId = blinkregion; | |
this.blinkrate = rate; | |
this.cursorChar = cursorCh; | |
this.window = window; | |
} | |
CursorBlink.prototype.getBlinkRegionId = function(){ | |
return this.blinkRegionId; | |
} | |
CursorBlink.prototype.setBlinkRegionId = function(value){ | |
this.blinkRegionId = value; | |
} | |
CursorBlink.prototype.getBlinkrate = function(){ | |
return this.blinkrate; | |
} | |
CursorBlink.prototype.setBlinkrate = function(value){ | |
this.blinkrate = value; | |
} | |
CursorBlink.prototype.getCursorChar = function(){ | |
return this.cursorChar; | |
} | |
CursorBlink.prototype.setCursorChar = function(value){ | |
this.cursorChar = value; | |
} | |
CursorBlink.prototype.doBlink = function(){ | |
var cursorEl = document.getElementById(this.blinkRegionId); | |
if(cursorEl != null){ | |
try{ | |
if(cursorEl.innerHTML == this.cursorChar) | |
cursorEl.innerHTML = ""; | |
else | |
cursorEl.innerHTML = this.cursorChar; | |
}catch(e){ | |
//do nothing, this is just for IE not working on 'innerHTML' prop | |
} | |
} | |
} | |
CursorBlink.prototype.write = function(containerId, msg){ | |
var container = document.getElementById(this.blinkRegionId); | |
var chars = msg.split(" "); | |
var i=0; | |
if(container != null){ | |
this.window.setInterval(function(){ | |
container.innerHTML = container.innerHTML + " " + chars[i]; | |
i = i+1; | |
}, 200); | |
} | |
} | |
CursorBlink.prototype.stopBlinking = function(){ | |
this.timer = null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment