<commit_before>import React from 'react';
import {NavLink} from 'fluxible-router';
import {connectToStores} from 'fluxible-addons-react';
import SlideViewStore from '../../../../../stores/SlideViewStore';
import ResizeAware from 'react-resize-aware';
import { findDOMNode } from 'react-dom';
const ReactDOM = require('react-dom');

class SlideViewPanel extends React.Component {
    render() {
        //styles should match slideContentEditor for consistency
        const compHeaderStyle = {
            minWidth: '100%',
            overflowY: 'auto',
            position: 'relative'
        };
        const compStyle = {
            //minWidth: '100%',
            // maxHeight: 450,
            minHeight: 450,
            //minHeight: '100%',
            overflowY: 'auto',
            overflowX: 'hidden',
            //overflowY: 'visible',
            //overflow: 'hidden,'
            position: 'relative'
        };
        const compSpeakerStyle = {
            maxHeight: 50,
            minHeight: 50,
            overflowY: 'auto',
            position: 'relative'
        };

        const containerMinHeight = {

        }

        return (

              <ResizeAware ref='container' id='container'>

                      {this.props.SlideViewStore.speakernotes ? Speaker notes: : ''}

              </ResizeAware>

        );
    }
    componentDidMount(){
        if(process.env.BROWSER){
            // update mathjax rendering
            // add to the mathjax rendering queue the command to type-set the inlineContent
            MathJax.Hub.Queue(["Typeset",MathJax.Hub,"inlineContent"]);

            //Function toi fit contents in edit and view component
            //$(".pptx2html").addClass('schaal');
            //$(".pptx2html [style*='absolute']").addClass('schaal');
            /*
            if ($('.pptx2html').length)
            {
                $(".pptx2html").css({'transform': 'scale(0.5,0.5)', 'transform-origin': 'top left'});
                //$("#signinModal").css({'zIndex': '99999', 'position': 'absolute'});

            } else {
                //do nothing - relative content scales anyways.
                //$(".slides").css({'transform': 'scale(0.5,0.5)', 'transform-origin': 'top left'});
                //$("#signinModal").css({'zIndex': '99999', 'position': 'absolute'});
            }
            */
            //initial resize
            this.resize()
            ReactDOM.findDOMNode(this.refs.container).addEventListener('resize', (evt) =>
                {
                //console.log('resize');
                this.resize();
            });
        }
        this.forceUpdate();
    }
    componentDidUpdate() {
        this.resize();
    }
    resize()
    {
        let containerwidth = document.getElementById('container').offsetWidth;
        let containerheight = document.getElementById('container').offsetHeight;
        //console.log('Component has been resized! Width =' + containerwidth + 'height' + containerheight);

        //reset scaling of pptx2html element to get original size
        $(".pptx2html").css({'transform': '', 'transform-origin': ''});

        //Function to fit contents in edit and view component
        let pptxwidth = $('.pptx2html').width();
        let pptxheight = $('.pptx2html').height();

        //only calculate scaleration for width for now
        this.scaleratio = containerwidth / pptxwidth;

        if ($('.pptx2html').length)
        {
            $(".pptx2html").css({'transform': '', 'transform-origin': ''});
            $(".pptx2html").css({'transform': 'scale('+this.scaleratio+','+this.scaleratio+')', 'transform-origin': 'top left'});

            //set height of content panel to at least size of pptx2html + (100 pixels * scaleratio).
            //width = pptxwidth + 40
            //height + 40
            //this.refs.slideViewPanel.style.width = ((pptxwidth + 40) * this.scaleratio) + 'px';
            //this.refs.slideViewPanel.style.padding = '20px 20px 20px 20px';
            //$(".pptx2html").css({'padding': '20px 20px 20px 20px'});
            //style.padding left = 20 px, top 20 px
            this.refs.slideViewPanel.style.height = ((pptxheight + 0 + 20) * this.scaleratio) + 'px';

            $(".pptx2html").css({'borderStyle': 'none none double none ', 'borderColor': '#3366ff', 'box-shadow': '0px 100px 1000px #ff8787'});
            //all borders
            //$(".pptx2html").css({'borderStyle': 'double double double double ', 'borderColor': '#3366ff', 'box-shadow': '0px 100px 1000px #ff8787'});
        }
    }
}

SlideViewPanel = connectToStores(SlideViewPanel, [SlideViewStore], (context, props) => {
    return {
        SlideViewStore: context.getStore(SlideViewStore).getState()
    };
});
export default SlideViewPanel;
<commit_msg>Fix mathematical expressions not always rendering correctly<commit_after>import React from 'react';
import {NavLink} from 'fluxible-router';
import {connectToStores} from 'fluxible-addons-react';
import SlideViewStore from '../../../../../stores/SlideViewStore';
import ResizeAware from 'react-resize-aware';
import { findDOMNode } from 'react-dom';
const ReactDOM = require('react-dom');

class SlideViewPanel extends React.Component {
    render() {
        //styles should match slideContentEditor for consistency
        const compHeaderStyle = {
            minWidth: '100%',
            overflowY: 'auto',
            position: 'relative'
        };
        const compStyle = {
            //minWidth: '100%',
            // maxHeight: 450,
            minHeight: 450,
            //minHeight: '100%',
            overflowY: 'auto',
            overflowX: 'hidden',
            //overflowY: 'visible',
            //overflow: 'hidden,'
            position: 'relative'
        };
        const compSpeakerStyle = {
            maxHeight: 50,
            minHeight: 50,
            overflowY: 'auto',
            position: 'relative'
        };

        const containerMinHeight = {

        }

        return (

              <ResizeAware ref='container' id='container'>

                      {this.props.SlideViewStore.speakernotes ? Speaker notes: : ''}

              </ResizeAware>

        );
    }
    componentDidMount(){
        if(process.env.BROWSER){
            //Function toi fit contents in edit and view component
            //$(".pptx2html").addClass('schaal');
            //$(".pptx2html [style*='absolute']").addClass('schaal');
            /*
            if ($('.pptx2html').length)
            {
                $(".pptx2html").css({'transform': 'scale(0.5,0.5)', 'transform-origin': 'top left'});
                //$("#signinModal").css({'zIndex': '99999', 'position': 'absolute'});

            } else {
                //do nothing - relative content scales anyways.
                //$(".slides").css({'transform': 'scale(0.5,0.5)', 'transform-origin': 'top left'});
                //$("#signinModal").css({'zIndex': '99999', 'position': 'absolute'});
            }
            */
            //initial resize
            this.resize()
            ReactDOM.findDOMNode(this.refs.container).addEventListener('resize', (evt) =>
                {
                //console.log('resize');
                this.resize();
            });
        }
        this.forceUpdate();
    }
    componentDidUpdate() {
        // update mathjax rendering
        // add to the mathjax rendering queue the command to type-set the inlineContent
        MathJax.Hub.Queue(["Typeset",MathJax.Hub,"inlineContent"]);

        this.resize();
    }
    resize()
    {
        let containerwidth = document.getElementById('container').offsetWidth;
        let containerheight = document.getElementById('container').offsetHeight;
        //console.log('Component has been resized! Width =' + containerwidth + 'height' + containerheight);

        //reset scaling of pptx2html element to get original size
        $(".pptx2html").css({'transform': '', 'transform-origin': ''});

        //Function to fit contents in edit and view component
        let pptxwidth = $('.pptx2html').width();
        let pptxheight = $('.pptx2html').height();

        //only calculate scaleration for width for now
        this.scaleratio = containerwidth / pptxwidth;

        if ($('.pptx2html').length)
        {
            $(".pptx2html").css({'transform': '', 'transform-origin': ''});
            $(".pptx2html").css({'transform': 'scale('+this.scaleratio+','+this.scaleratio+')', 'transform-origin': 'top left'});

            //set height of content panel to at least size of pptx2html + (100 pixels * scaleratio).
            //width = pptxwidth + 40
            //height + 40
            //this.refs.slideViewPanel.style.width = ((pptxwidth + 40) * this.scaleratio) + 'px';
            //this.refs.slideViewPanel.style.padding = '20px 20px 20px 20px';
            //$(".pptx2html").css({'padding': '20px 20px 20px 20px'});
            //style.padding left = 20 px, top 20 px
            this.refs.slideViewPanel.style.height = ((pptxheight + 0 + 20) * this.scaleratio) + 'px';

            $(".pptx2html").css({'borderStyle': 'none none double none ', 'borderColor': '#3366ff', 'box-shadow': '0px 100px 1000px #ff8787'});
            //all borders
            //$(".pptx2html").css({'borderStyle': 'double double double double ', 'borderColor': '#3366ff', 'box-shadow': '0px 100px 1000px #ff8787'});
        }
    }
}

SlideViewPanel = connectToStores(SlideViewPanel, [SlideViewStore], (context, props) => {
    return {
        SlideViewStore: context.getStore(SlideViewStore).getState()
    };
});
export default SlideViewPanel;
<|endoftext|>


