1- var intervalTypingMillisecondsBase = 50 ;
2- var intervalTypingMaxMilliseconds = 200 ;
3- var intervalChangeText = 4000 ;
1+ "use strict"
42
5- var currentSuffixIndex , lastSuffixIndex , lastSuffixButOneIndex ;
3+ $ ( function ( ) {
4+ var intervalTypingMillisecondsBase = 50 ;
5+ var intervalTypingMaxMilliseconds = 200 ;
6+ var intervalChangeText = 4000 ;
67
7- var languages = [
8- "C#" ,
9- "CSS" ,
10- "HTML" ,
11- "JAVA" ,
12- "JS" ,
13- "PYTHON" ,
14- "SQL"
15- ]
8+ var currentSuffixIndex , lastSuffixIndex , lastSuffixButOneIndex ;
169
17- var people = [
18- "BEN" ,
19- "DREW" ,
20- "EDWARD" ,
21- "GARETH" ,
22- "HARRY" ,
23- "JIM" ,
24- "LIAM" ,
25- "LIZ" ,
26- "KEIRAN" ,
27- "SIMON" ,
28- "US"
29- ] ;
10+ var languages = [
11+ "C#" ,
12+ "CSS" ,
13+ "HTML" ,
14+ "JAVA" ,
15+ "JS" ,
16+ "PYTHON" ,
17+ "SQL"
18+ ]
3019
31- function showText ( target , message , index , maxInterval ) {
32- if ( index < message . length ) {
33- $ ( target ) . append ( message [ index ++ ] ) ;
34-
35- var typingInterval = maxInterval - intervalTypingMillisecondsBase ;
36- if ( typingInterval < 0 ) {
37- typingInterval = 0 ;
38- }
20+ var people = [
21+ "BEN" ,
22+ "DREW" ,
23+ "EDWARD" ,
24+ "GARETH" ,
25+ "HARRY" ,
26+ "JIM" ,
27+ "LIAM" ,
28+ "LIZ" ,
29+ "KEIRAN" ,
30+ "SIMON" ,
31+ "US"
32+ ] ;
33+
34+ function showText ( target , message , index , maxInterval ) {
35+ if ( index < message . length ) {
36+ $ ( target ) . append ( message [ index ++ ] ) ;
37+
38+ var typingInterval = maxInterval - intervalTypingMillisecondsBase ;
39+ if ( typingInterval < 0 ) {
40+ typingInterval = 0 ;
41+ }
3942
40- typingInterval = intervalTypingMillisecondsBase + Math . floor ( Math . random ( ) * typingInterval ) ;
41- setTimeout ( function ( ) {
42- showText ( target , message , index , maxInterval ) ;
43- } , typingInterval ) ;
43+ typingInterval = intervalTypingMillisecondsBase + Math . floor ( Math . random ( ) * typingInterval ) ;
44+ setTimeout ( function ( ) {
45+ showText ( target , message , index , maxInterval ) ;
46+ } , typingInterval ) ;
47+ }
4448 }
45- }
4649
47- function showSuffix ( target , suffixOptions , suffixInterval ) {
48- while ( currentSuffixIndex === lastSuffixIndex || currentSuffixIndex === lastSuffixButOneIndex ) {
49- currentSuffixIndex = Math . floor ( Math . random ( ) * suffixOptions . length ) ;
50+ function showSuffix ( target , suffixOptions , suffixInterval ) {
51+ while ( currentSuffixIndex === lastSuffixIndex || currentSuffixIndex === lastSuffixButOneIndex ) {
52+ currentSuffixIndex = Math . floor ( Math . random ( ) * suffixOptions . length ) ;
53+ }
54+ lastSuffixButOneIndex = lastSuffixIndex ;
55+ lastSuffixIndex = currentSuffixIndex ;
56+
57+ setTimeout ( function ( ) {
58+ $ ( target ) . text ( '' ) ;
59+ showText ( target , suffixOptions [ currentSuffixIndex ] , 0 , intervalTypingMaxMilliseconds ) ;
60+ showSuffix ( target , suffixOptions , suffixInterval )
61+ } , intervalChangeText ) ;
5062 }
51- lastSuffixButOneIndex = lastSuffixIndex ;
52- lastSuffixIndex = currentSuffixIndex ;
53-
54- setTimeout ( function ( ) {
55- $ ( target ) . text ( '' ) ;
56- showText ( target , suffixOptions [ currentSuffixIndex ] , 0 , intervalTypingMaxMilliseconds ) ;
57- showSuffix ( target , suffixOptions , suffixInterval )
58- } , intervalChangeText ) ;
59- }
6063
61- $ ( function ( ) {
62- var suffixOptions = languages ;
64+ var suffixOptions = people ;
6365 currentSuffixIndex = lastSuffixIndex = lastSuffixButOneIndex = suffixOptions . length - 1 ;
6466 showSuffix ( "#suffix" , suffixOptions , intervalChangeText ) ;
6567} )
0 commit comments