PageSourceSearch

https://streamingtvcastrd.com/wp-content/plugins/modeltheme-framework/js/mt-plugins.js?ver=1.0.0

js streamingtvcastrd.com collected 2026-10-02 00:56:17 UTC 15,635 bytes, 438 lines download raw bytes

1/*
21. Typed.js
3
4
5
6*/
7
8// The MIT License (MIT)
9
10// Typed.js | Copyright (c) 2014 Matt Boldt | www.mattboldt.com
11
12// Permission is hereby granted, free of charge, to any person obtaining a copy
13// of this software and associated documentation files (the "Software"), to deal
14// in the Software without restriction, including without limitation the rights
15// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16// copies of the Software, and to permit persons to whom the Software is
17// furnished to do so, subject to the following conditions:
18
19// The above copyright notice and this permission notice shall be included in
20// all copies or substantial portions of the Software.
21
22// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28// THE SOFTWARE.\
29
30! function($) {
31
32    "use strict";
33
34    var Typed = function(el, options) {
35
36        // chosen element to manipulate text
37        this.el = $(el);
38
39        // options
40        this.options = $.extend({}, $.fn.typed.defaults, options);
41
42        // attribute to type into
43        this.isInput = this.el.is('input');
44        this.attr = this.options.attr;
45
46        // show cursor
47        this.showCursor = this.isInput ? false : this.options.showCursor;
48
49        // text content of element
50        this.elContent = this.attr ? this.el.attr(this.attr) : this.el.text()
51
52        // html or plain text
53        this.contentType = this.options.contentType;
54
55        // typing speed
56        this.typeSpeed = this.options.typeSpeed;
57
58        // add a delay before typing starts
59        this.startDelay = this.options.startDelay;
60
61        // backspacing speed
62        this.backSpeed = this.options.backSpeed;
63
64        // amount of time to wait before backspacing
65        this.backDelay = this.options.backDelay;
66
67        // div containing strings
68        this.stringsElement = this.options.stringsElement;
69
70        // input strings of text
71        this.strings = this.options.strings;
72
73        // character number position of current string
74        this.strPos = 0;
75
76        // current array position
77        this.arrayPos = 0;
78
79        // number to stop backspacing on.
80        // default 0, can change depending on how many chars
81        // you want to remove at the time
82        this.stopNum = 0;
83
84        // Looping logic
85        this.loop = this.options.loop;
86        this.loopCount = this.options.loopCount;
87        this.curLoop = 0;
88
89        // for stopping
90        this.stop = false;
91
92        // custom cursor
93        this.cursorChar = this.options.cursorChar;
94
95        // shuffle the strings
96        this.shuffle = this.options.shuffle;
97        // the order of strings
98        this.sequence = [];
99
100        // All systems go!
101        this.build();
102    };
103
104    Typed.prototype = {
105
106        constructor: Typed
107
108        ,
109        init: function() {
110            // begin the loop w/ first current string (global self.strings)
111            // current string will be passed as an argument each time after this
112            var self = this;
113            self.timeout = setTimeout(function() {
114                for (var i=0;i<self.strings.length;++i) self.sequence[i]=i;
115
116                // shuffle the array if true
117                if(self.shuffle) self.sequence = self.shuffleArray(self.sequence);
118
119                // Start typing
120                self.typewrite(self.strings[self.sequence[self.arrayPos]], self.strPos);
121            }, self.startDelay);
122        }
123
124        ,
125        build: function() {
126            var self = this;
127            // Insert cursor
128            if (this.showCursor === true) {
129                this.cursor = $("<span class=\"typed-cursor\">" + this.cursorChar + "</span>");
130                this.el.after(this.cursor);
131            }
132            if (this.stringsElement) {
133                self.strings = [];
134                this.stringsElement.hide();
135                var strings = this.stringsElement.find('p');
136                $.each(strings, function(key, value){
137                    self.strings.push($(value).html());
138                });
139            }
140            this.init();
141        }
142
143        // pass current string state to each function, types 1 char per call
144        ,
145        typewrite: function(curString, curStrPos) {
146            // exit when stopped
147            if (this.stop === true) {
148                return;
149            }
150
151            // varying values for setTimeout during typing
152            // can't be global since number changes each time loop is executed
153            var humanize = Math.round(Math.random() * (100 - 30)) + this.typeSpeed;
154            var self = this;
155
156            // ------------- optional ------------- //
157            // backpaces a certain string faster
158            // ------------------------------------ //
159            // if (self.arrayPos == 1){
160            //  self.backDelay = 50;
161            // }
162            // else{ self.backDelay = 500; }
163
164            // contain typing function in a timeout humanize'd delay
165            self.timeout = setTimeout(function() {
166                // check for an escape character before a pause value
167                // format: \^\d+ .. eg: ^1000 .. should be able to print the ^ too using ^^
168                // single ^ are removed from string
169                var charPause = 0;
170                var substr = curString.substr(curStrPos);
171                if (substr.charAt(0) === '^') {
172                    var skip = 1; // skip atleast 1
173                    if (/^\^\d+/.test(substr)) {
174                        substr = /\d+/.exec(substr)[0];
175                        skip += substr.length;
176                        charPause = parseInt(substr);
177                    }
178
179                    // strip out the escape character and pause value so they're not printed
180                    curString = curString.substring(0, curStrPos) + curString.substring(curStrPos + skip);
181                }
182
183                if (self.contentType === 'html') {
184                    // skip over html tags while typing
185                    var curChar = curString.substr(curStrPos).charAt(0)
186                    if (curChar === '<' || curChar === '&') {
187                        var tag = '';
188                        var endTag = '';
189                        if (curChar === '<') {
190                            endTag = '>'
191                        } else {
192                            endTag = ';'
193                        }
194                        while (curString.substr(curStrPos).charAt(0) !== endTag) {
195                            tag += curString.substr(curStrPos).charAt(0);
196                            curStrPos++;
197                        }
198                        curStrPos++;
199                        tag += endTag;
200                    }
201                }
202
203                // timeout for any pause after a character
204                self.timeout = setTimeout(function() {
205                    if (curStrPos === curString.length) {
206                        // fires callback function
207                        self.options.onStringTyped(self.arrayPos);
208
209                        // is this the final string
210                        if (self.arrayPos === self.strings.length - 1) {
211                            // animation that occurs on the last typed string
212                            self.options.callback();
213
214                            self.curLoop++;
215
216                            // quit if we wont loop back
217                            if (self.loop === false || self.curLoop === self.loopCount)
218                                return;
219                        }
220
221                        self.timeout = setTimeout(function() {
222                            self.backspace(curString, curStrPos);
223                        }, self.backDelay);
224                    } else {
225
226                        /* call before functions if applicable */
227                        if (curStrPos === 0)
228                            self.options.preStringTyped(self.arrayPos);
229
230                        // start typing each new char into existing string
231                        // curString: arg, self.el.html: original text inside element
232                        var nextString = curString.substr(0, curStrPos + 1);
233                        if (self.attr) {
234                            self.el.attr(self.attr, nextString);
235                        } else {
236                            if (self.isInput) {
237                                self.el.val(nextString);
238                            } else if (self.contentType === 'html') {
239                                self.el.html(nextString);
240                            } else {
241                                self.el.text(nextString);
242                            }
243                        }
244
245                        // add characters one by one
246                        curStrPos++;
247                        // loop the function
248                        self.typewrite(curString, curStrPos);
249                    }
250                    // end of character pause
251                }, charPause);
252
253                // humanized value for typing
254            }, humanize);
255
256        }
257
258        ,
259        backspace: function(curString, curStrPos) {
260            // exit when stopped
261            if (this.stop === true) {
262                return;
263            }
264
265            // varying values for setTimeout during typing
266            // can't be global since number changes each time loop is executed
267            var humanize = Math.round(Math.random() * (100 - 30)) + this.backSpeed;
268            var self = this;
269
270            self.timeout = setTimeout(function() {
271
272                // ----- this part is optional ----- //
273                // check string array position
274                // on the first string, only delete one word
275                // the stopNum actually represents the amount of chars to
276                // keep in the current string. In my case it's 14.
277                // if (self.arrayPos == 1){
278                //  self.stopNum = 14;
279                // }
280                //every other time, delete the whole typed string
281                // else{
282                //  self.stopNum = 0;
283                // }
284
285                if (self.contentType === 'html') {
286                    // skip over html tags while backspacing
287                    if (curString.substr(curStrPos).charAt(0) === '>') {
288                        var tag = '';
289                        while (curString.substr(curStrPos).charAt(0) !== '<') {
290                            tag -= curString.substr(curStrPos).charAt(0);
291                            curStrPos--;
292                        }
293                        curStrPos--;
294                        tag += '<';
295                    }
296                }
297
298                // ----- continue important stuff ----- //
299                // replace text with base text + typed characters
300                var nextString = curString.substr(0, curStrPos);
301                if (self.attr) {
302                    self.el.attr(self.attr, nextString);
303                } else {
304                    if (self.isInput) {
305                        self.el.val(nextString);
306                    } else if (self.contentType === 'html') {
307                        self.el.html(nextString);
308                    } else {
309                        self.el.text(nextString);
310                    }
311                }
312
313                // if the number (id of character in current string) is
314                // less than the stop number, keep going
315                if (curStrPos > self.stopNum) {
316                    // subtract characters one by one
317                    curStrPos--;
318                    // loop the function
319                    self.backspace(curString, curStrPos);
320                }
321                // if the stop number has been reached, increase
322                // array position to next string
323                else if (curStrPos <= self.stopNum) {
324                    self.arrayPos++;
325
326                    if (self.arrayPos === self.strings.length) {
327                        self.arrayPos = 0;
328
329                        // Shuffle sequence again
330                        if(self.shuffle) self.sequence = self.shuffleArray(self.sequence);
331
332                        self.init();
333                    } else
334                        self.typewrite(self.strings[self.sequence[self.arrayPos
334]], curStrPos);
335                }
336
337                // humanized value for typing
338            }, humanize);
339
340        }
341        /**
342         * Shuffles the numbers in the given array.
343         * @param {Array} array
344         * @returns {Array}
345         */
346        ,shuffleArray: function(array) {
347            var tmp, current, top = array.length;
348            if(top) while(--top) {
349                current = Math.floor(Math.random() * (top + 1));
350                tmp = array[current];
351                array[current] = array[top];
352                array[top] = tmp;
353            }
354            return array;
355        }
356
357        // Start & Stop currently not working
358
359        // , stop: function() {
360        //     var self = this;
361
362        //     self.stop = true;
363        //     clearInterval(self.timeout);
364        // }
365
366        // , start: function() {
367        //     var self = this;
368        //     if(self.stop === false)
369        //        return;
370
371        //     this.stop = false;
372        //     this.init();
373        // }
374
375        // Reset and rebuild the element
376        ,
377        reset: function() {
378            var self = this;
379            clearInterval(self.timeout);
380            var id = this.el.attr('id');
381            this.el.after('<span id="' + id + '"/>')
382            this.el.remove();
383            if (typeof this.cursor !== 'undefined') {
384                this.cursor.remove();
385            }
386            // Send the callback
387            self.options.resetCallback();
388        }
389
390    };
391
392    $.fn.typed = function(option) {
393        return this.each(function() {
394            var $this = $(this),
395                data = $this.data('typed'),
396                options = typeof option == 'object' && option;
397            if (!data) $this.data('typed', (data = new Typed(this, options)));
398            if (typeof option == 'string') data[option]();
399        });
400    };
401
402    $.fn.typed.defaults = {
403        strings: ["These are the default values...", "You know what you should do?", "Use your own!", "Have a great day!"],
404        stringsElement: null,
405        // typing speed
406        typeSpeed: 0,
407        // time before typing starts
408        startDelay: 0,
409        // backspacing speed
410        backSpeed: 0,
411        // shuffle the strings
412        shuffle: false,
413        // time before backspacing
414        backDelay: 500,
415        // loop
416        loop: false,
417        // false = infinite
418        loopCount: false,
419        // show cursor
420        showCursor: true,
421        // character for cursor
422        cursorChar: "|",
423        // attribute to type (null == text)
424        attr: null,
425        // either html or text
426        contentType: 'html',
427        // call when done callback function
428        callback: function() {},
429        // starting callback function before each string
430        preStringTyped: function() {},
431        //callback for every typed string
432        onStringTyped: function() {},
433        // callback for reset
434        resetCallback: function() {}
435    };
436
437
438}(window.jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.