SCRIPTING:

Yvette Nelson
STRING FX: PASSWORD TICKER
Given an input text, the script simulates a gradual detection/deciphering of the text by showing ticking letters that settle down one by one as soon as each of them matches with the corresponding letter of the given input text.

Prints such effect either into a form text field or on a layer (by ULMA).
May 2002
{ @ }

The model above is Yvette Nelson
LOADS OF YVETTE NELSON ON THE NET


PAVLOV AND FXs
What are «special effects» for in javaScript?

«I never see the dawn than I dont say to myself perhaps»
[ John Dos Passos, Manhattan transfer ]
 
If there is something I would like, so to say, to stand against as far as javaScript is concerned, positively this would be FXs (special effects): javaScript has been confined, to some extent and by a few approaches, to a language whose misunderstood purpose is to feed a page with fancy stuff completely lacking of functionality: the tautology of all the flash paradigms triumphs wherever you have got a definitely round, absolute, thoroughgoing nothing to say and none the less you are eager to yell it to the mountains, namely filling a page with graphics whose unique reason to live is to provide themselves with the reason to be there: none.
Matisse
A gimlet in a while is fine. A night spree a week may be fine. Even a regular booze may be ok to me. But a regular booze who claims he does it because of philanthropy, this is a bit too much to my ears. When over a couple of Martinis with friends I say that
« Since nicotine is a vasoconstrictive and alcohol is a vasodilative, then get a bottle of Jack Daniel's and a packet of Marlboro, a packet of Marlboro and a bottle of Jack Daniel's, and you're headed for the perfect health balance. »
I never say this meaning it. Some folks just use flash and FXs wherever they can, but they are not joking at all when they say it is either necessary or standard compliant or (would you dare to question it?) absolutely necessary for the deep meaning the site has to convey.
It's like those job offers that, in a list of requirements so long that you wonder whether they're hiring humans or Visitors for a X-Files installment, regularly add in between C++ and VBasic "Macromedia Dreamweaver" as one of the required languages to get the job: now I use as my editor of choice Home Site, backing it up with Edit Plus, so I am a Macromedia customer actually: but I could never imagine to ask my audience that they have to know "Home Site" as if it were a programming language, in the very same way I'd never ask you that you have to use a Nokia self phone to call me: you use what you want.
FXs on the web really belong to the same pack: nonsense on the net.
 