<commit_before>var libraries = (function () {
    var a = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
        b = "1234567890234567890134567890124567890123567890123467890123457890123456890123456790123456780123456789",
        c = "98109840984098409156481068456541684065964819841065106865710397464513210416435401645030648036034063974065004951094209420942097421970490274195049120974210974209742190274092740492097420929892490974202241",
        d = c + c + c + c + c + c + c + c + c + c,
        e = d + d + d + d + d + d + d + d + d + d,
        f = e + e + e,
        c2 = a + b,
        d2 = c2 + c2 + c2 + c2 + c2 + c2 + c2 + c2 + c2 + c2,
        e2 = d2 + d2 + d2 + d2 + d2 + d2 + d2 + d2 + d2 + d2,
        f2 = e2 + e2 + e2,
        s1 = 12345,
        s2 = 98765,
        s3 = 5437654,
        _5 = 5,
        _22 = 22,
        _23 = 23;
    var vars = { a: a, b: b, c: c, d: d, e: e, f: f, c2: c2, d2: d2, e2: e2, f2: f2, s1: s1, s2: s2, s3: s3, _5: _5, _22: _22, _23: _23 };

    var createInitialization = function (fName, radix) {
        var str = "";
        radix = radix || "";
        for (var i in vars) {
            str += i + "=" + fName + "('" + vars[i] + "'" + radix + ");" + i + "_str='" + vars[i] + "';";
        }
        return str;
    };

    var createOnCycle = function (f) {
        var str = "";
        for (var i in vars) {
            str += f(i) + ";";
        }
        return str;
    };

    var tests = {
        "Addition: large1 + large2": "a.add(b)",
        "Addition: large + small": "a.add(s1)",
        "Addition: small + large": "s1.add(a)",
        "Addition: small1 + small2": "s1.add(s2)",
        "Addition: 200 digits": "c.add(c2)",
        "Addition: 2,000 digits": "d.add(d2)",
        "Addition: 20,000 digits": "e.add(e2)",
        "Addition: 60,000 digits": "f.add(f2)",
        "Subtraction: large1 - large2": "b.minus(a)",
        "Subtraction: large - small": "b.minus(s1)",
        "Subtraction: small - large": "s1.minus(b)",
        "Subtraction: small - small": "s2.minus(s1)",
        "Subtraction: 200 digits": "c.minus(c2)",
        "Subtraction: 2,000 digits": "d.minus(d2)",
        "Subtraction: 20,000 digits": "e.minus(e2)",
        "Subtraction: 60,000 digits": "f.minus(f2)",
        "Multiplication: large * large": "a.times(b)",
        "Multiplication: large * small": "a.times(s1)",
        "Multiplication: small * large": "s1.times(a)",
        "Multiplication: small1 * small2": "s1.times(s2)",
        "Multiplication: 400 digits": "c.times(b)",
        "Multiplication: 2,200 digits": "d.times(c)",
        "Multiplication: 22,000 digits": "e.times(d)",
        "Multiplication: 82,000 digits": "f.times(e)",
        "Squaring: small": "s1.square()",
        "Squaring: 200 digits": "a.square()",
        "Squaring: 400 digits": "c.square()",
        "Squaring: 4,000 digits": "d.square()",
        "Squaring: 40,000 digits": "e.square()",
        "Division: large1 / large2": "b.over(a)",
        "Division: large / small": "a.over(s1)",
        "Division: small / large": "s2.over(b)",
        "Division: small / small": "s2.over(s1)",
        "Division: 200 digits": "c.over(b)",
        "Division: 2,000 digits": "d.over(c)",
        "Division: 20,000 digits": "e.over(d)",
        "Division: 60,000 digits": "f.over(e)",
        "Exponentiation: 5 ^ 22": "_5.pow(_22)",
        "Exponentiation: 5 ^ 23": "_5.pow(_23)",
        "Exponentiation: 5 ^ 12345": "_5.pow(s1)",
        "Exponentiation: 12345 ^ 12345": "s1.pow(s1)",
        "parseInt: 5 decimal digits": "parseInt(s1_str, 10)",
        "parseInt: 100 decimal digits": "parseInt(a_str, 10)",
        "parseInt: 2,000 decimal digits": "parseInt(d_str, 10)",
        "parseInt: 20,000 decimal digits": "parseInt(e_str, 10)",
        "parseInt: 5 hex digits": "parseInt(s1_str, 16)",
        "parseInt: 83 hex digits": "parseInt(a_str, 16)",
        "parseInt: 1,661 hex digits": "parseInt(d_str, 16)",
        "parseInt: 16,610 hex digits": "parseInt(e_str, 16)",
        "toString: 5 decimal digits": "s1.toString(10)",
        "toString: 100 decimal digits": "a.toString(10)",
        "toString: 2,000 decimal digits": "d.toString(10)",
        "toString: 20,000 decimal digits": "e.toString(10)",
        "toString: 5 hex digits": "s2.toString(16)",
        "toString: 83 hex digits": "a.toString(16)",
        "toString: 1,661 hex digits": "d.toString(16)",
        "toString: 16,610 hex digits": "e.toString(16)"
    };

    function generateTests(transformation, skip) {
        skip = skip || [];
        var t = {};
        for (var i in tests) {
            if (skip.indexOf(i.split(":")[0]) > -1) continue;
            t[i] = transformation(tests[i]);
        };
        return t;
    }

    var libraries = {
        "Peter Olson BigInteger.js": {
            url: ["../BigInteger.js"],
            projectURL: "https://github.com/peterolson/BigInteger.js",
            onStart: createInitialization("bigInt"),
            tests: generateTests(function (x) { return x.replace("parseInt", "bigInt"); })
        },
        "Yaffle BigInteger": {
            url: ["https://rawgit.com/Yaffle/BigInteger/gh-pages/BigInteger.js"],
            projectURL: "https://github.com/Yaffle/BigInteger",
            onStart: createInitialization("BigInteger.BigInt"),
            tests: generateTests(function (x) {
                return x
                .replace(/([_a-zA-Z0-9]+)\.add\(([_a-zA-Z0-9]+)\)/g, "BigInteger.add($1, $2)")
                .replace(/([_a-zA-Z0-9]+)\.minus\(([_a-zA-Z0-9]+)\)/g, "BigInteger.subtract($1, $2)")
                .replace(/([_a-zA-Z0-9]+)\.times\(([_a-zA-Z0-9]+)\)/g, "BigInteger.multiply($1, $2)")
                .replace(/([_a-zA-Z0-9]+)\.over\(([_a-zA-Z0-9]+)\)/g, "BigInteger.divide($1, $2)")
                .replace(/([_a-zA-Z0-9]+)\.square\(\)/g, "BigInteger.multiply($1, $1)")
                .replace(/([_a-zA-Z0-9]+)\.toString\(([_a-zA-Z0-9]+)\)/g, "($1).toString($2)")
                .replace(/parseInt\(([_a-zA-Z0-9]+),\s*16\)/g, "BigInteger.BigInt('0x' + $1)")
                .replace(/parseInt\(([_a-zA-Z0-9]+),\s*10\)/g, "BigInteger.BigInt($1)")
                .replace(/([_a-zA-Z0-9]+)\.pow\(([_a-zA-Z0-9]+)\)/g, "BigInteger.exponentiate($1, $2)");
            })
        },
        "ChromeLabs JSBI": {
            url: ["https://unpkg.com/jsbi@2.0.5/dist/jsbi-umd.js"],
            projectURL: "https://github.com/GoogleChromeLabs/jsbi",
            onStart: createInitialization("JSBI.BigInt"),
            tests: generateTests(function (x) {
                return x
                .replace(/([_a-zA-Z0-9]+)\.add\(([_a-zA-Z0-9]+)\)/g, "JSBI.add($1, $2)")
                .replace(/([_a-zA-Z0-9]+)\.minus\(([_a-zA-Z0-9]+)\)/g, "JSBI.subtract($1, $2)")
                .replace(/([_a-zA-Z0-9]+)\.times\(([_a-zA-Z0-9]+)\)/g, "JSBI.multiply($1, $2)")
                .replace(/([_a-zA-Z0-9]+)\.over\(([_a-zA-Z0-9]+)\)/g, "JSBI.divide($1, $2)")
                .replace(/([_a-zA-Z0-9]+)\.square\(\)/g, "JSBI.multiply($1, $1)")
                .replace(/([_a-zA-Z0-9]+)\.toString\(([_a-zA-Z0-9]+)\)/g, "($1).toString($2)")
                .replace(/parseInt\(([_a-zA-Z0-9]+),\s*16\)/g, "JSBI.BigInt('0x' + $1)")
                .replace(/parseInt\(([_a-zA-Z0-9]+),\s*10\)/g, "JSBI.BigInt($1)")
                .replace(/([_a-zA-Z0-9]+)\.pow\(([_a-zA-Z0-9]+)\)/g, "JSBI.exponentiate($1, $2)");
            })
        },
        "Tom Wu jsbn": {
            url: ["http://www-cs-students.stanford.edu/~tjw/jsbn/jsbn.js", "http://www-cs-students.stanford.edu/~tjw/jsbn/jsbn2.js"],
            projectURL: "http://www-cs-students.stanford.edu/~tjw/jsbn/",
            onStart: createInitialization("new BigInteger"),
            tests: generateTests(function (x) {
                return x.replace(/\.minus/g, ".subtract")
                .replace(/\.times/g, ".multiply")
                .replace(/\.over/g, ".divide")
                .replace("parseInt", "new BigInteger");
            })
        },
        "Fedor Indutny bn.js": {
            url: ["https://rawgit.com/indutny/bn.js/master/lib/bn.js"],
            projectURL: "https://github.com/indutny/bn.js",
            onStart: createInitialization("new BN"),
            tests: generateTests(function (x) {
                return x.replace(/\.minus/g, ".sub")
                .replace(/\.times/g, ".mul")
                .replace(/(.+)\.square\(\)/g, "$1.mul($1)")
                .replace(/\.over/g, ".div")
                .replace("parseInt", "new BN");
            }, ["Exponentiation"])
        },
        "MikeMcl bignumber.js": {
            url: ["https://rawgit.com/MikeMcl/bignumber.js/master/bignumber.min.js"],
            projectURL: "http://mikemcl.github.io/bignumber.js/",
            onStart: createInitialization("new BigNumber") + "BigNumber.config({POW_PRECISION: 0});",
            tests: generateTests(function (x) {
                return x.replace(/\.over/g, ".div")
                .replace(/(.+)\.square\(\)/g, "$1.times($1)")
                .replace("parseInt", "new BigNumber");
            })
        }/*, // Leemon Baird library link is broken
        "Leemon Baird BigInt.js": {
            url: ["http://www.leemon.com/crypto/BigInt.js"],
            projectURL: "http://www.leemon.com/crypto/BigInt.html",
            onStart: createInitialization("str2bigInt", ",10"),
            onCycle: createOnCycle(function (v) {
                return v + "=" + v + ".concat()";
            }),
            tests: generateTests(function(x) {
                return x.replace(/(\w+)\.add\(([^\)]*)\)/g, "add($1, $2)")
                .replace(/(\w+)\.minus\(([^\)]*)\)/g, "sub($1, $2)")
                .replace(/(\w+)\.times\(([^\)]*)\)/g, "mult($1, $2)")
                .replace(/(\w+)\.over\(([^\)]*)\)/g, "divInt_($1, $2)")
                .replace(/(\w+)\.square\(([^\)]*)\)/g, "mult($1, $1)")
                .replace("parseInt", "str2bigInt")
                .replace(/(\w+)\.toString\(([^\)]*)\)/g, "bigInt2str($1, $2)")
            }, ["Exponentiation"])
        }*/
    };
    return libraries;
})();
<commit_msg>remove broken link<commit_after>var libraries = (function () {
  var a =
      "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
    b =
      "1234567890234567890134567890124567890123567890123467890123457890123456890123456790123456780123456789",
    c =
      "98109840984098409156481068456541684065964819841065106865710397464513210416435401645030648036034063974065004951094209420942097421970490274195049120974210974209742190274092740492097420929892490974202241",
    d = c + c + c + c + c + c + c + c + c + c,
    e = d + d + d + d + d + d + d + d + d + d,
    f = e + e + e,
    c2 = a + b,
    d2 = c2 + c2 + c2 + c2 + c2 + c2 + c2 + c2 + c2 + c2,
    e2 = d2 + d2 + d2 + d2 + d2 + d2 + d2 + d2 + d2 + d2,
    f2 = e2 + e2 + e2,
    s1 = 12345,
    s2 = 98765,
    s3 = 5437654,
    _5 = 5,
    _22 = 22,
    _23 = 23;
  var vars = {
    a: a,
    b: b,
    c: c,
    d: d,
    e: e,
    f: f,
    c2: c2,
    d2: d2,
    e2: e2,
    f2: f2,
    s1: s1,
    s2: s2,
    s3: s3,
    _5: _5,
    _22: _22,
    _23: _23,
  };

  var createInitialization = function (fName, radix) {
    var str = "";
    radix = radix || "";
    for (var i in vars) {
      str +=
        i +
        "=" +
        fName +
        "('" +
        vars[i] +
        "'" +
        radix +
        ");" +
        i +
        "_str='" +
        vars[i] +
        "';";
    }
    return str;
  };

  var createOnCycle = function (f) {
    var str = "";
    for (var i in vars) {
      str += f(i) + ";";
    }
    return str;
  };

  var tests = {
    "Addition: large1 + large2": "a.add(b)",
    "Addition: large + small": "a.add(s1)",
    "Addition: small + large": "s1.add(a)",
    "Addition: small1 + small2": "s1.add(s2)",
    "Addition: 200 digits": "c.add(c2)",
    "Addition: 2,000 digits": "d.add(d2)",
    "Addition: 20,000 digits": "e.add(e2)",
    "Addition: 60,000 digits": "f.add(f2)",
    "Subtraction: large1 - large2": "b.minus(a)",
    "Subtraction: large - small": "b.minus(s1)",
    "Subtraction: small - large": "s1.minus(b)",
    "Subtraction: small - small": "s2.minus(s1)",
    "Subtraction: 200 digits": "c.minus(c2)",
    "Subtraction: 2,000 digits": "d.minus(d2)",
    "Subtraction: 20,000 digits": "e.minus(e2)",
    "Subtraction: 60,000 digits": "f.minus(f2)",
    "Multiplication: large * large": "a.times(b)",
    "Multiplication: large * small": "a.times(s1)",
    "Multiplication: small * large": "s1.times(a)",
    "Multiplication: small1 * small2": "s1.times(s2)",
    "Multiplication: 400 digits": "c.times(b)",
    "Multiplication: 2,200 digits": "d.times(c)",
    "Multiplication: 22,000 digits": "e.times(d)",
    "Multiplication: 82,000 digits": "f.times(e)",
    "Squaring: small": "s1.square()",
    "Squaring: 200 digits": "a.square()",
    "Squaring: 400 digits": "c.square()",
    "Squaring: 4,000 digits": "d.square()",
    "Squaring: 40,000 digits": "e.square()",
    "Division: large1 / large2": "b.over(a)",
    "Division: large / small": "a.over(s1)",
    "Division: small / large": "s2.over(b)",
    "Division: small / small": "s2.over(s1)",
    "Division: 200 digits": "c.over(b)",
    "Division: 2,000 digits": "d.over(c)",
    "Division: 20,000 digits": "e.over(d)",
    "Division: 60,000 digits": "f.over(e)",
    "Exponentiation: 5 ^ 22": "_5.pow(_22)",
    "Exponentiation: 5 ^ 23": "_5.pow(_23)",
    "Exponentiation: 5 ^ 12345": "_5.pow(s1)",
    "Exponentiation: 12345 ^ 12345": "s1.pow(s1)",
    "parseInt: 5 decimal digits": "parseInt(s1_str, 10)",
    "parseInt: 100 decimal digits": "parseInt(a_str, 10)",
    "parseInt: 2,000 decimal digits": "parseInt(d_str, 10)",
    "parseInt: 20,000 decimal digits": "parseInt(e_str, 10)",
    "parseInt: 5 hex digits": "parseInt(s1_str, 16)",
    "parseInt: 83 hex digits": "parseInt(a_str, 16)",
    "parseInt: 1,661 hex digits": "parseInt(d_str, 16)",
    "parseInt: 16,610 hex digits": "parseInt(e_str, 16)",
    "toString: 5 decimal digits": "s1.toString(10)",
    "toString: 100 decimal digits": "a.toString(10)",
    "toString: 2,000 decimal digits": "d.toString(10)",
    "toString: 20,000 decimal digits": "e.toString(10)",
    "toString: 5 hex digits": "s2.toString(16)",
    "toString: 83 hex digits": "a.toString(16)",
    "toString: 1,661 hex digits": "d.toString(16)",
    "toString: 16,610 hex digits": "e.toString(16)",
  };

  function generateTests(transformation, skip) {
    skip = skip || [];
    var t = {};
    for (var i in tests) {
      if (skip.indexOf(i.split(":")[0]) > -1) continue;
      t[i] = transformation(tests[i]);
    }
    return t;
  }

  var libraries = {
    "Peter Olson BigInteger.js": {
      url: ["../BigInteger.js"],
      projectURL: "https://github.com/peterolson/BigInteger.js",
      onStart: createInitialization("bigInt"),
      tests: generateTests(function (x) {
        return x.replace("parseInt", "bigInt");
      }),
    },
    "Yaffle BigInteger": {
      url: ["https://rawgit.com/Yaffle/BigInteger/gh-pages/BigInteger.js"],
      projectURL: "https://github.com/Yaffle/BigInteger",
      onStart: createInitialization("BigInteger.BigInt"),
      tests: generateTests(function (x) {
        return x
          .replace(
            /([_a-zA-Z0-9]+)\.add\(([_a-zA-Z0-9]+)\)/g,
            "BigInteger.add($1, $2)"
          )
          .replace(
            /([_a-zA-Z0-9]+)\.minus\(([_a-zA-Z0-9]+)\)/g,
            "BigInteger.subtract($1, $2)"
          )
          .replace(
            /([_a-zA-Z0-9]+)\.times\(([_a-zA-Z0-9]+)\)/g,
            "BigInteger.multiply($1, $2)"
          )
          .replace(
            /([_a-zA-Z0-9]+)\.over\(([_a-zA-Z0-9]+)\)/g,
            "BigInteger.divide($1, $2)"
          )
          .replace(
            /([_a-zA-Z0-9]+)\.square\(\)/g,
            "BigInteger.multiply($1, $1)"
          )
          .replace(
            /([_a-zA-Z0-9]+)\.toString\(([_a-zA-Z0-9]+)\)/g,
            "($1).toString($2)"
          )
          .replace(
            /parseInt\(([_a-zA-Z0-9]+),\s*16\)/g,
            "BigInteger.BigInt('0x' + $1)"
          )
          .replace(
            /parseInt\(([_a-zA-Z0-9]+),\s*10\)/g,
            "BigInteger.BigInt($1)"
          )
          .replace(
            /([_a-zA-Z0-9]+)\.pow\(([_a-zA-Z0-9]+)\)/g,
            "BigInteger.exponentiate($1, $2)"
          );
      }),
    },
    "ChromeLabs JSBI": {
      url: ["https://unpkg.com/jsbi@2.0.5/dist/jsbi-umd.js"],
      projectURL: "https://github.com/GoogleChromeLabs/jsbi",
      onStart: createInitialization("JSBI.BigInt"),
      tests: generateTests(function (x) {
        return x
          .replace(
            /([_a-zA-Z0-9]+)\.add\(([_a-zA-Z0-9]+)\)/g,
            "JSBI.add($1, $2)"
          )
          .replace(
            /([_a-zA-Z0-9]+)\.minus\(([_a-zA-Z0-9]+)\)/g,
            "JSBI.subtract($1, $2)"
          )
          .replace(
            /([_a-zA-Z0-9]+)\.times\(([_a-zA-Z0-9]+)\)/g,
            "JSBI.multiply($1, $2)"
          )
          .replace(
            /([_a-zA-Z0-9]+)\.over\(([_a-zA-Z0-9]+)\)/g,
            "JSBI.divide($1, $2)"
          )
          .replace(/([_a-zA-Z0-9]+)\.square\(\)/g, "JSBI.multiply($1, $1)")
          .replace(
            /([_a-zA-Z0-9]+)\.toString\(([_a-zA-Z0-9]+)\)/g,
            "($1).toString($2)"
          )
          .replace(
            /parseInt\(([_a-zA-Z0-9]+),\s*16\)/g,
            "JSBI.BigInt('0x' + $1)"
          )
          .replace(/parseInt\(([_a-zA-Z0-9]+),\s*10\)/g, "JSBI.BigInt($1)")
          .replace(
            /([_a-zA-Z0-9]+)\.pow\(([_a-zA-Z0-9]+)\)/g,
            "JSBI.exponentiate($1, $2)"
          );
      }),
    },
    "Tom Wu jsbn": {
      url: [
        "http://www-cs-students.stanford.edu/~tjw/jsbn/jsbn.js",
        "http://www-cs-students.stanford.edu/~tjw/jsbn/jsbn2.js",
      ],
      projectURL: "http://www-cs-students.stanford.edu/~tjw/jsbn/",
      onStart: createInitialization("new BigInteger"),
      tests: generateTests(function (x) {
        return x
          .replace(/\.minus/g, ".subtract")
          .replace(/\.times/g, ".multiply")
          .replace(/\.over/g, ".divide")
          .replace("parseInt", "new BigInteger");
      }),
    },
    "Fedor Indutny bn.js": {
      url: ["https://rawgit.com/indutny/bn.js/master/lib/bn.js"],
      projectURL: "https://github.com/indutny/bn.js",
      onStart: createInitialization("new BN"),
      tests: generateTests(
        function (x) {
          return x
            .replace(/\.minus/g, ".sub")
            .replace(/\.times/g, ".mul")
            .replace(/(.+)\.square\(\)/g, "$1.mul($1)")
            .replace(/\.over/g, ".div")
            .replace("parseInt", "new BN");
        },
        ["Exponentiation"]
      ),
    },
  };
  return libraries;
})();
<|endoftext|>


<commit_before>// @flow
/* eslint-disable camelcase */
import electron from 'electron';
import Config from 'electron-config';
import Pixiv from 'pixiv.js';
import appMenu from './menu';

const {app, BrowserWindow, ipcMain, shell} = electron;
let mainWindow;

require('electron-context-menu')();
require('electron-referer')('http://www.pixiv.net/');

function openTweet(url: string) {
	const win = new BrowserWindow({width: 600, height: 400});

	require('electron-referer')('https://twitter.com', win);

	const page = win.webContents;

	page.on('will-navigate', (event, url) => {
		if (/twitter\.com\/intent\/tweet\/complete/.test(url)) {
			win.close();
			require('electron-referer')('http://www.pixiv.net');
		}

		event.preventDefault();
	});

	win.loadURL(url);
}

if (process.env.NODE_ENV === 'development') {
	require('electron-debug')();
}

const config = new Config({
	defaults: {
		bounds: {
			width: 960,
			height: 680
		}
	}
});

function createMainWindow() {
	const lastWindowState = config.get('bounds');
	const win = new BrowserWindow({
		title: 'PixivDeck',
		width: lastWindowState.width,
		height: lastWindowState.height,
		x: lastWindowState.x,
		y: lastWindowState.y
	});

	if (process.env.NODE_ENV === 'development') {
		const loadExtensions = async () => {
			const installExtension = require('electron-devtools-installer');

			const install = installExtension.default;
			try {
				await install(installExtension.REACT_DEVELOPER_TOOLS);
				await install(installExtension.REDUX_DEVTOOLS);
			} catch (err) {
				console.error(err);
			}
		};

		loadExtensions();
	}

	win.loadURL(`file://${__dirname}/app/app.html`);

	win.on('closed', () => {
		mainWindow = null;
	});

	['resize', 'move'].forEach(ev => {
		win.on(ev, () => {
			config.set('bounds', win.getBounds());
		});
	});

	const {webContents} = win;
	webContents.on('new-window', (event: Event, url: string) => {
		if (/intent\/twitter/.test(url)) {
			return;
		}
		event.preventDefault();
		shell.openExternal(url);
	});

	return win;
}

