Gigya Job Openings

Page History

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
HTML
<script>
 
/*************************************************************************
 * START CODE EXAMPLE GENERATOR EXTENSION version 2.2 12MAR19
 * // Change version in lssdk.ceg.version also
 * 
 * Must define a container on the confluence page where the resulting 
 * code examples will display.
 * 
 * You must have an object on the confluence page that contains all the
 * necessary parameters and configurations for the code generator. This
 * MUST be named whatever (where name is passed as the
 * methods param).
 * 
 * lssdk.ceg.run(nameOfParamsObject)
 * 
 * Current version available at http://lssdk.herokuapp.com/js/codeExampleGenerator/ceg_ext.js
 * 
 * **lssdk.js is required to load this extension**
 * 
 * Report any bugs to levi.st [@] gigya-inc.com
 * 
 * ********CHANGELOG********
 * 
 * v1.001 12dec17 - bugfix colons in strings and the objects that miss them
 * v1.002 13dec17 - Reduced platform title size
 * v1.003 13dec17 - support single lang UI
 * v1.004 13dec17 - support single lang UI - shortened cookie timeout
 * v1.005 18dec17 - minimum support for functions in JS examples - only if the lang is for JS only [nodeId].langs.length === 1 
 * v1.006 22jan18 - adding support for userKey param in GSRequest (hopefully) 
 * v1.007 01feb18 - fixed typo in php code (removed extra semicolon)
 * v1.008 01feb18 - added minimal JS support, can now be used with complex data, but still does not support functions as param values.
 * v1.009 29mar18 - added lssdk.ceg.toggleUserKey for toggling the userKey example on/off (from what was originally set).
 * v2.0 8may18 - added UI for toggleUserKey.
 * 
 ************************************************************************ */

/**
 * config object structure - MANDATORY
 * 
 * paramsObject: {
 *      api: "apiName",
 *      params: { params },
 *      langs: "langs",
 *      useUserKey: Boolean,
 *      containerId: "container_id_for_finished_examples"
 * }
 *  //supported langs options = "net,android,curl,ios,java,js,javascript,php,py,python,all,nojs" (js === javascript) and (nojs === all - js) 
 * 
 * lssdk.ceg.run(paramsObject);
 */