You may wonder then, why then you are proposing exactly an FX?
Well, one reason (provided we take notice that to date you didn't find one single "FX" script featured at UnitedScripters): a good friend of mine made me a gift you see: a book of poems by some greek poet whose name is Kavafis, and whom I didn't hear of before.
I had the same problem you may have with that name, I just couldn't remember it you see, bud: we were talking with this friend about poetry and stuff, and every time I came to have to say that name, I just couldn't remember it.
Then when back home and I was alone and the dark awaited me, I started reading this poet's poems and after 2 hours I got so enthusiastic that I said to myself: this Kavafis is great!
Got it? I don't think so (I would have not!). Let me explain: all of a sudden I exclaimed his name, therefore I now remembered it. Weird, huh?
 
How did such a strange thing happen? Earlier that very same night I couldn't, now I remembered that name perfectly.
 
Well, you know: I do believe (I'm a believer!) that if you have to remember something without a feeling that gives a deeper meaning to the thing, and which makes the thing alive to your inner self and which makes the mind cooperate with the heart, well why the hack should you bother your synapses remembering? It would be like being at school with the wrinkly teacher who wants you to remember the date when the Battle of Hastings took place and then why not the hours I wonder: why should you remember a thing that nobody made you feel clearly how much is connected with your contemporary history?
It was Pavlov that in Russia made those experiments of the dogs that were given some food (and started drooling) while associating the forthcoming food with the ring of a bell: as you know, after a few days the dogs started drooling as soon as they heard a bell, no matter if there was food or not around. It is called conditioning.
 
But I bet that with the example I now provided, we can see that conditioning can surely be used to improperly affect a person, but its bedrock is based on something deeper and not improper at all: what's automatism in it may make of it a candidate to dictatorship, but what is noble in it makes of it a candidate to heavens.
You need an emotion to stimulate your intellect. After all, also Vance Packard's conclusions were that when advertisement conditions you this doesn't mean that the theories advertisement is based on or its purposes are necessarily "evil" (a conditioning that, anyway, can never be pavlovian although the whole of the current approach to commercials online is precisely based on such a certainty: that commercials online should perform pavlovian conditioning on the surfer - and for more on such entirely wrong approach to online commercials, by banners, annoying pop ups, and click me now stuff (as long as that even sillier flash and skip intro - go to the... html! stuff): this file).
 
So here is why I now indulge including also a few FXs: for if you use javaScript FXs with some wit, you can perform a few emotional effects whose purpose may well be much more relevant than just adding the FX itself: it can be the way to convey and establish an intellectual message and emotional correspondence by associating your message with an effect which exhibits some metaphoric consistence with the message thus helping memorizing it. But let me insist on this fact: do not pick FXs at random like flash scripters do: pick FXs only if they are allegorically functional to your message and you need some help to promote it: there must be an underlying allegory that connects your FX with your message, such as, say, a darkening background for those message that are meant to avoid a catastrophic event. or, for instance, just a string ticker that belongs to the allegory family of the cipher, so whatever message involves knowledge can get avail of it by finding a secret symmetry between the symbology it conjures and the intellectual contents the message carries: time to show to you an example with a sentence by the Gospels?


THE CODES
The script Ticker code, then the two snippets of codes meant the one to print the output on a form field the other to print on a layer (by using ULMA)

Here follow the codes: the first is the string ticker: it produces an array as its output whose each entry depicts one attempt to draw a string identical to the one provided as input argument: the script randomly extracts a letter from a built in alphabet (but you can even provide your own if you prefer) and compares it with the given input string: if it matches it stores it as a letter which must not change again, if it doesn't, it removes from the alphabet for the given letter the one that didn't match yet and proceeds to a next random picking of another letter in the hope this one matches.
Over time the matching input argument string is built up, and the outcome array isn't but the array that yields all the steps that have been necessary to get at this identical output: therefore -obviously- one time it may take 100 attempts, another time it may take 200: no way of predict for it makes random guesswork. The only thing you have to note is, probably, that for each attempt I remove the chance such letter could be picked again as a possible match for the current input string letter: this makes the approach more scientific, although a FX script would have not called in for such a caution.
Then after your string ticker subroutine, you have 3 more scripts. On the whole the settlement is as follows:
  1. stringTicker is the subroutine which makes the actual job yielding the array.
  2. tickerFormShowdown function: prints the array entries produced by the stringTicker on a form text field, one by one at a timeout interval.
  3. 2 functions to print the array entries produced by the stringTicker on a form text field, one by one at a timeout interval:
    1. tickerUlmaShowdown
    2. ULMAticker
    You need both of them to print on a layer, and it uses ULMA, the only approach that would allow you to manipulate more layers at once with the same effects.

function stringTicker(inputString, alphabet, alphabetIsAddOn, slower, optionalSplitter, arrayOfArraysOutput){
/*Requires gen 4 browsers: using regular expressions
and built in method slice()*/
//validate:
if(!inputString){return new Array(0)};
optionalSplitter=(optionalSplitter)?
optionalSplitter:"";
  //transform inputString into Array:
inputString=(typeof(inputString)=="string")?
inputString.split(optionalSplitter):inputString;
var preAlph=(alphabet)?alphabet:"";
preAlph=(typeof( preAlph )=="string")?preAlph:preAlph.join("");
alphabet=(alphabet && !alphabetIsAddOn &&alphabet.length)?alphabet:
'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
  //alphabet must be a String:
alphabet=(typeof(alphabet)!="string")?alphabet.join(""):alphabet;
alphabet+=(alphabetIsAddOn && preAlph)?preAlph:"";
var criticalCheck=inputString.slice(0);
  /* see whether chars in inputString are NOT present in alphabet: it's critical they are:
  if not present, it adds them! */
  for(var c=0;c<criticalCheck.length;c++){
    if(alphabet.indexOf(criticalCheck[c])==-1){
    alphabet+=criticalCheck[c];
    }
  }
//initialize:
var output=new Array(0);
var detected=new Array(inputString.length);
  //populate detected:
if(!slower){
for(var d=0;d<detected.length;d++){
detected[d]=alphabet;
}
}
//slow down?:
slower=(slower && !isNaN(parseFloat(slower)))?
parseFloat(slower):(slower)?1:0;
if(slower){//if so, make output length longer
var originalAlph=alphabet;
/*if slower higher than 1, multiplicates the alphabet*/
  for(var s=1;s<slower;s++){
  alphabet+=originalAlph;
  }
  for(var d=0;d<detected.length;d++){
  detected[d]=alphabet;
  }
/*if slower just==1, arguably an addOn alphabet was passed:
* remove from such alphabet duplicates of input char
* to make it even slower.
*/
  for(var m=0;m<detected.length;m++){
  var myReg=new RegExp();
  myReg.compile(inputString[m],"g");
  var howMany=detected[m].match(myReg);
    if(howMany && howMany>1){
    /* duplicates found: eliminate all */
    detected[m].replace(myReg,"");
    /* now put back ONE instance: */
    detected[m]+=inputString[m];
    }
  }
} //run:
while(1){
  var myTry=new Array(0);
  for(var t=0;t<inputString.length;t++){
  myTry[++myTry.length-1]=detected[t].charAt( Math.round( Math.random()* (detected[t].length-1) ) );
    var mtLength=myTry.length-1;
    if(myTry[mtLength] == inputString[mtLength]){
    detected[mtLength]=myTry[mtLength];
    }
  }
output[++output.length-1]=new Array(0);
var otpLength=output.length-1;
  //populate:
  var exit=0;
  for(var p=0;p<detected.length;p++){
    if(detected[p].length==1){
    output[otpLength][++output[otpLength].length-1] = detected[p];
    ++exit;
    }
    else{
    output[otpLength][++output[otpLength].length-1] = myTry[p];
    var out=detected[p].indexOf(myTry[p]);
      if(out>-1){
      var add=(out+1>=detected[p].length)?"":detected[p].substring(out+1, detected[p].length );
      detected[p]=detected[p].substring(0,out) + add;
      }
    }
  }
output[otpLength]=(!arrayOfArraysOutput)?
output[otpLength].join(""):output[otpLength];
if(exit==inputString.length){return output}
}
/*keep this comment to use freely
http://www.unitedscripters.com */}

/*============================*/
 
function tickerFormShowdown(array, targets, time){
if(!document.tickerShowdownTimer){
/* Requires document exists (do not call this before the BODY tag, that is)
* preferably array generated by letterTicker();
* pass the FORM targets argument without appending keyword value,
* the script appends it on its own.
*/
  if(!array){return ""};
time=(time)?parseFloat(time):120;
document.tickerShowdownArray=array;
document.tickerShowdownIndex=0;
document.tickerShowdownTarget=(typeof(targets)=="string")?
eval(targets):targets;
document.tickerShowdownTimer=setInterval("tickerFormShowdown()",time);
};
if(document.tickerShowdownIndex==document.tickerShowdownArray.length){
  document.tickerShowdownIndex=0;
  clearInterval(document.tickerShowdownTimer);
  document.tickerShowdownTimer=0;
  return;
};
document.tickerShowdownTarget.value=document.tickerShowdownArray[ document.tickerShowdownIndex++ ];
}

/*============================*/
 
function tickerUlmaShowdown(){
if(!this.isRunning){
//Requires ULMA
//must be ENABLED for the given layerManager
  if(!this.path.length){return true}
this.isRunning=1;
this.variable.layerEngaged=1;
this.preText=(this.preText)?this.preText:"";
this.postText=(this.postText)?this.postText:"";
this.currentPathIndex=(this.noIndexReset)?
this.currentPathIndex:0;
}
this.variable.layerEngaged=1;
this.variable.writeText.execute(this.preText);
this.variable.writeText.execute(this.path[ this.currentPathIndex++ ],1);
this.variable.writeText.execute(this.postText,1);
if(this.currentPathIndex==this.path.length){
this.stop();
this.isRunning=0;
return true;
}
return false}

/*============================*/
 
function ULMAticker(layerManager, tickingText, preText, postText, speed, alphabet, alphabetIsAddOn, slower, optionalSplitter, arrayOfArraysOutput, noIndexReset){
/*Requires: ULMA
* REQUIRES: stringTicker(), tickerUlmaShowdown()
* auto enables the method on the layerManager if not enabled.
*/
if(typeof(layerManager)=="string"){ layerManager=(ULMAObjects[layerManager])?
ULMAObjects[layerManager]:eval(layerManager) };
if(!layerManager.methods["tickerUlmaShowdown"]){
layerManager.enable("tickerUlmaShowdown")
};
layerManager.tickerUlmaShowdown.path=stringTicker(tickingText, alphabet, alphabetIsAddOn, slower, optionalSplitter, arrayOfArraysOutput);
layerManager.tickerUlmaShowdown.preText=(preText)?preText:"";
layerManager.tickerUlmaShowdown.postText=(postText)?postText:"";
layerManager.tickerUlmaShowdown.noIndexReset=(noIndexReset)?1:0;
layerManager.tickerUlmaShowdown.currentPathIndex=(noIndexReset)?
layerManager.tickerUlmaShowdown.currentPathIndex:0;
layerManager.tickerUlmaShowdown.speed=(speed)?parseFloat(speed):120;
layerManager.tickerUlmaShowdown.run();
}

stringTicker arguments:
  • inputString argument: it is the text that you want to appear as the eventual entry of the array the subroutine generates.
  • optionalSplitter argument: since the script splits the input into its components, you may want to pass here a divider which must be taken as the splitter of the input string. I suggest to you not to use this argument if you haven't sound reason for, therefore to always pass it as zero. Anyway the most basic invoking of this function is:
    stringTicker("cool"); //"cool" or whatever text,obviously. Always in between apex.
  • alphabet argument: you can provide an entirely different alphabet either as a long string of chars, or as an array of chars: if you set the alphabet argument to a string of chars and you do not set the alphabetIsAddOn argument, the alphabet you pass will overwrite the default one.
    If you want to make your output array more lengthy, and therefore you want a ticker which takes more time to get to a close, well just include (arguably as alphabetIsAddOn - see next argument too) more chars in the alphabet, or append them to the default alphabet by alphabetIsAddOn: you can certainly include alphabets where a same set of letters is repeated 4 or 5 times or more in order to make the ticker be as many times likely to be longer accordingly to as many duplicated letter or additional chars you have included. Anyway the best way to achieve a longer output array is to set the slower argument (see further on).
  • alphabetIsAddOn argument: if you pass this, you need to pass something as alphabet argument as well; if you pass this as something different than zero, it will append the argument you passed as alphabet to the built in alphabet, as an integration to it you see.
    Anyway rest assured that the script takes care of a mission critical aspect on its own: if it finds in your input string some chars that are not present in the default alphabet, it automatically includes them in the default alphabet!
  • slower argument: since the function is optimized to get the result in the minimal possible amount of guesses, you might want to make the output array lenghtier in order to make a longer ticker without affecting the speed it "tickers" by; to achieve this, namely to get a longer output array, you pass the argument slower as a number: it will multiply the default alphabet (or the one you have overwritten it with) as many times as slower is: if slower is 2, alphabet will become: (alphabet plus alphabet), if slower is 3, alphabet becomes (alpabhet+alpabeth+alphabet), and so on...
    stringTicker("cool", 0, 0, 4);
    Note that if slower is passed as 1, it won't multiply the alphabet.
    In such case it would accept passing a positive alphabetIsAddOn argument, and a slower argument as well along with it, without replicating what you added to the default alphabet: namely, I assume that if you pass the parameter alphabetIsAddOn, you may arguably want a way to append your addons to the standard alphabet without seeing the whole multiplicated if you wanted both things: addons and slower. Such a combinations can get achieved by passing slower as 1:
    stringTicker("cool", "morechars", 1, 1)
    In such case the alphabet won't get multiplicated, assuming all the responsibility to make your alphabet longer relies upon the significance of the amount of chars you passed as the alphabet argument: none the less, since you set the slower argument, from such generated alphabet (default+addons, that is) the redundant copies for each given char would be eliminated (see immediatly furhter on for more on this cryptic statement).
    Last but not least: the script inspects the input string building for each char of it a thread copy of the alphabet upon which it makes the attempts to grab the matching letter for the specific given input char (that is: a copy of alphabet for each input char); each alphabet thread for each char will be freed of the relative wrong guessworked char any time such a guesswork fails picking a matching entry: in such way the process gets faster and faster at each iteration for given each char of the input string, we use specific alphabets (threads) that gradually eliminate from the pickable letters of the corresponding thread the chars that already proved being wrong.
    Therefore here it is another cool feature: if the alphabet is multiplicated by the agency of a slower argument higher than 1, or also just if your slower argument equals 1 and you added some addons to the default alphabet, well if so for each thread meant to inspect one char of the inputString each possible duplicate of the inputString char which might be present in the alphabet thread meant to inspect such inputString char would be eliminated (in fact if alphabets get multiplied, also the given matching char would get multiplicated!): this means that if on some silly input as "hi" the alphabet thread which inspects the h would include 3 h for it was multiplicated by 3, well 2 h will be eliminated to make the process slower! In fact the more the h, in our examples, the more then chances the guessowrk is right sooner: but if you want it slower, you don't want this, right?
  • arrayOfArraysOutput argument: if set to something different than zero, yields as output an array whose each entry is not a string of the attempt, but an array of the attempt: array of arrays, whose each entry of the latter is a char of the current attempt to match the input argument.
tickerFormShowdown arguments:
  • array argument: the array produced by stringTicker (yes, you could even pass the very same stringTicker function as the argument itself)
  • targets argument: it must be a valid form text field reference omitting the value keyword, such as say: document.myForm.myField
  • time argument: it's the timeout speed: defaults to 120 milliseconds.
  • Example:
    tickerFormShowdown( stringTicker("cool"), document.formName.fieldName, 150 )
ULMAticker function: requires you have defined tickerUlmaShowdown() in your script as well. Requires ULMA layerManager defined and initialized (var foo; foo=new layerManager("foo", "layerIDhere"); foo.abilitate();); by the agency of ULMAticker the script enables the tickerUlmaShowdown method on the given layerManager on its own (which would not do, if you are to use tickerUlmaShowdown without passing through ULMAticker).
ULMAticker (lowercase t) arguments as follows:
  • layerManager argument: an ULMA layerManager, passed either as an object or as its string version name
  • tickingText argument: the very same as the input argument in stringTicker
  • preText argument: you're writing onto a layer: maybe you want to write something before the section where the array attempts entries get printed (beware on NS4 oddities: if you write stuff like tables whose align property is set, Netscape may be unable to write or recognize objects)
  • postText argument: since you're still writing onto a layer, maybe you want to append something after the current array entry printed text.
  • speed argument: defaults to 120 milliseconds.
  • all subsequent arguments: they have the same names of some arguments in the stringTicker subroutine definition, and are meant exactly for the same purposes they are meant for there.
  • noIndexReset argument: if set, doesn't reset to zero the index which is scouring the array: it may be useful if you want to interrupt and restart tickering from the entry you already were positioned at.
  • Example:
    ULMAticker( stringTicker("cool"), "<font size='3'>", "</font>", 120)
Obviously, whenever you don't need to pass an argument but you do need to pass the subsequent one, pass the one you don't need as zero.

TEST THE STRING TICKER
Shae Marks
Tickering on: a layer » form textField »
Input Text »
add to alphabet?
(optional; the more the longer the process. Accepts duplicates)
Chloe Jones


Top of Page