app.on('window-all-closed', () => {
	if (process.platform !== 'darwin') {
		app.quit();
	}
});

app.on('activate', () => {
	if (!mainWindow) {
		mainWindow = createMainWindow();
	}
});

app.on('ready', () => {
	mainWindow = createMainWindow();
	const page = mainWindow.webContents;

	electron.Menu.setApplicationMenu(appMenu);

	const auth = config.get('auth');
	let pixiv;

	page.on('dom-ready', () => {
		if (!(auth && auth.name && auth.password)) {
			page.send('logout');
		}
	});

	ipcMain.on('INIT', ev => {
		if (auth && auth.remember && auth.name && auth.password) {
			const {name, password} = auth;
			pixiv = new Pixiv(name, password);
			ev.sender.send('SUCCESS_LOGINED');
		}
	});

	ipcMain.on('LOGIN', (ev, {name, password}) => {
		pixiv = new Pixiv(name, password);
		ev.sender.send('SUCCESS_LOGINED');
		config.set('auth', {name, password, remember: true});
	});

	ipcMain.on('ranking', async (ev, {id, opts}) => {
		const res = await pixiv.ranking('all', Object.assign({page: 1, per_page: 50, include_sanity_level: true}, opts));
		ev.sender.send('ranking', {id, res: res.response[0]});
	});

	ipcMain.on('favoriteWorks', async (ev, {id, opts}) => {
		const res = await pixiv.favoriteWorks(Object.assign({}, {per_page: 50, include_stats: true}, opts));
		ev.sender.send('favoriteWorks', {id, res});
	});

	ipcMain.on('search', async (ev, {id, q, opts}) => {
		const res = await pixiv.search(q, Object.assign({}, {mode: 'tag', per_page: 20}, opts));
		ev.sender.send('search', {id, res});
	});

	ipcMain.on('userWorks', async (ev, {id, userID, opts}) => {
		const res = await pixiv.usersWorks(userID, opts);
		ev.sender.send('userWorks', {id, res});
	});

	ipcMain.on('work', async (ev, id) => {
		const res = await pixiv.works(id);
		ev.sender.send('work', res);
	});

	ipcMain.on('tweet', (ev, url) => {
		openTweet(url);
	});
});
<commit_msg>Change referer setting<commit_after>// @flow
/* eslint-disable camelcase */
import electron from 'electron';
import Config from 'electron-config';
import Pixiv from 'pixiv.js';
import referer from 'electron-referer';
import appMenu from './menu';

const {app, BrowserWindow, ipcMain, shell} = electron;
let mainWindow;

require('electron-context-menu')();

function openTweet(url: string) {
	const win = new BrowserWindow({width: 600, height: 400});

	referer('https://twitter.com', win);

	const page = win.webContents;

	page.on('will-navigate', (event, url) => {
		if (/twitter\.com\/intent\/tweet\/complete/.test(url)) {
			win.close();
		}

		event.preventDefault();
	});

	win.loadURL(url);
}

if (process.env.NODE_ENV === 'development') {
	require('electron-debug')();
}

const config = new Config({
	defaults: {
		bounds: {
			width: 960,
			height: 680
		}
	}
});

function createMainWindow() {
	const lastWindowState = config.get('bounds');
	const win = new BrowserWindow({
		title: 'PixivDeck',
		width: lastWindowState.width,
		height: lastWindowState.height,
		x: lastWindowState.x,
		y: lastWindowState.y
	});

	if (process.env.NODE_ENV === 'development') {
		const loadExtensions = async () => {
			const installExtension = require('electron-devtools-installer');

			const install = installExtension.default;
			try {
				await install(installExtension.REACT_DEVELOPER_TOOLS);
				await install(installExtension.REDUX_DEVTOOLS);
			} catch (err) {
				console.error(err);
			}
		};

		loadExtensions();
	}

	win.loadURL(`file://${__dirname}/app/app.html`);

	win.on('closed', () => {
		mainWindow = null;
	});

	['resize', 'move'].forEach(ev => {
		win.on(ev, () => {
			config.set('bounds', win.getBounds());
		});
	});

	const {webContents} = win;

	webContents.on('did-finish-load', () => {
		referer('http://www.pixiv.net', win);
	});

	webContents.on('new-window', (event: Event, url: string) => {
		if (/intent\/twitter/.test(url)) {
			return;
		}
		event.preventDefault();
		shell.openExternal(url);
	});

	return win;
}

app.on('window-all-closed', () => {
	if (process.platform !== 'darwin') {
		app.quit();
	}
});

app.on('activate', () => {
	if (!mainWindow) {
		mainWindow = createMainWindow();
	}
});

app.on('ready', () => {
	mainWindow = createMainWindow();
	const page = mainWindow.webContents;

	electron.Menu.setApplicationMenu(appMenu);

	const auth = config.get('auth');
	let pixiv;

	page.on('dom-ready', () => {
		if (!(auth && auth.name && auth.password)) {
			page.send('logout');
		}
	});

	ipcMain.on('INIT', ev => {
		if (auth && auth.remember && auth.name && auth.password) {
			const {name, password} = auth;
			pixiv = new Pixiv(name, password);
			ev.sender.send('SUCCESS_LOGINED');
		}
	});

	ipcMain.on('LOGIN', (ev, {name, password}) => {
		pixiv = new Pixiv(name, password);
		ev.sender.send('SUCCESS_LOGINED');
		config.set('auth', {name, password, remember: true});
	});

	ipcMain.on('ranking', async (ev, {id, opts}) => {
		const res = await pixiv.ranking('all', Object.assign({page: 1, per_page: 50, include_sanity_level: true}, opts));
		ev.sender.send('ranking', {id, res: res.response[0]});
	});

	ipcMain.on('favoriteWorks', async (ev, {id, opts}) => {
		const res = await pixiv.favoriteWorks(Object.assign({}, {per_page: 50, include_stats: true}, opts));
		ev.sender.send('favoriteWorks', {id, res});
	});

	ipcMain.on('search', async (ev, {id, q, opts}) => {
		const res = await pixiv.search(q, Object.assign({}, {mode: 'tag', per_page: 20}, opts));
		ev.sender.send('search', {id, res});
	});

	ipcMain.on('userWorks', async (ev, {id, userID, opts}) => {
		const res = await pixiv.usersWorks(userID, opts);
		ev.sender.send('userWorks', {id, res});
	});

	ipcMain.on('work', async (ev, id) => {
		const res = await pixiv.works(id);
		ev.sender.send('work', res);
	});

	ipcMain.on('tweet', (ev, url) => {
		openTweet(url);
	});
});
<|endoftext|>


