Skip to content

Mteixeira88/IE-include-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IE-include-method

You see the Javascript/Typescript and try yourself the code here. or have/copy the class in the index.ts file or in the section Typescript Class.

Motivation

When looking for a solution to use the include Javascript function, I notice that IE didn't had support and I lost a lot of time looking for a solution in the internet.

For this reason, I did a script that is already converted to Javascript here that enables the use of include by calling a class and giving what values you want to compare and the value to compare.

Typescript Class

This class enables the use of include Javascript function in IE.

class ITM {
    private containing: any;
    private browser: boolean = false;

    constructor() {
        //code goes here
    }
/**
 * [browserDetect - This method is to know when the user is using Internet Explorer]
 */
    private browserDetect() {
        if ((navigator.userAgent.indexOf('Trident/7.0') > 0) ||
            (/MSIE 10/i.test(navigator.userAgent)) ||
                (/MSIE 9/i.test(navigator.userAgent) ||
                    /rv:11.0/i.test(navigator.userAgent))) {
                this.browser = true;
            }
    }

/**
 * [includesToMatch - Depending on the browser, this method compares your variables using the include or the match Javascript function,
 * enabling it to work with the last breakthrough tecnologies of ES]
 */
    public includesToMatch(variableToCompare: string, containing: Array<string>) {
        let variableToMatch: string;
        this.browserDetect()
        this.containing = containing;
        if (this.browser) {
            for (let i = 0; i < containing.length; i++) {
                if (variableToCompare.match(containing[i])) {
                    return true;
                }
            }
        } else {

            if (this.containing.includes(variableToCompare)) {
                return true;
            }
        }
        return false;
    }
}

Typescript usage

import {ITM} from '../your-folder/your-file';
const test = new ITM();
test.includesToMatch(variabletoCompare, arrayToCompare);

Contributing

  1. Fork this project: https://github.com/Mteixeira88/css-variables-IE-script
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

Author

Miguel Teixeira

License

This is free and unencumbered software released into the public domain. For more information, please refer to http://unlicense.org.

About

When looking for a solution to use the include Javascript function, I notice that IE didn't had support and I lost a lot of time looking for a solution in the internet.

Resources

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors