deecode
by Oliver Kelso
HTML
<span id="deecode"> </span>
CSS
html, body{
background:#111;
color:#5FED68;
font-family:helvetica;
font-size:12px;
}
#deecode{
}
JavaScript
! function($){
"use strict";
var Deecode = function(el, options) {
// chosen element to manipulate text
this.el = $(el);
// options
this.options = $.extend({}, $.fn.typed.defaults, options);
// attribute to type into
this.isInput = this.el.is('input');
this.attr = this.options.attr;
// text content of element
this.elContent = this.attr ? this.el.attr(this.attr) : this.el.text()
// decode speed
this.decodeSpeed = this.options.decodeSpeed;
// add a delay before typing starts
this.startDelay = this.options.startDelay;
// char speed
this.charSpeed = this.options.charSpeed;
// decode direction
this.direction = this.options.direction;
// amount of time to wait before backspacing
this.backDelay = this.options.backDelay;
// character number position of current string
this.strPos = 0;
// current array position
this.arrayPos = 0;
// number to stop backspacing on.
// default 0, can change depending on how many chars
// you want to remove at the time
this.stopNum = 0;
// Looping logic
this.loop = this.options.loop;
this.loopCount = this.options.loopCount;
this.curLoop = 0;
// for stopping
this.stop = false;
// All systems go!
this.build();
};
Deecode.prototype = {
constructor: Deecode
,
init: function() {
// begin the loop w/ first current string (global self.string)
// current string will be passed as an argument each time after this
var self = this;
self.timeout = setTimeout(function() {
// Start typing
self.typewrite(self.strings[self.arrayPos], self.strPos);
}, self.startDelay);
}
}
...