<commit_before>(function () {
    vohApp.controller('stylistCtrl', ['$scope', '$stateParams', '$anchorScroll', '$location', 'usersService', function ($scope, $stateParams, $anchorScroll, $location, usersService) {

        //Function to check if $stateParams is empty
        function isEmpty(obj) {
            for (var prop in obj) {
                if (obj.hasOwnProperty(prop))
                    return false;
            }

            return true && JSON.stringify(obj) === JSON.stringify({});
        }

        //Find Stylists That Are Featured
        function findFeaturedStylists() {
            var featuredStylists = _.filter(stylists, {
                'featured': true
            });
            return featuredStylists;
        }

        $scope.stylists = findFeaturedStylists();

        $scope.startedSearch = function(hairstyle) {
            $scope.stylists = findSpecialties(stylists, hairstyle);
        };

        $scope.goToStylistHeader = function () {
            $location.hash('top-header');
            $anchorScroll();
        };

        //Find Stylists that do certain haircuts
        function findSpecialties(stylistsArg, pickedStyle) {
            var specialStylists = _.chain(stylistsArg)
                .filter(function (item) {

                    var singleStylist = _.chain(item.specialty).filter(function (hairstyle) {
                        if (hairstyle === pickedStyle) {
                            return true;
                        } else {
                            return false;
                        }
                    }).value();

                    if (singleStylist.length !== 0) {
                        return item;
                    }

                })
                .value();

            return specialStylists;
        }

        //Data Object for Find Stylists Drop Down Menu Selections
        $scope.data = {
            hairstyle: null,
            location: null
        };

        // Function for when the user chooses options in the Hero Dropdown in Find Stylists page
        $scope.searchForStylists = function (location, hairstyle) {
            if (hairstyle === null) {
                var locationArray = location.split(', ');
                var stylistsInLocation = findLocation(locationArray[0], locationArray[1]);
                $scope.stylists = stylistsInLocation;
            } else if (location === null) {
                var stylistsSpecialty = findSpecialties(stylists, hairstyle);
                $scope.stylists = stylistsSpecialty;
            } else {
                var locationArray = location.split(', ');
                var stylistsInLocation = findLocation(locationArray[0], locationArray[1]);
                $scope.stylists = findSpecialties(stylistsInLocation, hairstyle);
            }
            return $scope.stylists;
        };

        //Find stylists by city and state
        function findLocation(city, state) {
            var stylistsInLocation = _.chain(stylists)
                .filter(function (item) {
                    if (item.city === city) {
                        if (item.state === state) {
                            return item;
                        }
                    }
                })
                .value();
            return stylistsInLocation;
        }

        //Move featured stylists to the top
        function featuredFirst(pikachu) {
            var stylistsArray = [];
            var formattedStylists = _.chain(pikachu).filter(function (item) {
                if (item.featured === true) {
                    return stylistsArray.push(item);
                }
            }).value();
            pikachu.unshift(formattedStylists);
            return _.flattenDeep(pikachu);
        }

        //================ Single Stylist Logic ==================//
        if(!isEmpty($stateParams)) {
            console.log($stateParams);
            _.chain(stylists).filter(function(item) {
                if(item.id === Number($stateParams.id)) {
                    $scope.stylist = item;
                }
            }).value();

            $scope.registered = usersService.loggedIn;

            $scope.$on('userAuthentication', function() {
                $scope.registered = usersService.loggedIn;
            });

        }

    }]);
}());<commit_msg>Injected services and dropdown component logic<commit_after>(function () {
    vohApp.controller('stylistCtrl', ['$scope', '$stateParams', '$anchorScroll', '$location', 'usersService', '$sce', function ($scope, $stateParams, $anchorScroll, $location, usersService, $sce) {

        //Function to check if $stateParams is empty
        function isEmpty(obj) {
            for (var prop in obj) {
                if (obj.hasOwnProperty(prop))
                    return false;
            }

            return true && JSON.stringify(obj) === JSON.stringify({});
        }

        //Data Object for Find Stylists Drop Down Menu Selections
        $scope.data = {
            specialties: [],
            locations: []
        };

        //Find Stylists That Are Featured
        function findFeaturedStylists() {
            var featuredStylists = _.filter(stylistsList, {
                'featured': true
            });
            return featuredStylists;
        }

        $scope.stylists = findFeaturedStylists();

        $scope.startedSearch = function(hairstyle) {
            $scope.stylists = findSpecialties(stylistsList, hairstyle);
        };

        $scope.goToStylistHeader = function () {
            $location.hash('top-header');
            $anchorScroll();
        };

        //Function that feeds Locations to the Find Stylist Dropdown Component
        function loadLocations() {

            var stylistLocation;

            _.filter(stylistsList, function(item) {
                var stylistCity = item.city;
                var stylistState = item.state;
                //Create Location string i.e Houston, TX
                stylistLocation = stylistCity + ', ' + stylistState;

                if($scope.data.locations.length === 0) {
                    $scope.data.locations.push(stylistLocation);
                } else {
                    var isInArray = _.indexOf($scope.data.locations, stylistLocation);
                    if(isInArray === -1) {
                        $scope.data.locations.push(stylistLocation);
                    }
                }
            });
        }

        //Fire function for Find Stylist Location Dropdown
        loadLocations();

        //Function that feeds Specialties to the Find Stylist Dropdown Component
        function loadSpecialties() {

            var stylistSpecialties;

            _.filter(stylistsList, function(item) {

                _.filter(item.specialties, function(specialty) {
                    if ($scope.data.specialties.length === 0) {
                        $scope.data.specialties.push(specialty);
                    } else {
                        var isInArray = _.indexOf($scope.data.specialties, specialty);
                        if (isInArray === -1) {
                            $scope.data.specialties.push(specialty);
                        }
                    }
                });
            });
        }

        //Fire function for Find Stylist specialties dropdown component
        loadSpecialties();

        //Find Stylists that do certain haircuts
        function findSpecialties(stylistsArg, pickedStyle) {
            var specialStylists = _.chain(stylistsArg)
                .filter(function (item) {
                    var singleStylist = _.chain(item.specialties).filter(function (hairstyle) {
                        if (hairstyle === pickedStyle) {
                            return true;
                        } else {
                            return false;
                        }
                    }).value();

                    if (singleStylist.length !== 0) {
                        $scope.noResults = false;
                        return item;
                    } else {
                        $scope.noResults = true;
                    }

                })
                .value();

            return specialStylists;
        }

        $scope.specialty = '';
        $scope.location = '';

        // Function for when the user chooses options in the Hero Dropdown in Find Stylists page
        $scope.searchForStylists = function (location, hairstyle) {
            if(location === '' && hairstyle === '') {
                $scope.stylists = findFeaturedStylists();
            } else if (hairstyle === '') {
                var locationArray = location.split(', ');
                var stylistsInLocation = findLocation(locationArray[0], locationArray[1]);
                $scope.stylists = stylistsInLocation;
            } else if (location === '') {
                var stylistsSpecialty = findSpecialties(stylistsList, hairstyle);
                $scope.stylists = stylistsSpecialty;
            } else {
                var locationArray = location.split(', ');
                var stylistsInLocation = findLocation(locationArray[0], locationArray[1]);
                console.log('stylistInLocation, '. stylistsInLocation);
                $scope.stylists = findSpecialties(stylistsInLocation, hairstyle);

            }
            return $scope.stylists;
        };

        //Find stylists by city and state
        function findLocation(city, state) {
            var stylistsInLocation = _.chain(stylistsList)
                .filter(function (item) {
                    if (item.city === city) {
                        if (item.state === state) {
                            console.log(item);
                            return item;
                        }
                    }
                })
                .value();
            return stylistsInLocation;
        }

        //Move featured stylists to the top
        function featuredFirst(pikachu) {
            var stylistsArray = [];
            var formattedStylists = _.chain(pikachu).filter(function (item) {
                if (item.featured === true) {
                    return stylistsArray.push(item);
                }
            }).value();
            pikachu.unshift(formattedStylists);
            return _.flattenDeep(pikachu);
        }

        //================ Single Stylist Logic ==================//
        if(!isEmpty($stateParams)) {
            _.chain(stylistsList).filter(function(item) {
                if(item.id === Number($stateParams.id)) {
                    $scope.stylist = item;
                    $scope.stylistBio = $sce.trustAsHtml($scope.stylist.bio);
                }
            }).value();

            $scope.registered = usersService.loggedIn;

            $scope.$on('userAuthentication', function() {
                $scope.registered = usersService.loggedIn;
            });
        }

    }]);
}());<|endoftext|>


<commit_before>import { LightningElement, wire, track } from "lwc";
import { refreshApex } from "@salesforce/apex";

import getContactLanguageSettingsVModel from "@salesforce/apex/ContactInfoSettingsController.getContactLanguageSettingsVModel";
import getPreferredContactInfoSettingsVModel from "@salesforce/apex/ContactInfoSettingsController.getPreferredContactInfoSettingsVModel";

import stgContactInformationSettingsTitle from "@salesforce/label/c.stgContactInformationSettingsTitle";
import stgDefaultContactLanguageFluency from "@salesforce/label/c.stgDefaultContactLanguageFluency";
import stgHelpDefaultContactLanguageFluency from "@salesforce/label/c.stgHelpDefaultContactLanguageFluency";
import stgOptSelect from "@salesforce/label/c.stgOptSelect";
import stgDisablePreferredEmailEnforcement from "@salesforce/label/c.stgDisablePreferredEmailEnforcement";
import stgHelpContactPreferredEmail from "@salesforce/label/c.stgHelpContactPreferredEmail";
import stgEnablePreferredPhoneSync from "@salesforce/label/c.stgEnablePreferredPhoneSync";
import stgHelpContactPreferredPhoneSync from "@salesforce/label/c.stgHelpContactPreferredPhoneSync";
import stgDisablePreferredPhoneEnforcement from "@salesforce/label/c.stgDisablePreferredPhoneEnforcement";
import stgHelpContactPreferredPhone from "@salesforce/label/c.stgHelpContactPreferredPhone";
import stgPreferredPhoneDefault from "@salesforce/label/c.stgPreferredPhoneDefault";
import stgPreferredPhoneSelectionDesc from "@salesforce/label/c.stgPreferredPhoneSelectionDesc";

export default class ContactInformationSettings extends LightningElement {
    isEditMode = false;
    affordancesDisabledToggle = false;

    @track contactLanguageSettingsWireResult;
    @track contactLanguageSettingsVModel;

    @track preferredContactInfoSettingsWireResult;
    @track preferredContactInfoSettingsVModel;
    @track showPreferredPhoneEnforcement;

    labelReference = {
        contactInformationSettingsTitle: stgContactInformationSettingsTitle,
        contactLanguageDefaultFluencyTitle: stgDefaultContactLanguageFluency,
        contactLanguageDefaultFluencyDescription: stgHelpDefaultContactLanguageFluency,
        comboboxPlaceholderText: stgOptSelect,
        requirePreferredEmailTitle: stgDisablePreferredEmailEnforcement,
        requirePreferredEmailDescription: stgHelpContactPreferredEmail,
        enhancedPhoneFunctionalityTitle: stgEnablePreferredPhoneSync,
        enhancedPhoneFunctionalityDescription: stgHelpContactPreferredPhoneSync,
        preferredPhoneEnforcementTitle: stgDisablePreferredPhoneEnforcement,
        preferredPhoneEnforcementDescription: stgHelpContactPreferredPhone,
        defaultPreferredPhoneTitle: stgPreferredPhoneDefault,
        defaultPreferredPhoneDescription: stgPreferredPhoneSelectionDesc,
    };

    inputAttributeReference = {
        defaultContactLanugageFluencyComboboxId: "defaultContactLanguageFluency",
        requirePreferredEmailToggleId: "requirePreferredEmail",
        enhancedPhoneFunctionalityToggleId: "enhancedPhoneFunctionality",
        preferredPhoneEnforcementToggleId: "preferredPhoneEnforcement",
        defaultPreferredPhoneComboboxId: "defaultPreferredPhone",
    };

    get affordancesDisabled() {
        if (!this.isEditMode || this.affordancesDisabledToggle === true) {
            return true;
        }
        return undefined;
    }

    @wire(getContactLanguageSettingsVModel)
    contactLanguageSettingsVModelWire(result) {
        this.contactLanguageSettingsWireResult = result;

        if (result.data) {
            this.contactLanguageSettingsVModel = result.data;
        } else if (result.error) {
            //console.log("error retrieving contactLanguageSettingsVModel");
        }
    }

