HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: /var/www/html/bwcdev/wp-content/plugins/calculated-fields-form/js/modules/10_text/public/10_text.js
/*
* text.js v0.1
* By: CALCULATED FIELD PROGRAMMERS
* Includes operations to interact with Texts
* Copyright 2022 CODEPEOPLE
*/

;(function(root){
	var lib = {};

	/*** PUBLIC FUNCTIONS ***/

	if(window.WORDSCOUNTER == undefined) {
        lib.WORDSCOUNTER = lib.wordscounter = function(text){
            try {
                return text.replace(/(?!\w|\s)./g, '')
                            .replace(/\s+/g, ' ')
                            .replace(/^(\s*)([\W\w]*)(\b\s*$)/g, '$2')
                            .split(' ').length;
            } catch (err) {
                return 0;
            }
        }
    }

    if(window.CHARSCOUNTER == undefined) {
        lib.CHARSCOUNTER = lib.charscounter = function(text, ignore_blank){
            try {
                var ignore_blank = ignore_blank || 0;
                text += '';
                if ( ignore_blank ) text = text.replace( /[\s\r\n\t]/g, '');
                return text.length;
            } catch (err) {
                return 0;
            }
        }
    }

    if(window.INTEXT == undefined) {
        lib.INTEXT = lib.intext = function(term, text, case_insensitive){
            try {
                var case_insensitive = case_insensitive || 0;
                if( ! term instanceof RegExp ) term += '';
                text += '';
                if ( case_insensitive ) {
                    if( term instanceof RegExp ) term = new RegExp( term.source, 'i' );
                    else term = term.toLowerCase();
                    text = text.toLowerCase();
                }
                return Math.max(text.split(term).length - 1, 0);
            } catch (err) {
                return 0;
            }
        }
    }

    root.CF_TEXT = lib;

})(this);