if ((typeof(lssdk) !== 'undefined') && (lssdk.isInitialized === true)) {
    var lssdk = window.lssdk || {};
    lssdk.ceg = lssdk.ceg || {};
    lssdk.codeExampleGenerator = lssdk.codeExampleGenerator || lssdk.ceg || {};
    lssdk.generator = lssdk.generator || {};
    lssdk.ceg.nodes = lssdk.ceg.nodes || [];
    lssdk.ceg.nodes_exist = false;
    lssdk.ceg.version = "Version 2.2 - 12MAR19"; // change above also
    
    // Add necessary styles to the page on load
    lssdk.ceg.styles = {};
    lssdk.ceg.styles.initialized = false;
    lssdk.ceg.ref = {};
	lssdk.ceg.addMonoFont = function() {
        let a,b,c;
        a = document.getElementsByTagName('head')[0];
        b = document.createElement('style');
        c = "@import url('https://fonts.googleapis.com/css?family=Source+Code+Pro');";
        b.innerHTML = c;
        a.appendChild(b);
        lssdk.ceg.styles.monofontLoaded = true;
        console.warn("CEGEXT added monofont to head.");
    };
    lssdk.ceg.addStyles = function() {
    	lssdk.ceg.addMonoFont();    
		var styleContainer = document.createElement("style");
        var styles = ".colorYellow { color: #a70 !important;\n font-family: 'Source Code Pro', monospace !important; }\n.colorBlue { color: #369 !important;\n font-family: 'Source Code Pro', monospace !important; }\n.colorPink { color: #ff1493 !important;\n font-family: 'Source Code Pro', monospace !important; }\n.colorBold { font-weight: bold !important;\n font-family: 'Source Code Pro', monospace !important; }\n.colorGreen {color: #008200 !important\n font-family: 'Source Code Pro', monospace !important; } \n span.colorGreen {\n color: #008200 !important;\n font-family: 'Source Code Pro', monospace !important;\n}\n";
        styleContainer.innerHTML = styles;
        document.getElementsByTagName('head')[0].appendChild(styleContainer);
        lssdk.ceg.styles.initialized = true;
        console.log("CEG EXT Styles added to page.");
    };

    // COOKIE CONTROL
    lssdk.ceg.cookies = lssdk.ceg.cookies || {};
    lssdk.ceg.cookies.set = function(lang) {
        if ((typeof(lang) !== 'undefined') && (lang !== null) && (lang !== '')) {
            lssdk.tools.setCookie("gig_codeExampleGenPrefs",lang,364);
        } else {
            console.warn("WARNING! lssdk.ceg.cookies.set failed.");
        }
    };
    lssdk.ceg.cookies.get = function() {
        var a = lssdk.tools.getCookie("gig_codeExampleGenPrefs");
        return a;
    };
    lssdk.ceg.cookies.remove = function(name) {
        if ((typeof(name) !== 'undefined') && (name !== null) && (name !== '')) {
            lssdk.tools.removeCookie(name);
        } else {
            console.warn("WARNING! lssdk.ceg.cookies.remove failed.");
        }
    };

    // hold user cookie
    lssdk.ceg.userPlatformCookie = null;
    lssdk.ceg.userPlatformCookie = lssdk.ceg.cookies.get();
    if (typeof(lssdk.ceg.userPlatformCookie) !== "string") {
        lssdk.ceg.userPlatformCookie = "javascript";
    }
    lssdk.ceg.cookies.checkCookie = function() {
        if ((typeof(lssdk.ceg.userPlatformCookie) !== 'undefined') && (lssdk.ceg.userPlatformCookie !== null) && (lssdk.ceg.userPlatformCookie !== '')) {
            var statusMessage = 'No preferred platform language detected.';
            var lang = lssdk.ceg.userPlatformCookie;
            var allNodes;
            var allLangs;
            if ((typeof(lssdk.ceg.nodes_exist) !== 'undefined') && (lssdk.ceg.nodes_exist !== null) && (lssdk.ceg.nodes_exist === true)) {
                allNodes = lssdk.ceg.nodes;
                var firstAvailableLang;
                var langIsAvailable;
                for(var propName in allNodes) {
                    if(allNodes.hasOwnProperty(propName)) {
                        var newKey = propName;
                        var allOpts = allNodes[newKey].selectUI.children;
                        lssdk.ceg.ref.allOpts = allOpts;
                        //console.log("*******************: ", allOpts);
                        if (allOpts.length === 2) {
                            var onePlatform = allOpts[1].id.split("_");
                            var actualPlatform = onePlatform[onePlatform.length -1];
                            //console.log("actualPlatform", actualPlatform);
                            lssdk.ceg.selectAnOption(newKey, actualPlatform);
                        } else {
                            for (var t = 0; t < allOpts.length; t++) {
                                if (allOpts[t].id.indexOf(lang) > -1) {
                                    lssdk.ceg.selectAnOption(newKey, lang);
                                    langIsAvailable = true;
                                    console.log('Preferred platform language set to: ', lang);
                                    return false;
                                } else if (allOpts[t].id.indexOf(lang) === -1) {
                                    var firstAvailableLangId = allOpts[1].id.split("_");
                                    firstAvailableLang = firstAvailableLangId[firstAvailableLangId.length -1];
                                    langIsAvailable = false;
                                }
                            }
                        }
                        // handle user's lang doesn't exist in select
                        if (langIsAvailable === false) {
                            lssdk.ceg.selectAnOption(newKey, firstAvailableLang);
                            console.log('Preferred platform language set to: ', firstAvailableLang);
                        }
                    }
                }
            } else {
                console.warn("ERROR! No active nodes found - ceg_ext.js");
                //throw new Error("No active nodes found - ceg_ext.js");
                return false;
            }
        } else {
            console.log("CEG EXT says 'WOOPS! No platform cookie found :( '")
        }
    };

    // Make code example block selectable
    lssdk.ceg.selectText = function(divId) {
        if (document.selection) {
            var range = document.body.createTextRange();
            range.moveToElementText(document.getElementById(divId));
            range.select();
        } else if (window.getSelection) {
            var range = document.createRange();
            range.selectNode(document.getElementById(divId));
            window.getSelection().removeAllRanges();
            window.getSelection().addRange(range);
        }
    };

    // parse a function
    lssdk.ceg.parseFunction = function(obj) {
        if (typeof(obj) === 'function') {
            JSON.stringify(obj, function(key, val) {
                if (typeof val === 'function') {
                    return val + ''; // implicitly `toString` it
                }
                return val;
            });
        } else {
            console.log("WARNING! The object passed to lssdk.ceg.parseFunction was not a function");
        }
    };

    //Tools for parsing out complex JS values
    lssdk.ceg.getParamType = function(key) 
    {
        var input = null;
        var type = null;
        if ((typeof(key) !== 'undefined') && (key !== "") && (key !== null)) {
            input = key;
        } else {
            console.warn("Invalid key, operation canceled.");
            return false;
        }
        if ((typeof(input)==='object') && (input.length !== 'undefined')) {
            type = 'array-object';
        } else if ((typeof(input)==='object') && (input.length === 'undefined')) {
            type = 'json-object';
        } else {
            type = typeof(key);
        }
        return type;
    }
    lssdk.ceg.convertToString=function(key,type)
    {
        var converted,input,objType;
        if ((typeof(key) !== 'undefined') && (key !== "") && (key !== null)) {
            input = key;
        }
        if ((typeof(type) !== 'undefined') && (type !== "") && (type !== null)) {
            objType = type;
        }
        if (objType === 'array-object') {
            converted = JSON.stringify(input);
        } else if (objType === 'json-object') {
            converted = JSON.stringify(input);
        } else {
            console.warn("Convert to string failed. key is not an object or you are missing a required parameter. lssdk.ceg.convertToString(key,type)");
            converted = input;
        }
        return converted;
    };
    lssdk.ceg.checkIfParamIsObject = function(paramName)
    {
        var key,type,result;
        if ((typeof(paramName) !== 'undefined') && (paramName !== "") && (paramName !== null)) {
            key = paramName;
        }
        type = lssdk.ceg.getParamType(key);
        if ((type === 'array-object') || (type === 'json-object')) {
            var result = lssdk.ceg.convertToString(key,type);
            return result;
        } else {
            return false;
        }
    };

    // test object sampleStuff
    lssdk.ceg.addDemo = function() {
        window.ceg_demoCodeExampleObject = ceg_demoCodeExampleObject || {};
        ceg_demoCodeExampleObject.containerId = "responseDiv";
        ceg_demoCodeExampleObject.api = "accounts.getAccountInfo";
        ceg_demoCodeExampleObject.langs = "all"; // STRING
        ceg_demoCodeExampleObject.useUserKey = false; // Boolean
        ceg_demoCodeExampleObject.params = { // OBJECT
            "accountOptions":{'verifyEmail':true},
            "emailVerification":{'verificationEmailExpiration':3600},
            "gigyaPlugins":{'sessionExpiration':0,'rememberSessionExpiration':-2},
            "passwordComplexity":{'minCharGroups':3},
            "paramOne":'isOne',
            "paramTwo" : true,
            "ParamThree":'notEvenClose',
            "paramFour":'4455',
            "one": 'two',
            "four": {'pp1': 'true', 'pp2':'forever'},
            "ninetysix" : 1234,
            "111111":111111,
            //"five": {["yuck": "thirtyfive","seventeen":"twenty"]}, // this format is not supported
            "seven": [{'eleventyfour': 'nine'},{'twelve':'twentytwo'}], // ("seven","[object Object],[object Object]")
            "wwwwww":'wwwwww',
            "easyArray": ["one", "two", "three", "fourthousandsevenhundredandtwentyfourquadrillion"],
	        "randomURL": "https://Yoyo.example.com/yolo"
        };
        lssdk.ceg.run(ceg_demoCodeExampleObject);
    };

    // This runs the Code Example Generator and everything else required is contained within it
    lssdk.ceg.run = function(config) {
        var container;
        var configObj;
        var nodeId = "cegNode_" + Date.now().toString() + "_" + Math.random().toString().split(".")[1];
        // really add styles
        if (!!lssdk.ceg.styles.initialized) {
            console.log("CEG EXT styles already initialized.");
        } else {
            lssdk.ceg.addStyles();
        }

        if ((typeof(config) !== 'undefined') && (config !== null) && (typeof(config) === "object")) { // START CONFIG OBJ PARSE
            configObj = config;
            lssdk.ceg.nodes[nodeId] = {};
            lssdk.ceg.nodes[nodeId].config = configObj;
            if ((typeof(configObj.containerId) === 'string') && (configObj.containerId !== "")) {
                if (typeof(document.getElementById(configObj.containerId)) === 'object') {
                    container = configObj.containerId;
                    lssdk.ceg.nodes[nodeId].parent = document.getElementById(container); // name of the code example container
                    lssdk.ceg.nodes[nodeId].innerCodeContainers = lssdk.ceg.nodes[nodeId].innerCodeContainers || [];
                } else {
                    console.warn("ERROR! ceg_ext.js - Specified containerId not found.");
                    return false;
                }
            } else {
                console.warn("ERROR! ceg_ext.js - No containerID found in config object");
                return false;
            }
            if ((typeof(configObj.api) !== 'undefined') && (configObj.api !== null) && (configObj.api !== '')) {
                lssdk.ceg.nodes[nodeId].api = configObj.api;
            } else {
                console.warn("ERROR! ceg_ext.js - No api defined in config object.");
                //throw new Error("ceg_ext.js - No api defined in config object.");
                return false;
            }
            if ((typeof(configObj.params) === 'object') && (configObj.params !== null)) {
                lssdk.ceg.nodes[nodeId].baseParams = configObj.params;
            } else {
                console.warn("ERROR! ceg_ext.js - No params found in config object");
                return false;
            }
            lssdk.ceg.nodes[nodeId].langs = [];
            if ((typeof(configObj.langs) !== 'undefined') && (typeof(configObj.langs) === 'string')) {
                var langArray = configObj.langs.split(",");
                // check for all or nojs - still no mobile support!
                if (langArray[0].toLowerCase() === "all") {
                    var a = "net,curl,java,js,php,py";
                    langArray = a.split(",");
                } else if (langArray[0].toLowerCase() === "nojs") {
                    var b = "net,curl,java,php,py";
                    langArray = b.split(",");
                }
                for (var i = 0; i < langArray.length; i++) {
                    lssdk.ceg.nodes[nodeId].langs.push(langArray[i].toLowerCase());
                }
            }
            if ((typeof(configObj.useUserKey) !== undefined) && (configObj.useUserKey === true)) {
                lssdk.ceg.nodes[nodeId].useUserKey = true;
            } else {
                lssdk.ceg.nodes[nodeId].useUserKey = false;
            }

            // PROCESSING OF DATA AND CREATING EXAMPLE BELOW
            /**
             * 
             * Since this is not going to use the built in confluence code macro
             * need to figure out how to style the code examples per lang preference
             * will need to re-visit using codeMirror
             * 
             */

            // CONVERT OLD CONFLUENCE STYLE CODE EXAMPLE TO HTML
            lssdk.ceg.nodes[nodeId].convertedCodeBlocks = [];
            lssdk.ceg.convertToHtml = function(type) {
                var newType;
                var str;
                var newStr;
                if ((typeof(type) !== 'undefined') && (type !== null) && (type !== "")) {
                    if (type === 'js') {
                        newType = "javascript";
                    } else if (type === 'py') {
                        newType = "python";
                    } else {
                        newType = type;
                    }
                    str = lssdk.ceg.nodes[nodeId].codeBlocks[newType];

                    // JS support
                    if ((newType === "javascript") && (lssdk.ceg.nodes[nodeId].langs.length === 1)) {
                        newStr = str;
                        newStr = newStr.replace("if(", "if (");
                        newStr = newStr.replace(/colorBlue&nbsp;color/g,"colorBlue color");
                        newStr = newStr.replace(/colorgreen&nbsp;color/g,"colorGreen color");
                        newStr = newStr.replace(/colorPink&nbsp;color/g,"colorPink color");
                        newStr = newStr.replace(/colorYellow&nbsp;color/g,"colorYellow color");
                        newStr = newStr.replace(/<span&nbsp;/g,"<br/><span ");
                        newStr = newStr.replace(/&lt;script/g,"<br/>&lt;script");
                        newStr = newStr.replace(/var/,"<br/>&nbsp;&nbsp;var");
                        newStr = newStr.replace(/&lt;\/script&gt;/g,"<br/>&lt;/script&gt;");
                        newStr = newStr.replace(/params\s*=\s*{/,"params = {<br/>&nbsp;&nbsp;&nbsp;&nbsp;");
                        newStr = newStr.replace(/}\s*,/g,"},<br/>&nbsp;&nbsp;&nbsp;&nbsp;");
                        newStr = newStr.replace(/}\s*gigya\./g,"<br/>&nbsp;&nbsp;}<br/>&nbsp;&nbsp;gigya.");
                    } else {
                        newStr = str.replace(/[\n]/g,"<br/>");
                        newStr = newStr.replace(/[\s]/g,"&nbsp;");
                        newStr = newStr.replace("<?php", "&lt;?php");
                        newStr = newStr.replace("if(", "if (");
                        newStr = newStr.replace(/colorBlue&nbsp;color/g,"colorBlue color");
                        newStr = newStr.replace(/colorgreen&nbsp;color/g,"colorGreen color");
                        newStr = newStr.replace(/colorPink&nbsp;color/g,"colorPink color");
                        newStr = newStr.replace(/colorYellow&nbsp;color/g,"colorYellow color");
                        newStr = newStr.replace(/<span&nbsp;/g,"<span ");
                    }
                    lssdk.ceg.nodes[nodeId].convertedCodeBlocks[newType] = newStr;
                } 
            }

            // Create container and header for example to insert into parent container of page
            lssdk.ceg.createCodeWrapper = function(name) {
                var wrapperName; // should be nodeId
                if ((typeof(name) !== 'undefined') && (typeof(name) === 'string') && (name !== "")) {
                    wrapperName = name;
                } else {
                    console.warn("ERROR! createCodeWrapper failed. Missing required parameter container-name.");
                    return false;
                }
                var container = document.createElement('div');
                container.id = "outerCodeWrapper_" + wrapperName;
                container.setAttribute("style","width: auto; height: auto; border: 1px solid lightgrey; border-radius: 10px; padding: 15px; min-height: 200px;"); // set css here
                var header = document.createElement('div');
                header.id = "outerCodeWrapperHeader_" + wrapperName;
                header.setAttribute("style", "width: 100%; height:50px;");

                // Add title holder for platform selected
                var titleContainer = document.createElement("div");
                titleContainer.setAttribute("style", "color: #149dd6 !important; font-size: 1.5em; position: absolute; margin-top: 3px;");
                titleContainer.id = "outerCodeWrapperTitleContainer_" +  nodeId;
                lssdk.ceg.nodes[nodeId].selectUI_TitleContainer = titleContainer.id;

                // attach title container
                header.appendChild(titleContainer);

                // 8.5.18 adding userKey toggle
                var toggleLink = document.createElement("div");
                toggleLink.setAttribute("style", "position: relative; top: 30px; font-size: 80%; color: rgba(20,157,214,.63) !important; cursor: pointer;");
                toggleLink.title = "Click here to toggle the example to use a User Key and secret or only Partner secret."
                toggleLink.id = "userKeyToggle_" + nodeId;
                toggleLink.innerHTML = "Click Here to toggle userKey example";
                lssdk.ceg.nodes[nodeId].selectUI_toggleLink = toggleLink.id;

                // handle the click event
                toggleLink.addEventListener("click", function() {
                    lssdk.ceg.toggleUserKey(lssdk.ceg.nodes[nodeId].config);
                    var linkName = "userKeyToggle_" + lssdk.ceg.getLatestNode(lssdk.ceg.nodes);
                    document.getElementById(linkName).style.visiblity = "hidden";
                });



                // append toggle to container
                header.appendChild(toggleLink);

                // add Drop-down
                var dropdown = document.createElement("select");
                dropdown.id = "outerCodeWrapperSelect_" + wrapperName;
                dropdown.setAttribute("style", "font-weight: bold; width: 220px; padding: 5px; line-height: 25px; height: 36px; font-size: 20px; border: 1px inset; background-color: #33a7e3; color: #ffffff; float: right; border-radius: 5px; list-style: none; list-style-type: none; cursor: pointer; margin-top: -15px;");
                var selectOption = document.createElement("option");
                selectOption.id = "outerCodeWrapperSelect_" + wrapperName + "_select";
                selectOption.className = "";
                selectOption.innerText = "Select a Platform";
                dropdown.appendChild(selectOption);

                //add select to header
                header.appendChild(dropdown);

                // add header to outerCodeWrapper
                container.appendChild(header);

                // add container to parent
                document.getElementById(lssdk.ceg.nodes[wrapperName].parent.id).appendChild(container);
                lssdk.ceg.nodes[wrapperName].outerCodeWrapper = container.id;
                console.log("Container " + container.id + " added to DOM.");
            };

            // Create unique containers to hold the specific code examples and inject convertedCodeBlocks
            lssdk.ceg.createSpecificCodeContainer = function(name,type) {
                var codeHolderName, codeType,containerName;
                if ((typeof(name) !== 'undefined') && (typeof(name) === 'string') && (name !== "")) {
                    codeHolderName = name;
                } else {
                    console.warn("ERROR! createSpecificCodeContainer failed. Missing required parameter container-name.");
                    return false;
                }
                if ((typeof(type) !== 'undefined') && (typeof(type) === 'string') && (type !== "")) {
                    codeType = type;
                } else {
                    console.warn("ERROR! createSpecificCodeContainer failed. Missing required parameter container-type.");
                    return false;
                }
                containerName = "innerCodeContainer_" + codeHolderName + "_" + codeType;
                codeHolderName = document.createElement("div");
                codeHolderName.id = containerName;
                codeHolderName.title = "Click to select";
                codeHolderName.setAttribute("style", "display: none; border: 1px dashed lightgrey; padding: 15px; font-family: 'Source Code Pro', monospace !important; white-space: nowrap !important; overflow-x: scroll; color: rgb(0,0,0); font-size: 1.1em; background-color: #f8f8ff; border-radius: 2px; width: 95%;");
                codeHolderName.innerHTML = lssdk.ceg.nodes[nodeId].convertedCodeBlocks[type];
                //console.log("convertedCodeBlock added to outerCodeWrapper.");
                document.getElementById(lssdk.ceg.nodes[nodeId].outerCodeWrapper).appendChild(codeHolderName);
                lssdk.ceg.nodes[nodeId].innerCodeContainers.push(containerName);

                // make selectable
                codeHolderName.addEventListener("click", function() {
                    lssdk.ceg.selectText(this.id);
                });
                

                // Add option for code example to select
                var selectContainer = "outerCodeWrapperSelect_" + nodeId;
                var titleText;
                if ((type === "net") || (type === "php")) {
                    titleText = type.toUpperCase();
                    if (titleText === "NET") {
                        titleText = ".NET";
                    }
                } else if ((type === "java") || (type === "python") || (type === "android")) {
                    var holder = type.split("");
                    holder[0] = holder[0].toUpperCase();
                    titleText = holder.join();
                    titleText = titleText.replace(/[,]/g,"")
                } else if (type === 'curl') {
                    titleText = "cURL";
                } else if (type === "ios") {
                    titleText = "iOS";
                } else if ((type === "js") || (type === "javascript")) {
                    titleText = "JavaScript";
                }
                var newOption = document.createElement("option");
                newOption.id = "outerCodeWrapperSelect_" + nodeId + "_" + type;
                newOption.className = "";
                newOption.innerText = titleText;
                document.getElementById(selectContainer).appendChild(newOption);
                lssdk.ceg.nodes[nodeId].selectUI = document.getElementById(selectContainer);
            };

            // parse params obj and create correct params structure for examples
            lssdk.ceg.nodes[nodeId].paramsArray = []; // empty array for storing parsed data while constructing examples 

            /**
             * parse the configObj.params into an array of strings that we can split for use in our code blocks
             * example: param name  would be lssdk.ceg.nodes[nodeId].paramsArray[i].split("$$$")[0]; and param value would be lssdk.ceg.nodes[nodeId].paramsArray[i].split("$$$")[1]
             */ 
            lssdk.ceg.parseParams = function(params) {
                var codeParams;
                if ((typeof(params) !== 'undefined') && (typeof(params) === 'object')) {
                    codeParams = params;
                    for(var propName in codeParams) {
                        if(codeParams.hasOwnProperty(propName)) {
                            var newKey = propName;
                            /* TESTING
                            console.log("propName>>>>>>>>>>>>>>>>", codeParams[propName]);
                            console.log("propName type>>>>>>>>>>>", typeof(codeParams[propName]));
                            console.log("propName parse>>>>>>>>>>", JSON.parse(codeParams[propName]));
                            console.log("propName typeP>>>>>>>>>>", typeof(JSON.parse(codeParams[propName])));
                            console.log("propName string>>>>>>>>>", JSON.stringify(codeParams[propName]));
                            console.log("propName typeS>>>>>>>>>>", typeof(JSON.parse(codeParams[propName])));
                            */
                            var newValue = JSON.stringify(codeParams[propName]);
                            lssdk.ceg.nodes[nodeId].paramsArray.push(newKey + "$$$" + newValue);
                            //console.log(newKey + "$$$" + newValue);
                        }
                    }
                }
            };

            lssdk.ceg.parseParams(configObj.params);

            // parse langs array and create code examples for all requested languages
            lssdk.ceg.createCodeExamples = function(array) {
                var langArray,fullArray;
                if ((typeof(array) !== 'undefined') && (typeof(array) === 'object') && (array.length > 0)) {
                    langArray = array;
                    for (var i = 0; i < langArray.length; i++) {
                        var thisLang = langArray[i];
                        lssdk.ceg.constructCodeExample(thisLang);
                        //console.log("Constructed code example for: ", thisLang);
                        // convert code example to html instead of \n and white space
                        lssdk.ceg.convertToHtml(thisLang);
                    }
                } else {
                    console.warn("ERROR! createAllCodeExamples requires an array.");
                    return false;
                }
            } // END createAllCodeExamples

            /* set code example data to the node for parsing into HTML later */
            lssdk.ceg.nodes[nodeId].codeBlocks = [];
            lssdk.ceg.addCodeExampleToNode = function(type,data) {
                lssdk.ceg.nodes[nodeId].codeBlocks[type] = data;
                console.log("code example added to node " + nodeId + ": ", type);
            };

            // create the actual indented code example to insert into the confluence code blocks
            lssdk.ceg.constructCodeExample = function(type) {
                var exampleType;
                var userKeyStringNet = ', true';
                var newParamNet = '';
                var userKeyStringCurl = '';
                var userKeyStringJava = '';
                var newParamJava = '';
                var userKeyStringPhp = '';
                var newParamPhp = '';
                var userKeyStringPython = '';
                var newParamPython = '';
                if ((typeof(lssdk.ceg.nodes[nodeId].useUserKey) !== 'undefined') && (lssdk.ceg.nodes[nodeId].useUserKey === true)) {
                    userKeyStringNet = ', null, true, userKey';
                    userKeyStringCurl = "    --data-urlencode <span class='colorBlue'>\"userKey=[Enter-Your-Application/User-Key]\"</span>\\\n";
                    userKeyStringJava = ", null, true, userKey";
                    userKeyStringPhp = ', <span class="colorYellow">null</span>, <span class="colorYellow">true</span>, <span class="colorYellow">$userKey</span>';
                    userKeyStringPython = ',userKey';

                    newParamNet = '\n            <span class="colorBlue colorBold">const string</span> userKey = <span class="colorBlue">"Enter-Your-User/Application-Key-Here"</span>;';
                    newParamJava = '\n    <span class="colorBlue colorBold">final</span> String userKey = <span class="colorBlue">"PUT-YOUR-USER/APPLICATION-KEY-HERE"</span>;';
                    newParamPhp = '\n<span class="colorYellow">$userKey</span> = <span class="colorBlue">"PUT-YOUR-USER/APPLICATION-KEY-HERE"</span>;';
                    newParamPython = '\nuserKey = <span class="colorBlue">"PUT-YOUR-USER/APPLCIATION-KEY-HERE"</span>';
                }
                if ((lssdk.ceg.nodes[nodeId].baseParams == null) || (typeof(lssdk.ceg.nodes[nodeId].baseParams) === 'undefined') || (typeof(lssdk.ceg.nodes[nodeId].baseParams) !== 'object')) {
                    console.warn("WARNING! constructCodeExample encountered a Fatal error: No parameters found in lssdk.ceg.nodes[" + nodeId + "].baseParams or it doesn't exist.");
                } else {
                    if ((typeof(type) !== 'undefined') && (type !== null)) {
                        exampleType = type;
                        if (exampleType === "net") { // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< .NET
                            var myCount = Object.keys(lssdk.ceg.nodes[nodeId].baseParams).length;
                            var param_str_full_complete = '';
                            function setApiParamsStringNet() {
                                for (var i = 0; i < lssdk.ceg.nodes[nodeId].paramsArray.length; i++) {
                                    var str_front = '            request.SetParam(<span class="colorBlue">"';
                                    var k = lssdk.ceg.nodes[nodeId].paramsArray[i].split("$$$")[0];
                                    var c;
                                    c = lssdk.ceg.nodes[nodeId].paramsArray[i].split("$$$")[1];
                                    if ((c.match(/\[/g) || []).length >= 1) {
                                        c = JSON.stringify(c);
                                    } else if ((c.match(/\{/g) || []).length >= 1) {
                                        c = JSON.stringify(c);
                                    }
                                    else if (((c.match(/"/g) || []).length === 2) && ((c.match(/:/g) || []).length < 1)) {

                                    } else {

                                    }
                                    var str_mid = k + '"</span>,<span class="colorBlue">' + c;
                                    var str_back = '</span>);';
                                    var str_full = str_front + str_mid + str_back;
                                    param_str_full_complete += str_full + '\n';
                                };
                                return param_str_full_complete;
                            }
                            var ex_string_net_a = '<span class="colorBlue colorBold">using</span> System;\n<span class="colorBlue colorBold">using</span> Gigya.Socialize.SDK;\n\n<span class="colorBlue colorBold">class</span> Program {\n    <span class="colorBlue colorBold">static void</span> Main(<span class="colorBlue colorBold">string</span>[] args)\n        {\n            <span class="colorBlue colorBold">const string</span> apiKey = <span class="colorBlue">"Enter-Your-API-Key-Here"</span>;\n            <span class="colorBlue colorBold">const string</span> secretKey = <span class="colorBlue">"Enter-Your-Secret-Key-Here"</span>;' + newParamNet + '\n\n            <span class="colorBlue colorBold">string</span> method = <span class="colorBlue">"' + lssdk.ceg.nodes[nodeId].api + '"</span>;\n            GSRequest request = <span class="colorBlue colorBold">new</span> GSRequest(apiKey, secretKey, method' + userKeyStringNet + ');\n\n';
                            var ex_string_net_b = setApiParamsStringNet();
                            var ex_string_net_c = '\n            GSResponse response = request.Send();\n\n            <span class="colorBlue colorBold">if</span> (response.GetErrorCode() == 0)\n                {\n                    <span class="colorGreen">// Everything\'s okay</span>\n                    GSObject resObj = response.GetData();\n\n                    <span class="colorGreen">// Do something with the data</span>\n                }\n            <span class="colorBlue colorBold">else</span>\n                {\n                    Console.WriteLine(<span class="colorBlue">"Uh-oh, we got the following error:{0}"</span>, response.GetLog());\n                }\n        }\n}';
                            var full_net_request_string = ex_string_net_a + ex_string_net_b + ex_string_net_c;
                            lssdk.ceg.addCodeExampleToNode('net', full_net_request_string);
                        } else if (exampleType === "android") { // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ANDROID
                            console.warn("WARNING! Unsupported parameter: Android is not a supported language for code examples");
                        } else if (exampleType === "curl") { // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< CURL
                            var myCount = Object.keys(lssdk.ceg.nodes[nodeId].baseParams).length;
                            var param_str_full_complete = '';
                            var apiNamespace = lssdk.ceg.nodes[nodeId].api.split('.')[0];
                            function setApiParamsStringCurl() {
                                for (var i = 0; i < lssdk.ceg.nodes[nodeId].paramsArray.length; i++) {
                                    var str_front = '    --data-urlencode <span class="colorBlue">"';
                                    var k = lssdk.ceg.nodes[nodeId].paramsArray[i].split("$$$")[0];
                                    var c;
                                    c = lssdk.ceg.nodes[nodeId].paramsArray[i].split("$$$")[1];
                                    if ((c.match(/\[/g) || []).length >= 1) {
                                        c = c.replace(/"/g,"'");
                                    } else if ((c.match(/\{/g) || []).length >= 1) {
                                        c = c.replace(/"/g,"'");
                                    } else if((c.match(/"/g) || []).length === 2) {
                                        c = c.replace(/"/g,"");
                                    } else {

                                    }
                                    /* old for backup
                                    if ((c.match(/:/g) || []).length >= 1) {
                                        c = c.replace(/"/g,"'");
                                    } else if (((c.match(/"/g) || []).length === 2) && ((c.match(/:/g) || []).length < 1)) {
                                        c = c.replace(/"/g,"");
                                    }
                                    */
                                    c += '"';
                                    var str_mid = k + '</span>=<span class="colorBlue">' + c;
                                    var str_back = '</span> \\';
                                    var str_full = str_front + str_mid + str_back + '\n';
                                    param_str_full_complete += str_full;
                                };
                                return param_str_full_complete;
                            }
                            // IE SAFE
                            var ex_string_curl_ie_a = '<span class="colorGreen"># Define the API and Secret key (the keys can be obtained from your site setup page in the Gigya console).\n# Enter the proper Data center (us1, eu1, au1) if not using us1.\n# Requests include a secret and MUST be sent over SSL.\n\n# You can copy and import the code below directly into Postman.</span>\n\n';
                            var ex_string_curl_ie_params_d = setApiParamsStringCurl();
                            //console.log(ex_string_curl_ie_params_d);
                            ex_string_curl_ie_params_d = ex_string_curl_ie_params_d.replace(/,\n$/, '\n'); // remove last comma
                            // convert params back to a single line and prep for html encoding
                            //var ex_string_curl_ie_params_e = encodeURIComponent(ex_string_curl_ie_params_d).replace(/'/g,"\\'");
                            //console.log(ex_string_curl_ie_params_d);
                            var ex_string_curl_ie_api_b = "curl -X POST \\\n    https://" + apiNamespace + ".gigya.com/" + lssdk.ceg.nodes[nodeId].api + " \\\n    -H <span class='colorBlue'>'content-type: application/x-www-form-urlencoded'</span> \\\n    --data-urlencode <span class='colorBlue'>\"apiKey=[Enter-Your-API-Key-Here]\"</span> \\\n    --data-urlencode <span class='colorBlue'>\"secret=[Enter-Your-Secret-Key]\"</span> \\\n" + userKeyStringCurl + ex_string_curl_ie_params_d;
                            full_curl_request_string = ex_string_curl_ie_a + ex_string_curl_ie_api_b;
                            lssdk.ceg.addCodeExampleToNode('curl', full_curl_request_string);
                        } else if (exampleType === "ios") { // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< IOS
                            console.warn("WARNING! Unsupported parameter: iOS is not a supported language for code examples");
                        } else if (exampleType === "java") { // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< JAVA
                            var myCount = Object.keys(lssdk.ceg.nodes[nodeId].baseParams).length;
                            var param_str_full_complete = '';
                            function setApiParamsStringJava() {
                                for (var i = 0; i < lssdk.ceg.nodes[nodeId].paramsArray.length; i++) {
                                    var str_front = '    request.setParam(<span class="colorBlue">"';
                                    var k = lssdk.ceg.nodes[nodeId].paramsArray[i].split("$$$")[0];
                                    var c;
                                    c = lssdk.ceg.nodes[nodeId].paramsArray[i].split("$$$")[1];
                                    if ((c.match(/\[/g) || []).length >= 1) {
                                        c = JSON.stringify(c);
                                    } else if ((c.match(/\{/g) || []).length >= 1) {
                                        c = JSON.stringify(c);
                                    } /* else if ((c.match(/:/g) || []).length >= 1) {
                                        c = JSON.stringify(c);
                                    }*/
                                    else if (((c.match(/"/g) || []).length === 2) && ((c.match(/:/g) || []).length < 1)) {

                                    } else {

                                    }
                                    var str_mid = k + '"</span>,<span class="colorBlue">' + c;
                                    var str_back = '</span>);';
                                    var str_full = str_front + str_mid + str_back;
                                    param_str_full_complete += str_full + '\n';
                                };
                                return param_str_full_complete;
                            }
                            var ex_string_java_a = '<span class="colorBlue colorBold">class</span> Program {\n\n    <span class="colorBlue colorBold">public static void</span> main(String[] args) {\n\n    <span class="colorGreen">//Define the API-Key and Secret key (the keys can be obtained from your site setup page on Gigya\'s website).</span>\n    <span class="colorBlue colorBold">final</span> String apiKey = <span class="colorBlue">"PUT-YOUR-APIKEY-HERE"</span>;\n    <span class="colorBlue colorBold">final</span> String secretKey = <span class="colorBlue">"PUT-YOUR-SECRET-KEY-HERE"</span>;' + newParamJava + '\n\n    ';
                            var ex_string_java_b = 'String apiMethod = <span class="colorBlue">"' + lssdk.ceg.nodes[nodeId].api + '"</span>;\n    GSRequest request = <span class="colorBlue colorBold">new</span> GSRequest(apiKey, secretKey, apiMethod' + userKeyStringJava + ');\n\n';
                            var ex_string_java_c = setApiParamsStringJava();
                            var ex_string_java_d = '\n\n    GSResponse response = request.send();\n\n\n    <span class="colorBlue colorBold">if</span>(response.getErrorCode()==<span class="colorGreen">0</span>)\n        {\n            System.out.printIn(<span class="colorBlue">"success!"</span>);\n        }\n    <span class="colorBlue colorBold">else</span>\n        {\n            System.out.printIn(<span class="colorBlue">"Uh-oh, we got the following error: "</span> + response.getLog());\n        }\n\n    }\n}\n';
                            var full_java_request_string = ex_string_java_a + ex_string_java_b + ex_string_java_c + ex_string_java_d;
                            lssdk.ceg.addCodeExampleToNode('java', full_java_request_string);
                        } else if ((exampleType === "js") || (exampleType === "javascript")) { // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< JS
                            lssdk.ceg.nodes[nodeId].js_params = {};
                            lssdk.ceg.nodes[nodeId].js_params.keys = {};
                            lssdk.ceg.nodes[nodeId].js_params.vals = {};
                            var myCount = Object.keys(lssdk.ceg.nodes[nodeId].baseParams).length;
                            var param_str_full_complete = '';

                            // JS SPECIAL CONVERSION FOR FUNCTION SUPPORT
                            var jsParams = lssdk.ceg.nodes[nodeId].baseParams;
                            if ((typeof(jsParams) !== 'undefined') && (typeof(jsParams) === 'object')) {
                                var jsIndex = 0;
                                for (var key in jsParams) {
                                    if (jsParams.hasOwnProperty(key)) {
                                        jsIndex = jsIndex + 1;
                                        //console.log("jsParams:key ", key);
                                        //console.log("jsParams:jsParams[key] ", jsParams[key]);
                                        lssdk.ceg.nodes[nodeId].js_params.keys[jsIndex] = key;
                                        var checkParam = lssdk.ceg.checkIfParamIsObject(jsParams[key]);
                                        //console.log("############checkParam: ", checkParam);
                                        if (checkParam !== false) {
                                            lssdk.ceg.nodes[nodeId].js_params.vals[jsIndex] = checkParam;
                                        } else {
                                            if (typeof(jsParams[key]) == 'boolean') {
                                                lssdk.ceg.nodes[nodeId].js_params.vals[jsIndex] = jsParams[key];
                                            } else {
                                                lssdk.ceg.nodes[nodeId].js_params.vals[jsIndex] = "\"" + jsParams[key] + "\"";
                                            }
                                        }
                                        
                                    }
                                }
                                //console.log("**********************************************");
                                //console.log(lssdk.ceg.nodes[nodeId].js_params);
                            } else {
                                //console.warn("BREAK>>");
                                return false;
                            }
                            function setApiParamsStringJs2() {
                                var jsIndex = 0;
                                var x = 0;
                                //console.log("jsIndex: ", jsIndex);
                                //console.log("baseParams: " , lssdk.ceg.nodes[nodeId].baseParams);
                                for (var i = 1; i < lssdk.ceg.nodes[nodeId].paramsArray.length +1; i++) {
                                    var str_front = '        "';
                                    var c,k;
                                    //console.log("NOW: ", i);
                                    //console.log(lssdk.ceg.nodes[nodeId].js_params);
                                    k = lssdk.ceg.nodes[nodeId].js_params.keys[i];
                                    /*if (typeof(lssdk.ceg.nodes[nodeId].js_params.vals[i]) === 'function') {
                                        c = lssdk.ceg.parseFunction(lssdk.ceg.nodes[nodeId].js_params.vals[i]);
                                        console.log("k: ", k);
                                    } else {
                                        c = lssdk.ceg.nodes[nodeId].js_params.vals[i];
                                    }*/
                                    c = String(lssdk.ceg.nodes[nodeId].js_params.vals[i]);
                                    //console.log("converted to string: ", c);
                                    //c.replace(/\w/g, "&nbsp;");
                                    jsIndex = jsIndex + 1;
                                    // TESTING
                                    //console.log("lssdk.ceg.nodes[nodeId].paramsArray[i].split('$$$')[1]: ", c);
                                    //console.log("baseParams: " , lssdk.ceg.nodes[nodeId].baseParams);
                                    var str_mid = k + '":' + c;
                                    var str_back = ''; // moved the comma down
                                    var str_full = str_front + str_mid + str_back;
                                    function doInt() {
                                        x = x + 1;
                                    }
                                    doInt();
                                    if (i === lssdk.ceg.nodes[nodeId].paramsArray.length) {
                                        param_str_full_complete += str_full;
                                    } else {
                                        param_str_full_complete += str_full + ',<br/>&nbsp;&nbsp;&nbsp;&nbsp;';
                                    }
                                };
                                return param_str_full_complete;
                            }


                            function setApiParamsStringJs() {
                                var x = 0;
                                for (var i = 0; i < lssdk.ceg.nodes[nodeId].paramsArray.length; i++) {
                                    var str_front = '        "';
                                    var c;
                                    var k = lssdk.ceg.nodes[nodeId].paramsArray[i].split("$$$")[0];
                                    c = lssdk.ceg.nodes[nodeId].paramsArray[i].split("$$$")[1];

                                    // TESTING
                                    //console.log("lssdk.ceg.nodes[nodeId].paramsArray[i].split('$$$')[1]: ", c);
                                    //console.log("baseParams: " , lssdk.ceg.nodes[nodeId].baseParams);



                                    var str_mid = k + '":' + c;
                                    var str_back = ',';
                                    var str_full = str_front + str_mid + str_back;
                                    function doInt() {
                                        x = x + 1;
                                    }
                                    doInt();
                                    if (/[\[{]/g.test(str_full)) {
                                        var e = str_full
                                        
                                        // fix initial occurance of {
                                        if (/^\s.*:"{/.test(e)) {
                                            e = e.replace(/"{/, '{\n             ');
                                            //console.log('a1', e);
                                        } 
                                        // fix initial occurance of [
                                        if (/^\s.*:"\[/.test(e)) {
                                            e = e.replace(/"\[/, '[\n             ');
                                            //console.log('b1', e);
                                        }
                                        // fix last occurance of }
                                        if (/}",$/.test(e)) {
                                            e = e.replace(/}",$/, '\n        },');
                                            //console.log('c1', e);
                                        }
                                        // fix last occurance of }
                                        if (/\]",$/.test(e)) {
                                            e = e.replace(/\]",$/, '\n        ],');
                                            //console.log('c1', e);
                                        }
                                        str_full = e;
                                    }
                                    param_str_full_complete += str_full + '\n';
                                };
                                return param_str_full_complete;
                            }
                            var ex_string_js_a = '&lt;!-- The Gigya Web SDK is required once per page--&gt;\n&lt;scr' + 'ipt type=<span class="colorBlue">"text/javascript"</span> lang=<span class="colorBlue">"javascript"</span> src=<span class="colorBlue">"https://cdns.gigya.com/js/gigya.js?apikey=ENTER-YOUR-API-KEY-HERE"</span>&gt;&lt;/scr' + 'ipt&gt;\n\n&lt;scr' + 'ipt&gt;\n    <span class="colorBlue colorBold">var</span> params = {<span class="colorBlue">\n';
                            var ex_string_js_b; // = setApiParamsStringJs2();
                            if (lssdk.ceg.nodes[nodeId].langs.length === 1) {
                                ex_string_js_b = setApiParamsStringJs2();
                            } else {
                                ex_string_js_b = setApiParamsStringJs();
                            }
                            ex_string_js_b = ex_string_js_b.replace(/,\n$/, '\n');
                            var ex_string_js_c = '    </span>}\n    gigya.' + lssdk.ceg.nodes[nodeId].api + '(params);\n&lt;/scr' + 'ipt&gt;\n';
                            var full_js_request_string = ex_string_js_a + ex_string_js_b + ex_string_js_c;
                            lssdk.ceg.addCodeExampleToNode('javascript', full_js_request_string);
                        } else if (exampleType === "php") { // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< PHP
                            var myCount = Object.keys(lssdk.ceg.nodes[nodeId].baseParams).length;
                            var param_str_full_complete = '';
                            function setApiParamsStringPhp() {
                                for (var i = 0; i < lssdk.ceg.nodes[nodeId].paramsArray.length; i++) {    
                                    var str_front = '<span class="colorYellow">$request</span>->setParam(<span class="colorBlue">"';
                                    var k = lssdk.ceg.nodes[nodeId].paramsArray[i].split("$$$")[0];
                                    var c;
                                    c = lssdk.ceg.nodes[nodeId].paramsArray[i].split("$$$")[1];
                                    if ((c.match(/\[/g) || []).length >= 1) {
                                        c = JSON.stringify(c);
                                    } else if ((c.match(/\{/g) || []).length >= 1) {
                                        c = JSON.stringify(c);
                                    } /* else if ((c.match(/:/g) || []).length >= 1) {
                                        c = JSON.stringify(c);
                                    }*/
                                    else if (((c.match(/"/g) || []).length === 2) && ((c.match(/:/g) || []).length < 1)) {

                                    } else {

                                    }
                                    var str_mid = k + '"</span>,<span class="colorBlue">' + c;
                                    var str_back = '</span>);';
                                    var str_full = str_front + str_mid + str_back;
                                    param_str_full_complete += str_full + '\n';
                                    //param_str_full_complete = param_str_full_complete.replace(/=/g,'=\'');
                                };
                                return param_str_full_complete;
                            }
                            // IE SAFE
                            var ex_string_php_ie_a = '<?php\n\n<span class="colorBlue colorBold">include_once</span>(<span class="colorBlue">"/libs/GSSDK.php"</span>);\n\n<span class="colorYellow">$apiKey</span> = <span class="colorBlue">"PUT-YOUR-APIKEY-HERE"</span>;\n<span class="colorYellow">$secretKey</span> = <span class="colorBlue">"PUT-YOUR-SECRET-KEY-HERE"</span>;' + newParamPhp + '\n\n';
                            var ex_string_php_ie_api_b = '<span class="colorYellow">$method</span> = "' + lssdk.ceg.nodes[nodeId].api + '"</span>;'; //api name $method = "%requestAPI%";
                            var ex_string_php_ie_c = '\n\n<span class="colorYellow">$request</span> = <span class="colorBlue colorBold">new</span> GSRequest(<span class="colorYellow">$apiKey</span>,<span class="colorYellow">$secretKey</span>,<span class="colorYellow">$method</span>' + userKeyStringPhp + ');\n';
                            var ex_string_php_ie_params_d = setApiParamsStringPhp();
                            var ex_string_php_ie_e = '\n<span class="colorYellow">$response</span> = <span class="colorYellow">$request</span>->send();\n\n<span class="colorBlue colorBold">if</span>(<span class="colorYellow">$response</span>->getErrorCode()==0)\n    {\n        <span class="colorPink">echo</span> <span class="colorBlue">"Success"</span>;\n    }\n<span class="colorBlue colorBold">else</span>\n    {\n        <span class="colorPink">echo</span> (<span class="colorBlue">"Uh-oh, we got the following error: "</span> . <span class="colorYellow">$response</span>->getErrorMessage());\n        <span class="colorPink">error_log</span>(<span class="colorYellow">$response</span>->getLog());\n    }\n\n?>';
                            full_php_request_string = ex_string_php_ie_a + ex_string_php_ie_api_b + ex_string_php_ie_c + ex_string_php_ie_params_d + ex_string_php_ie_e;
                            lssdk.ceg.addCodeExampleToNode('php', full_php_request_string);
                        } else if ((exampleType === "py") || (exampleType === "python")) { // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< PY
                            var myCount = Object.keys(lssdk.ceg.nodes[nodeId].baseParams).length;
                            var param_str_full_complete = ''; 
                            function setApiParamsStringPy() {
                                for (var i = 0; i < lssdk.ceg.nodes[nodeId].paramsArray.length; i++) {
                                    var str_front = '    "';
                                    var c;
                                    var k = lssdk.ceg.nodes[nodeId].paramsArray[i].split("$$$")[0];
                                    c = lssdk.ceg.nodes[nodeId].paramsArray[i].split("$$$")[1];
                                    if ((c.match(/\[/g) || []).length >= 1) {
                                        c = JSON.stringify(c);
                                    } else if ((c.match(/\{/g) || []).length >= 1) {
                                        c = JSON.stringify(c);
                                    } /* else if ((c.match(/:/g) || []).length >= 1) {
                                        c = JSON.stringify(c);
                                    }*/
                                    else if (((c.match(/"/g) || []).length === 2) && ((c.match(/:/g) || []).length < 1)) {

                                    } else {

                                    }
                                    var str_mid = k + '":' + c;
                                    var str_back = '</span>,<span class="colorBlue">';
                                    var str_full = str_front + str_mid + str_back;
                                    param_str_full_complete += str_full + '\n';
                                };
                                return param_str_full_complete.replace(/,([^,]*)$/,'$1'); // return complete string minus last (extra) comma
                            }
                            // IE SAFE
                            var ex_string_py_ie_a = '<span class="colorBlue colorBold">from</span> GSSDK <span class="colorBlue colorBold">import *</span>\n\n<span class="colorGreen"># Define the API and Secret key (the keys can be obtained from your site setup page in the Gigya console).</span>\napiKey = <span class="colorBlue">"PUT-YOUR-APIKEY-HERE"</span>\nsecretKey = <span class="colorBlue">"PUT-YOUR-SECRET-KEY-HERE"</span>' + newParamPython + '\n\n<span class="colorGreen"># Step 1 - Defining the request and adding parameters</span>\n';
                            var ex_string_py_ie_params_d = setApiParamsStringPy();
                            ex_string_py_ie_params_d = ex_string_py_ie_params_d.replace(/,\n$/, '\n');
                            var ex_string_py_ie_api_b = 'method <span class="colorBlue">= "' + lssdk.ceg.nodes[nodeId].api + '"</span>\nparams <span class="colorBlue">=</span> {\n<span class="colorBlue">' + ex_string_py_ie_params_d + '</span>}\nrequest <span class="colorBlue">=</span> new GSRequest(apiKey,secretKey,method,params' + userKeyStringPython + ')\n\n<span class="colorGreen"># Step 2 - Sending the request</span>\nresponse <span class="colorBlue">=</span> request.send()\n\n<span class="colorGreen"># Step 3 - handling the request\'s response.</span>\n<span class="colorBlue colorBold">if</span> (response.getErrorCode()==<span class="colorGreen">0</span>):\n    <span class="colorGreen"># SUCCESS! response status = OK</span>\n    <span class="colorPink">print</span> <span class="colorBlue">"Success in ' + lssdk.ceg.nodes[nodeId].api + ' operation."</span>\n<span class="colorBlue colorBold">else</span>:\n    <span class="colorGreen"># Error</span>\n    <span class="colorPink">print</span> <span class="colorBlue">"Got error on ' + lssdk.ceg.nodes[nodeId].api + ': "</span> + response.getErrorMessage()\n    <span class="colorGreen"># You may also log the response: response.getLog()</span>';
                            //var ex_string_py_ie_c = '\n\n$';
                            //var ex_string_py_ie_e = '\n$response = $request->send();\n\nif($response->getErrorCode()==0);\n    {\n        echo "Success";\n    }\nelse\n    {\n        echo ("Uh-oh, we got the following error: " . $response->getErrorMessage());\n        error_log($response->getLog());\n    }\n\n?>';
                            full_py_request_string = ex_string_py_ie_a + ex_string_py_ie_api_b;
                            lssdk.ceg.addCodeExampleToNode('python', full_py_request_string);
                        } else {
                            console.warn("WARNING! constructCodeExample encountered a non-fatal error: Invalid language specified: ", exampleType);
                        }
                    } //END of IF TYPE
                } // END IF PARAMS EXIST
            }// END constructCodeExample

            // add all code blocks to the node
            lssdk.ceg.createCodeExamples(lssdk.ceg.nodes[nodeId].langs);


            // Create listner to switch data per selected drop-down option and change example per lang selection
            lssdk.ceg.hideAllExamples = function(name) {
                var thisNode;
                if ((typeof(name) !== 'undefined') && (typeof(lssdk.ceg.nodes[name]) !== 'undefined') && (name !== null)) {
                    thisNode = name;
                } else {
                    console.warn("ERROR! You did it now. You just broke the internet...");
                    return false;
                }
                if ((typeof(document.getElementById("innerCodeContainer_" + thisNode + "_net")) !== 'undefined') && (document.getElementById("innerCodeContainer_" + thisNode + "_net") !== null)) {
                    document.getElementById("innerCodeContainer_" + thisNode + "_net").style.display = "none";
                }
                if ((typeof(document.getElementById("innerCodeContainer_" + thisNode + "_android")) !== 'undefined') && (document.getElementById("innerCodeContainer_" + thisNode + "_android") !== null)) {
                    document.getElementById("innerCodeContainer_" + thisNode + "_android").style.display = "none";
                }
                if ((typeof(document.getElementById("innerCodeContainer_" + thisNode + "_curl")) !== 'undefined') && (document.getElementById("innerCodeContainer_" + thisNode + "_curl") !== null)) {
                    document.getElementById("innerCodeContainer_" + thisNode + "_curl").style.display = "none";
                }
                if ((typeof(document.getElementById("innerCodeContainer_" + thisNode + "_ios")) !== 'undefined') && (document.getElementById("innerCodeContainer_" + thisNode + "_ios") !== null)) {
                    document.getElementById("innerCodeContainer_" + thisNode + "_ios").style.display = "none";
                }
                if ((typeof(document.getElementById("innerCodeContainer_" + thisNode + "_java")) !== 'undefined') && (document.getElementById("innerCodeContainer_" + thisNode + "_java") !== null)) {
                    document.getElementById("innerCodeContainer_" + thisNode + "_java").style.display = "none";
                }
                if ((typeof(document.getElementById("innerCodeContainer_" + thisNode + "_javascript")) !== 'undefined') && (document.getElementById("innerCodeContainer_" + thisNode + "_javascript") !== null)) {
                    document.getElementById("innerCodeContainer_" + thisNode + "_javascript").style.display = "none";
                }
                if ((typeof(document.getElementById("innerCodeContainer_" + thisNode + "_php")) !== 'undefined') && (document.getElementById("innerCodeContainer_" + thisNode + "_php") !== null)) {
                    document.getElementById("innerCodeContainer_" + thisNode + "_php").style.display = "none";
                }
                if ((typeof(document.getElementById("innerCodeContainer_" + thisNode + "_python")) !== 'undefined') && (document.getElementById("innerCodeContainer_" + thisNode + "_python") !== null)) {
                    document.getElementById("innerCodeContainer_" + thisNode + "_python").style.display = "none";
                }
            };
            lssdk.ceg.selectAnOption = function(node, val) {
                lssdk.ceg.hideAllExamples(node);
                var changeMe = document.getElementById("innerCodeContainer_" + node + "_" + val.toLowerCase().replace(/[.]/,""));
                lssdk.ceg.cookies.set(val.toLowerCase().replace(/[.]/,""));
                var titleContainerName = lssdk.ceg.nodes[node].selectUI_TitleContainer;
                var titleDiv = document.getElementById(titleContainerName);
                var titleVal;
                if (typeof(val) !== 'undefined') {
                    if ((val.toLowerCase() === ".net") || (val.toLowerCase() === "net")) {
                        titleVal = ".NET";
                    } else if (val.toLowerCase() === "android") {
                        titleVal = "Android";
                    }
                     else if (val.toLowerCase() === "curl") {
                        titleVal = "cURL";
                    } else if (val.toLowerCase() === "java") {
                        titleVal = "Java";
                    } else if ((val.toLowerCase() === "javascript") || (val.toLowerCase() === "js")) {
                        titleVal = "JavaScript";
                    }  else if (val.toLowerCase() === "php") {
                        titleVal = "PHP";
                    } else if ((val.toLowerCase() === "python") || (val.toLowerCase() === "py")) {
                        titleVal = "Python";
                    }
                }
                if (titleVal) {
                    titleDiv.innerHTML = titleVal + " Code Example";
                } else {
                    titleDiv.innerHTML = "Code Example";
                }
                
                // change drop-down
                var totalN,indexN;
                totalN = lssdk.ceg.nodes[node].selectUI.children;
                lssdk.ceg.nodes[node].selectUI_totalN = totalN;
                var fullVal;
                for (var i = 0; i < totalN.length; i++) {
                    fullVal = val + "$"; // Needed to keep 'java' from triggering 'javascript'
                    fullId = totalN[i].id + "$"; // Needed to keep 'java' from triggering 'javascript'
                    //console.log("fullVal: ", fullVal);
                    //console.log("fullId: ", fullId);
                    if (fullId.indexOf(fullVal) > -1) {
                        indexN = totalN[i].index;
                    } 
                }
                if (indexN) {
                    lssdk.ceg.nodes[node].selectUI.selectedIndex = indexN;
                }
                if (val.toLowerCase().replace(/[.]/,"") == "select a platform") {
                    
                } else {
                        changeMe.style.display = "block";
                }
            };
            lssdk.ceg.nodes[nodeId].addSelectUIListener = function() {
                var trigger = document.getElementById(lssdk.ceg.nodes[nodeId].selectUI.id);
                var newValue;
                trigger.addEventListener("change", function(val) {
                    newValue = trigger.value;
                    lssdk.ceg.selectAnOption(nodeId, newValue);
                });
            };
        } else { // END CONFIG OBJ PARSE
            console.warn("ERROR! ceg_ext.js - No config object found.");
            return false;
        } 
        lssdk.ceg.createCodeWrapper(nodeId);
        var codeList;
        if (typeof(lssdk.ceg.nodes[nodeId].convertedCodeBlocks) !== 'undefined') {
            codeList = lssdk.ceg.nodes[nodeId].convertedCodeBlocks;
            for(var propName in codeList) {
                if(codeList.hasOwnProperty(propName)) {
                    var newKey = propName;
                    lssdk.ceg.createSpecificCodeContainer(nodeId,newKey);
                }
            }
        } else {
            console.warn("ERROR! Fatal error in lssdk.ceg.run");
        }
        lssdk.ceg.nodes[nodeId].addSelectUIListener();

        console.warn("lssdk.ceg.run has succesfully added code example at node: " +  nodeId); // notice of code example completion
        lssdk.ceg.nodes_exist = true;
    } // end of lssdk.ceg.run

	lssdk.ceg.getLatestNode = function(inc) {
        var allNames = [];
        var latestNode;
        for(var obj in inc) { 
            if (obj.indexOf("cegNode_") > -1) {
                allNames.push(obj);
            }
        }
        if (allNames.length > 0) {
           latestNode = allNames[allNames.length-1];
           return latestNode;
        } else {
           return false;
        }
    };



    // Enables toggling userKey example on and off
    lssdk.ceg.toggleUserKey = function(configObject) {
    var useKey,newConfig,oldConfig;
    if ((typeof(configObject) === 'object') && (configObject !== null)) {
        oldConfig = configObject;
        //console.log(oldConfig);
    } else {
        console.warn("Error! No configObject found with the specified name.");
        return false;
    }
    if (typeof(oldConfig.useUserKey) !== 'undefined') {
        if (oldConfig.useUserKey === true) {
            useKey = false;
        } else if (oldConfig.useUserKey === false) {
            useKey = true;
        } else {
            useKey = true;
        }
    } else {
        useKey = true;
    }
    //console.log(useKey);
    newConfig = oldConfig;
    newConfig.useUserKey = useKey;
    document.getElementById(newConfig.containerId).innerHTML = "";
    lssdk.ceg.run(newConfig);
};
//example: lssdk.ceg.toggleExample(accountsGetAccountInfoCodeExampleParams); // name of configObejct passed in the original lssdk.ceg.run() function
    console.warn("\nCode Example Generator extension for LSSDK (ceg_ext.js) " + lssdk.ceg.version + " has successfully loaded.\n"); // initialize notice
    // check user's preferred platform
     setTimeout(function(){ lssdk.ceg.cookies.checkCookie(); }, 1000);
} else {
    console.warn("ERROR! LSSDK not found. ceg_ext.js requires lssdk.js.");
} // end if/else wrapper
/**
 * **************************************************************************
 * END CODE EXAMPLE GENERATOR EXTENSION                                     *
 * **************************************************************************
 */
 
</script>