    @wire(getPreferredContactInfoSettingsVModel)
    preferredContactInfoSettingsVModelWire(result) {
        this.preferredContactInfoSettingsWireResult = result;

        if (result.data) {
            this.preferredContactInfoSettingsVModel = result.data;

            // preferred phone visibility dependent on enhanced phone functionality setting
            this.showPreferredPhoneEnforcement = this.preferredContactInfoSettingsVModel.enhancedPhoneFunctionality;
        } else if (result.error) {
            //console.log("error retrieving preferredContactInfoSettingsVModel");
        }
    }

    handleSettingsEditModeChange(event) {
        this.isEditMode = !event.detail;
        this.affordancesDisabledToggle = event.detail;
    }

    handleSettingsSaveCancel(event) {
        this.refreshAllApex();
    }

    handleSettingsSaving(event) {
        this.affordancesDisabledToggle = true;
        // TODO: perform client side validation

        // if validation fails, call this.handleValidationFailure()
        //this.template.querySelector("c-settings-save-canvas").handleValidationFailure();

        // else, update hierarchy settings
        this.template.querySelector("c-settings-save-canvas").updateHierarchySettings();
    }

    handleSettingsSaveCompleted(event) {
        this.affordancesDisabledToggle = false;
        this.refreshAllApex();
    }

    handleDefaultContactLanguageFluencyChange(event) {
        let hierarchySettingsChange = {
            settingsType: "string",
            settingsName: "Default_Contact_Language_Fluency__c",
            settingsValue: event.detail.value,
        };

        this.template.querySelector("c-settings-save-canvas").handleHierarchySettingsChange(hierarchySettingsChange);
    }

    handleRequirePreferredEmailChange(event) {
        const eventDetail = event.detail;

        let hierarchySettingsChange = {
            settingsType: "boolean",
            settingsName: "Disable_Preferred_Email_Enforcement__c",
            settingsValue: !eventDetail.value, // UI input should display inverse of value specified in hierarchy settings for this field
        };

        this.template.querySelector("c-settings-save-canvas").handleHierarchySettingsChange(hierarchySettingsChange);
    }

    handleEnhancedPhoneFunctionalityChange(event) {
        const eventDetail = event.detail;
        // display preferred phone setting if enhanced phone functionality selected
        this.showPreferredPhoneEnforcement = eventDetail.value;

        let hierarchySettingsChange = {
            settingsType: "boolean",
            settingsName: "Enable_New_Preferred_Phone_Sync__c",
            settingsValue: eventDetail.value,
        };

        this.template.querySelector("c-settings-save-canvas").handleHierarchySettingsChange(hierarchySettingsChange);
    }

    handlePreferredPhoneEnforcementChange(event) {
        const eventDetail = event.detail;

        let hierarchySettingsChange = {
            settingsType: "boolean",
            settingsName: "Disable_Preferred_Phone_Enforcement__c",
            settingsValue: !eventDetail.value, // UI input should display inverse of value specified in hierarchy settings for this field
        };

        this.template.querySelector("c-settings-save-canvas").handleHierarchySettingsChange(hierarchySettingsChange);
    }

    handleDefaultPreferredPhoneChange(event) {
        var defaultPreferredPhoneValue = event.detail.value;

        if (event.detail.value === '""') {
            // set Hierarchy Settings field to a blank value (not "")
            defaultPreferredPhoneValue = "";
        }

        let hierarchySettingsChange = {
            settingsType: "string",
            settingsName: "Preferred_Phone_Selection__c",
            settingsValue: defaultPreferredPhoneValue,
        };

        this.template.querySelector("c-settings-save-canvas").handleHierarchySettingsChange(hierarchySettingsChange);
    }

    refreshAllApex() {
        Promise.all([
            refreshApex(this.contactLanguageSettingsWireResult),
            refreshApex(this.preferredContactInfoSettingsWireResult),
        ]).then(() => {
            this.showPreferredPhoneEnforcement = this.preferredContactInfoSettingsVModel.enhancedPhoneFunctionality;

            this.template.querySelectorAll("c-settings-row-dual-listbox").forEach((dualListBox) => {
                dualListBox.resetValue();
            });
            this.template.querySelectorAll("c-settings-row-input").forEach((input) => {
                input.resetValue();
            });
        });
    }
}
<commit_msg>fixed enhanced phone functionality bug<commit_after>import { LightningElement, wire, track } from "lwc";
import { refreshApex } from "@salesforce/apex";

import getContactLanguageSettingsVModel from "@salesforce/apex/ContactInfoSettingsController.getContactLanguageSettingsVModel";
import getPreferredContactInfoSettingsVModel from "@salesforce/apex/ContactInfoSettingsController.getPreferredContactInfoSettingsVModel";

import stgContactInformationSettingsTitle from "@salesforce/label/c.stgContactInformationSettingsTitle";
import stgDefaultContactLanguageFluency from "@salesforce/label/c.stgDefaultContactLanguageFluency";
import stgHelpDefaultContactLanguageFluency from "@salesforce/label/c.stgHelpDefaultContactLanguageFluency";
import stgOptSelect from "@salesforce/label/c.stgOptSelect";
import stgDisablePreferredEmailEnforcement from "@salesforce/label/c.stgDisablePreferredEmailEnforcement";
import stgHelpContactPreferredEmail from "@salesforce/label/c.stgHelpContactPreferredEmail";
import stgEnablePreferredPhoneSync from "@salesforce/label/c.stgEnablePreferredPhoneSync";
import stgHelpContactPreferredPhoneSync from "@salesforce/label/c.stgHelpContactPreferredPhoneSync";
import stgDisablePreferredPhoneEnforcement from "@salesforce/label/c.stgDisablePreferredPhoneEnforcement";
import stgHelpContactPreferredPhone from "@salesforce/label/c.stgHelpContactPreferredPhone";
import stgPreferredPhoneDefault from "@salesforce/label/c.stgPreferredPhoneDefault";
import stgPreferredPhoneSelectionDesc from "@salesforce/label/c.stgPreferredPhoneSelectionDesc";

export default class ContactInformationSettings extends LightningElement {
    isEditMode = false;
    affordancesDisabledToggle = false;

    @track contactLanguageSettingsWireResult;
    @track contactLanguageSettingsVModel;

    @track preferredContactInfoSettingsWireResult;
    @track preferredContactInfoSettingsVModel;
    @track showPreferredPhoneEnforcement;

    labelReference = {
        contactInformationSettingsTitle: stgContactInformationSettingsTitle,
        contactLanguageDefaultFluencyTitle: stgDefaultContactLanguageFluency,
        contactLanguageDefaultFluencyDescription: stgHelpDefaultContactLanguageFluency,
        comboboxPlaceholderText: stgOptSelect,
        requirePreferredEmailTitle: stgDisablePreferredEmailEnforcement,
        requirePreferredEmailDescription: stgHelpContactPreferredEmail,
        enhancedPhoneFunctionalityTitle: stgEnablePreferredPhoneSync,
        enhancedPhoneFunctionalityDescription: stgHelpContactPreferredPhoneSync,
        preferredPhoneEnforcementTitle: stgDisablePreferredPhoneEnforcement,
        preferredPhoneEnforcementDescription: stgHelpContactPreferredPhone,
        defaultPreferredPhoneTitle: stgPreferredPhoneDefault,
        defaultPreferredPhoneDescription: stgPreferredPhoneSelectionDesc,
    };

    inputAttributeReference = {
        defaultContactLanugageFluencyComboboxId: "defaultContactLanguageFluency",
        requirePreferredEmailToggleId: "requirePreferredEmail",
        enhancedPhoneFunctionalityToggleId: "enhancedPhoneFunctionality",
        preferredPhoneEnforcementToggleId: "preferredPhoneEnforcement",
        defaultPreferredPhoneComboboxId: "defaultPreferredPhone",
    };

    get affordancesDisabled() {
        if (!this.isEditMode || this.affordancesDisabledToggle === true) {
            return true;
        }
        return undefined;
    }

    @wire(getContactLanguageSettingsVModel)
    contactLanguageSettingsVModelWire(result) {
        this.contactLanguageSettingsWireResult = result;

        if (result.data) {
            this.contactLanguageSettingsVModel = result.data;
        } else if (result.error) {
            //console.log("error retrieving contactLanguageSettingsVModel");
        }
    }

    @wire(getPreferredContactInfoSettingsVModel)
    preferredContactInfoSettingsVModelWire(result) {
        this.preferredContactInfoSettingsWireResult = result;

        if (result.data) {
            this.preferredContactInfoSettingsVModel = result.data;

            // preferred phone visibility dependent on enhanced phone functionality setting
            this.showPreferredPhoneEnforcement = this.preferredContactInfoSettingsVModel.enhancedPhoneFunctionality;
        } else if (result.error) {
            //console.log("error retrieving preferredContactInfoSettingsVModel");
        }
    }

    handleSettingsEditModeChange(event) {
        this.isEditMode = !event.detail;
        this.affordancesDisabledToggle = event.detail;
    }

    handleSettingsSaveCancel(event) {
        this.refreshAllApex();
    }

    handleSettingsSaving(event) {
        this.affordancesDisabledToggle = true;
        // TODO: perform client side validation

        // if validation fails, call this.handleValidationFailure()
        //this.template.querySelector("c-settings-save-canvas").handleValidationFailure();

        // else, update hierarchy settings
        this.template.querySelector("c-settings-save-canvas").updateHierarchySettings();
    }

    handleSettingsSaveCompleted(event) {
        this.affordancesDisabledToggle = false;
        this.refreshAllApex();
    }

    handleDefaultContactLanguageFluencyChange(event) {
        let hierarchySettingsChange = {
            settingsType: "string",
            settingsName: "Default_Contact_Language_Fluency__c",
            settingsValue: event.detail.value,
        };

        this.template.querySelector("c-settings-save-canvas").handleHierarchySettingsChange(hierarchySettingsChange);
    }

    handleRequirePreferredEmailChange(event) {
        const eventDetail = event.detail;

        let hierarchySettingsChange = {
            settingsType: "boolean",
            settingsName: "Disable_Preferred_Email_Enforcement__c",
            settingsValue: !eventDetail.value, // UI input should display inverse of value specified in hierarchy settings for this field
        };

        this.template.querySelector("c-settings-save-canvas").handleHierarchySettingsChange(hierarchySettingsChange);
    }

    handleEnhancedPhoneFunctionalityChange(event) {
        const eventDetail = event.detail;
        // display preferred phone setting if enhanced phone functionality selected
        this.showPreferredPhoneEnforcement = eventDetail.value;

        let hierarchySettingsChange = {
            settingsType: "boolean",
            settingsName: "Enable_New_Preferred_Phone_Sync__c",
            settingsValue: eventDetail.value,
        };

        this.template.querySelector("c-settings-save-canvas").handleHierarchySettingsChange(hierarchySettingsChange);
        if (!eventDetail.value) {
            this.handlePreferredPhoneEnforcementChange({ value: false });
        }
    }

    handlePreferredPhoneEnforcementChange(event) {
        const eventDetail = event.detail;

        let hierarchySettingsChange = {
            settingsType: "boolean",
            settingsName: "Disable_Preferred_Phone_Enforcement__c",
            settingsValue: !eventDetail.value, // UI input should display inverse of value specified in hierarchy settings for this field
        };

        this.template.querySelector("c-settings-save-canvas").handleHierarchySettingsChange(hierarchySettingsChange);
    }

    handleDefaultPreferredPhoneChange(event) {
        var defaultPreferredPhoneValue = event.detail.value;

        if (event.detail.value === '""') {
            // set Hierarchy Settings field to a blank value (not "")
            defaultPreferredPhoneValue = "";
        }

        let hierarchySettingsChange = {
            settingsType: "string",
            settingsName: "Preferred_Phone_Selection__c",
            settingsValue: defaultPreferredPhoneValue,
        };

        this.template.querySelector("c-settings-save-canvas").handleHierarchySettingsChange(hierarchySettingsChange);
    }

    refreshAllApex() {
        Promise.all([
            refreshApex(this.contactLanguageSettingsWireResult),
            refreshApex(this.preferredContactInfoSettingsWireResult),
        ]).then(() => {
            this.showPreferredPhoneEnforcement = this.preferredContactInfoSettingsVModel.enhancedPhoneFunctionality;

            this.template.querySelectorAll("c-settings-row-dual-listbox").forEach((dualListBox) => {
                dualListBox.resetValue();
            });
            this.template.querySelectorAll("c-settings-row-input").forEach((input) => {
                input.resetValue();
            });
        });
    }
}
<|endoftext|>


<commit_before>/**
 * Copyright 2013, 2015 IBM Corp.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Original and good work by IBM
 * "Big Nodes" mods by Jacques W
 *
 * /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 *
 *  Big Nodes principles:
 *
 *  #1 can handle big data
 *  #2 send start/end messages
 *  #3 tell what they are doing
 *
 *  Any issues? https://github.com/Jacques44
 *
 * /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 *
 **/

module.exports = function(RED) {

    "use strict";

    var biglib = require('node-red-biglib');

    // Definition of which options are known for spawning a command (ie node configutation to BigExec.spawn function)
    var spawn_options = {
      "command": "",                                                  // Command to execute
      "commandArgs": { value: "", validation: biglib.argument_to_array },    // Arguments from the configuration box
      "commandArgs2": { value: "", validation: biglib.argument_to_array },   // Payload as additional arguments if required
      "commandArgs3": { value: "", validation: biglib.argument_to_array },   // Extra argument from message if property set
      "minWarning": 1,                                                // The min return code the node will consider it is a warning
      "minError": 8,                                                  // The min return code the node will consider it is as an error
      "cwd": "",                                                      // The working directory
      "env": {},
      "shell": false,                                                 // Use a shell
      "noStdin": false                                                // Command does require an input (used to avoid EPIPE error)
    }

    function BigExec(config) {

      RED.nodes.createNode(this, config);

      // Arguments from configuration box are broken into a suitable array
      //config.commandArgs = argument_to_array(config.commandArgs);

      var spawn = function(my_config) {

        var spawn_config = {
          cwd: my_config.cwd,
          env: my_config.env,
          shell: my_config.shell
        }

        console.log(spawn_config);

        // This dummy writable is used when the command does not need any data on its stdin
        // If any data is coming, this stream drops it and no "EPIPE error" is thrown
        var dummy = biglib.dummy_writable(my_config.noStdin);

        this.working("Executing " + my_config.command.substr(0,20) + "...");

        console.log(my_config.commandArgs.concat(my_config.commandArgs2||[]).concat(my_config.commandArgs3||[]));

        // Here it is, the job is starting now
        var child = new require('child_process').spawn(my_config.command, my_config.commandArgs.concat(my_config.commandArgs2||[]).concat(my_config.commandArgs3||[]), spawn_config);

        // This to avoid "invalid chunk data" when payload is not a string
        var stringify = biglib.stringify_stream();
        stringify.pipe(child.stdin);

        var ret = require('event-stream').duplex(my_config.payloadIsArg ? dummy : stringify, child.stdout);
        //if (my_config.noStdin) child.stdin.end();

        ret.others = [ child.stderr ];

        child
          .on('exit', function(code, signal) {
            // Gives biglib extra informations using the "stats" function
            this.stats({ rc: code, signal: signal });
            ret.emit('my_finish');
          }.bind(this))
          .on('error', function(err) {
            console.log(err);
            ret.emit('error', err);
          })

        return ret;
      }

      // Custom progress function
      var progress = function(running) { return running ? "running for " + this.duration() : ("done with rc " + (this._runtime_control.rc != undefined ? this._runtime_control.rc : "?")) }

      // new instance of biglib for this configuration
      // probably the most tuned biglib I've asked ever...
      var bignode = new biglib({
        config: config, node: this,   // biglib needs to know the node configuration and the node itself (for statuses and sends)
        status: progress,             // define the kind of informations displayed while running
        parser_config: spawn_options, // the parser configuration (ie the known options the parser will understand)
        parser: spawn,                // the parser (ie the remote command)
        on_finish: biglib.min_finish, // custom on_finish handler
        finish_event: 'my_finish'     // custom finish event to listen to
      });

      // biglib changes the configuration to add some properties
      config = bignode.config();

      this.on('input', function(msg) {

        // Is payload an extra argument
        delete config.commandArgs2;
        if (config.payloadIsArg && msg.payload) {
          msg.config = msg.config || {};
          msg.config.commandArgs2 = msg.payload;

          // if not, the size_stream which streams to the command will throw EPIPE
          delete msg.payload;
        }

        if (config.extraArgumentProperty && msg[config.extraArgumentProperty]) {
          msg.config = msg.config || {};
          msg.config.commandArgs3 = msg[config.extraArgumentProperty];
        }

        if (config.envProperty && msg[config.envProperty]) {
          msg.config = msg.config || {};
          msg.config.env = msg[config.envProperty];
        }

        bignode.main.call(bignode, msg);
      })
    }

    RED.nodes.registerType("bigexec", BigExec);

}
<commit_msg>get rid of debug!<commit_after>/**
 * Copyright 2013, 2015 IBM Corp.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Original and good work by IBM
 * "Big Nodes" mods by Jacques W
 *
 * /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 *
 *  Big Nodes principles:
 *
 *  #1 can handle big data
 *  #2 send start/end messages
 *  #3 tell what they are doing
 *
 *  Any issues? https://github.com/Jacques44
 *
 * /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 *
 **/

module.exports = function(RED) {

    "use strict";

    var biglib = require('node-red-biglib');

    // Definition of which options are known for spawning a command (ie node configutation to BigExec.spawn function)
    var spawn_options = {
      "command": "",                                                  // Command to execute
      "commandArgs": { value: "", validation: biglib.argument_to_array },    // Arguments from the configuration box
      "commandArgs2": { value: "", validation: biglib.argument_to_array },   // Payload as additional arguments if required
      "commandArgs3": { value: "", validation: biglib.argument_to_array },   // Extra argument from message if property set
      "minWarning": 1,                                                // The min return code the node will consider it is a warning
      "minError": 8,                                                  // The min return code the node will consider it is as an error
      "cwd": "",                                                      // The working directory
      "env": {},
      "shell": false,                                                 // Use a shell
      "noStdin": false                                                // Command does require an input (used to avoid EPIPE error)
    }

    function BigExec(config) {

      RED.nodes.createNode(this, config);

      // Arguments from configuration box are broken into a suitable array
      //config.commandArgs = argument_to_array(config.commandArgs);

      var spawn = function(my_config) {

        var spawn_config = {
          cwd: my_config.cwd,
          env: my_config.env,
          shell: my_config.shell
        }

        // This dummy writable is used when the command does not need any data on its stdin
        // If any data is coming, this stream drops it and no "EPIPE error" is thrown
        var dummy = biglib.dummy_writable(my_config.noStdin);

        this.working("Executing " + my_config.command.substr(0,20) + "...");

        // Here it is, the job is starting now
        var child = new require('child_process').spawn(my_config.command, my_config.commandArgs.concat(my_config.commandArgs2||[]).concat(my_config.commandArgs3||[]), spawn_config);

        // This to avoid "invalid chunk data" when payload is not a string
        var stringify = biglib.stringify_stream();
        stringify.pipe(child.stdin);

        var ret = require('event-stream').duplex(my_config.payloadIsArg ? dummy : stringify, child.stdout);
        //if (my_config.noStdin) child.stdin.end();

        ret.others = [ child.stderr ];

        child
          .on('exit', function(code, signal) {
            // Gives biglib extra informations using the "stats" function
            this.stats({ rc: code, signal: signal });
            ret.emit('my_finish');
          }.bind(this))
          .on('error', function(err) {
            console.log(err);
            ret.emit('error', err);
          })

        return ret;
      }

      // Custom progress function
      var progress = function(running) { return running ? "running for " + this.duration() : ("done with rc " + (this._runtime_control.rc != undefined ? this._runtime_control.rc : "?")) }

      // new instance of biglib for this configuration
      // probably the most tuned biglib I've asked ever...
      var bignode = new biglib({
        config: config, node: this,   // biglib needs to know the node configuration and the node itself (for statuses and sends)
        status: progress,             // define the kind of informations displayed while running
        parser_config: spawn_options, // the parser configuration (ie the known options the parser will understand)
        parser: spawn,                // the parser (ie the remote command)
        on_finish: biglib.min_finish, // custom on_finish handler
        finish_event: 'my_finish'     // custom finish event to listen to
      });

      // biglib changes the configuration to add some properties
      config = bignode.config();

      this.on('input', function(msg) {

        // Is payload an extra argument
        delete config.commandArgs2;
        if (config.payloadIsArg && msg.payload) {
          msg.config = msg.config || {};
          msg.config.commandArgs2 = msg.payload;

          // if not, the size_stream which streams to the command will throw EPIPE
          delete msg.payload;
        }

        if (config.extraArgumentProperty && msg[config.extraArgumentProperty]) {
          msg.config = msg.config || {};
          msg.config.commandArgs3 = msg[config.extraArgumentProperty];
        }

        if (config.envProperty && msg[config.envProperty]) {
          msg.config = msg.config || {};
          msg.config.env = msg[config.envProperty];
        }

        bignode.main.call(bignode, msg);
      })
    }

    RED.nodes.registerType("bigexec", BigExec);

}
<|endoftext|>


<commit_before>const path = require('path');
const istanbul = require('rollup-plugin-istanbul');

const baseConfig = require('./karma.base');

function getBuild() {
  let id = `LIGHTY - TRAVIS #${process.env.TRAVIS_BUILD_NUMBER}`;

  id += ` (Branch: ${process.env.TRAVIS_BRANCH}`;

  if (process.env.TRAVIS_PULL_REQUEST !== 'false') {
    id += ` | PR: ${process.env.TRAVIS_PULL_REQUEST}`;
  }

  id += ')';

  return id;
}

function getTunnel() {
  return process.env.TRAVIS_JOB_NUMBER;
}

module.exports = function karma(config) {
  const sauceBrowsers = {
    // Chrome (last 3 versions)

    sl_chrome_54: {
      base: 'SauceLabs',
      browserName: 'chrome',
      version: '54.0',
      platform: 'Windows 10',
    },

    sl_chrome_53: {
      base: 'SauceLabs',
      browserName: 'chrome',
      version: '53.0',
      platform: 'Windows 10',
    },

    sl_chrome_52: {
      base: 'SauceLabs',
      browserName: 'chrome',
      version: '52.0',
      platform: 'Windows 10',
    },

    // Firefox (last 3 versions)

    sl_firefox_50: {
      base: 'SauceLabs',
      browserName: 'firefox',
      version: '50.0',
      platform: 'Windows 10',
    },

    sl_firefox_49: {
      base: 'SauceLabs',
      browserName: 'firefox',
      version: '49.0',
      platform: 'Windows 10',
    },

    sl_firefox_48: {
      base: 'SauceLabs',
      browserName: 'firefox',
      version: '48.0',
      platform: 'Windows 10',
    },

    // Edge

    sl_edge_14: {
      base: 'SauceLabs',
      browserName: 'MicrosoftEdge',
      version: '14.14393',
      platform: 'Windows 10',
    },

    sl_edge_13: {
      base: 'SauceLabs',
      browserName: 'MicrosoftEdge',
      version: '13.10586',
      platform: 'Windows 10',
    },

    // Internet Explorer (last 3 versions)

    sl_ie_11: {
      base: 'SauceLabs',
      browserName: 'internet explorer',
      version: '11.103',
      platform: 'Windows 10',
    },

    sl_ie_10: {
      base: 'SauceLabs',
      browserName: 'internet explorer',
      version: '10.0',
      platform: 'Windows 8',
    },

    sl_ie_9: {
      base: 'SauceLabs',
      browserName: 'internet explorer',
      version: '9.0',
      platform: 'Windows 7',
    },

    // Safari (last 3 versions)

    sl_safari_10: {
      base: 'SauceLabs',
      browserName: 'Safari',
      version: '10.0',
      platform: 'OS X 10.11',
    },

    sl_safari_9: {
      base: 'SauceLabs',
      browserName: 'Safari',
      version: '9.0',
      platform: 'OS X 10.11',
    },

    sl_safari_8: {
      base: 'SauceLabs',
      browserName: 'Safari',
      version: '8.0',
      platform: 'OS X 10.10',
    },

    // iOS (last 3 major versions)

    sl_ios_10: {
      base: 'SauceLabs',
      browserName: 'Safari',
      appiumVersion: '1.6.3',
      deviceName: 'iPhone Simulator',
      deviceOrientation: 'portrait',
      platformVersion: '10.0',
      platformName: 'iOS',
    },

    sl_ios_9: {
      base: 'SauceLabs',
      browserName: 'Safari',
      appiumVersion: '1.6.3',
      deviceName: 'iPhone Simulator',
      deviceOrientation: 'portrait',
      platformVersion: '9.3',
      platformName: 'iOS',
    },

    sl_ios_8: {
      base: 'SauceLabs',
      browserName: 'Safari',
      appiumVersion: '1.6.3',
      deviceName: 'iPhone Simulator',
      deviceOrientation: 'portrait',
      platformVersion: '8.4',
      platformName: 'iOS',
    },
  };

  Object.assign(baseConfig, {
    sauceLabs: {
      testName: 'lighty',
      build: getBuild(),
      tunnelIdentifier: getTunnel(),
      recordVideo: false,
      recordScreenshots: false,
      startConnect: false,
    },

    customLaunchers: sauceBrowsers,

    browsers: Object.keys(sauceBrowsers),

    reporters: ['dots', 'coverage', 'coveralls', 'saucelabs'],

    coverageReporter: {
      dir: path.join(__dirname, '../', 'coverage'),
      reporters: [
        { type: 'text' },
        { type: 'lcov' },
      ],
    },

    concurrency: 1,
    browserDisconnectTimeout: 10000,
    browserDisconnectTolerance: 1,
    browserNoActivityTimeout: 4 * 60 * 1000,
    captureTimeout: 0,

    singleRun: true,
  });

  baseConfig.rollupPreprocessor.plugins.unshift(istanbul({
    exclude: ['node_modules/**/*.js', 'spec/**/*.js'],
  }));

  baseConfig.plugins.push(
    'karma-sauce-launcher',
    'karma-coverage',
    'karma-coveralls'
  );

  config.set(baseConfig);
};
<commit_msg>Disable istanbul for CI<commit_after>const path = require('path');
const istanbul = require('rollup-plugin-istanbul');

const baseConfig = require('./karma.base');

function getBuild() {
  let id = `LIGHTY - TRAVIS #${process.env.TRAVIS_BUILD_NUMBER}`;

  id += ` (Branch: ${process.env.TRAVIS_BRANCH}`;

  if (process.env.TRAVIS_PULL_REQUEST !== 'false') {
    id += ` | PR: ${process.env.TRAVIS_PULL_REQUEST}`;
  }

  id += ')';

  return id;
}

function getTunnel() {
  return process.env.TRAVIS_JOB_NUMBER;
}

module.exports = function karma(config) {
  const sauceBrowsers = {
    // Chrome (last 3 versions)

    sl_chrome_54: {
      base: 'SauceLabs',
      browserName: 'chrome',
      version: '54.0',
      platform: 'Windows 10',
    },

    sl_chrome_53: {
      base: 'SauceLabs',
      browserName: 'chrome',
      version: '53.0',
      platform: 'Windows 10',
    },

    sl_chrome_52: {
      base: 'SauceLabs',
      browserName: 'chrome',
      version: '52.0',
      platform: 'Windows 10',
    },

    // Firefox (last 3 versions)

    sl_firefox_50: {
      base: 'SauceLabs',
      browserName: 'firefox',
      version: '50.0',
      platform: 'Windows 10',
    },

    sl_firefox_49: {
      base: 'SauceLabs',
      browserName: 'firefox',
      version: '49.0',
      platform: 'Windows 10',
    },

    sl_firefox_48: {
      base: 'SauceLabs',
      browserName: 'firefox',
      version: '48.0',
      platform: 'Windows 10',
    },

    // Edge

    sl_edge_14: {
      base: 'SauceLabs',
      browserName: 'MicrosoftEdge',
      version: '14.14393',
      platform: 'Windows 10',
    },

    sl_edge_13: {
      base: 'SauceLabs',
      browserName: 'MicrosoftEdge',
      version: '13.10586',
      platform: 'Windows 10',
    },

    // Internet Explorer (last 3 versions)

    sl_ie_11: {
      base: 'SauceLabs',
      browserName: 'internet explorer',
      version: '11.103',
      platform: 'Windows 10',
    },

    sl_ie_10: {
      base: 'SauceLabs',
      browserName: 'internet explorer',
      version: '10.0',
      platform: 'Windows 8',
    },

    sl_ie_9: {
      base: 'SauceLabs',
      browserName: 'internet explorer',
      version: '9.0',
      platform: 'Windows 7',
    },

    // Safari (last 3 versions)

    sl_safari_10: {
      base: 'SauceLabs',
      browserName: 'Safari',
      version: '10.0',
      platform: 'OS X 10.11',
    },

    sl_safari_9: {
      base: 'SauceLabs',
      browserName: 'Safari',
      version: '9.0',
      platform: 'OS X 10.11',
    },

    sl_safari_8: {
      base: 'SauceLabs',
      browserName: 'Safari',
      version: '8.0',
      platform: 'OS X 10.10',
    },

    // iOS (last 3 major versions)

    sl_ios_10: {
      base: 'SauceLabs',
      browserName: 'Safari',
      appiumVersion: '1.6.3',
      deviceName: 'iPhone Simulator',
      deviceOrientation: 'portrait',
      platformVersion: '10.0',
      platformName: 'iOS',
    },

    sl_ios_9: {
      base: 'SauceLabs',
      browserName: 'Safari',
      appiumVersion: '1.6.3',
      deviceName: 'iPhone Simulator',
      deviceOrientation: 'portrait',
      platformVersion: '9.3',
      platformName: 'iOS',
    },

    sl_ios_8: {
      base: 'SauceLabs',
      browserName: 'Safari',
      appiumVersion: '1.6.3',
      deviceName: 'iPhone Simulator',
      deviceOrientation: 'portrait',
      platformVersion: '8.4',
      platformName: 'iOS',
    },
  };

  Object.assign(baseConfig, {
    sauceLabs: {
      testName: 'lighty',
      build: getBuild(),
      tunnelIdentifier: getTunnel(),
      recordVideo: false,
      recordScreenshots: false,
      startConnect: false,
    },

    customLaunchers: sauceBrowsers,

    browsers: Object.keys(sauceBrowsers),

    reporters: ['dots', 'coverage', 'coveralls', 'saucelabs'],

    coverageReporter: {
      dir: path.join(__dirname, '../', 'coverage'),
      reporters: [
        { type: 'text' },
        { type: 'lcov' },
      ],
    },

    concurrency: 1,
    browserDisconnectTimeout: 10000,
    browserDisconnectTolerance: 1,
    browserNoActivityTimeout: 4 * 60 * 1000,
    captureTimeout: 0,

    singleRun: true,
  });

  baseConfig.plugins.push(
    'karma-sauce-launcher',
    'karma-coverage',
    'karma-coveralls'
  );

  config.set(baseConfig);
};
<|endoftext|>