<commit_before><!DOCTYPE html>
<html>
<head>
    <title>Create deep links for Sears</title>
    <link rel="icon" href="https://branch.io/img/press/kit/badge-black.png" />
    <link rel="stylesheet" href="style.css" />

    <!-- jQuery Library via Google CDN -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="<KEY>" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="<KEY>" crossorigin="anonymous">

    <!-- Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="<KEY>" crossorigin="anonymous"></script>

    <!-- Import clipboard.js -->
    <script src="https://cdn.jsdelivr.net/npm/clipboard@1/dist/clipboard.min.js"></script>

    <!-- Import Papa Parse -->
    <script src="PapaParse-4.3.2/papaparse.min.js"></script>

    <!-- Import FileSaver.js -->
    <script src="FileSaver.js-master/FileSaver.min.js"></script>


    <!-- Script to generate 3P link based on user inputs -->
    <script>
        function generate3PLink() {
            //var domain = window.document.getElementById("branchDomain").value;
            //var ESPProviderCode = window.document.getElementById("ESPProviderCode").value;
            var desktop_url = false;
            var original_url = window.document.getElementById("originalUrl").value;

            if (!original_url) {
                alert("Please enter a destination URL.");
                window.document.getElementById("originalUrl").focus();
                return
            } else if (original_url) {
                desktop_url = true;
            }
            var params = '';
            var output = '';
            // Get query parameters and add to params variable
            var table1 = window.document.getElementById('query_params');
            for (var i = 0, row; row = table1.rows[i]; i++) {
                var key = table1.rows[i].cells[1].children[0].value
                var value = table1.rows[i].cells[2].children[0].value
                var firstKey = table1.rows[0].cells[1].children[0].value
                var firstValue = table1.rows[0].cells[2].children[0].value
                if (key && value) {
                    params += (key + '=' + encodeURIComponent(value) + '&');
                }
            }

            var table2 = window.document.getElementById('analytic_params');
            for (var i = 0, row; row = table2.rows[i]; i++) {
                var key = table2.rows[i].cells[1].children[0].value
                var value = table2.rows[i].cells[2].children[0].value

                if (key && value) {
                    if (key == '~tags') {
                        var tags = value.split(',');
                        var validate = value.split(/[\s,]+/);
                        var tagLength = tags.length;
                        var validateLength = validate.length;
                        if (tagLength != validateLength) {
                            alert("For multiple tags, separate with commas and no spaces.");
                            window.document.getElementById("analytic-value-3").focus();
                            return
                        }
                        for (var n = 0; n < tagLength; n++) {
                            params += (key + '=' + tags[n] + '&');
                        }
                    } else {
                        params += (key + '=' + value + '&');
                    }
                } else if (key == 'utm_campaign' && !value) {
                    window.document.getElementById("generated3PLink").value = "utm_campaign is required";
                    return
                }
            }

            
            //var encodedURL = encodeURIComponent(original_url);
            if (!/(http(s?))\:\/\//.test(original_url)) {
                original_url = 'https://' + original_url;
            }
            if (desktop_url) {
                if (params == '') {
                    output = get3PLink(original_url);
                } else {
                    output = get3PLink(original_url) + '&' + params.slice(0, params.length - 1);
                }
                output = output + '&utm_channel=email';
            }

            window.document.getElementById("generated3PLink").value = output;
        }

        // Returns current number of query parameter rows
        function getRowCount() {
            var rowCount = window.document.getElementById('query_params').rows.length;

            return rowCount;
        }

        // Adds a new row for additional query parameters
        function addQuerylinkParam() {
            var newRowIndex = getRowCount() + 1;

            var newRowHTML = `<tr id="row-${newRowIndex}"><td><label style="margin-right:10px">Query Param ${newRowIndex}</label></td><td><input class="form-control" style="width:500px" id="query-key-${newRowIndex}" type="text"/></td><td><input class="form-control" style="width:500px" id="query-value-${newRowIndex}" type="text"/></td></tr>`;
            $("#query_params").append(newRowHTML);
        }

        // Removes a query parameter row
        function removeQuerylinkParam() {
            rowCount = getRowCount();
            if (rowCount > 1) {
                current_row = getRowCount();
                $(`#row-${current_row}`).remove();
            }

        }


        function get3PLink(original_url) {
            var branch_url = 'https://' + 'sears.app.link' + '/3p?' + encodeURIComponent('$3p') + '=' + 'e_rs' + '&' + encodeURIComponent('$original_url') + '=' + encodeURIComponent(original_url);

            return branch_url;
        }

        function parseFile() {
            var domain = window.document.getElementById("branchDomain").value;
            var ESPProviderCode = window.document.getElementById("ESPProviderCode").value;
            var selectedFile = document.getElementById('files').files[0];

            var csv_array = 'destination,3p_link\n';

            // Make sure we have everything
            if (domain == '') {
                alert("Add a Branch Domain");
                return;
            } else if (ESPProviderCode == 'np') {
                alert("Please select an ESP");
                return;
            } else if (selectedFile == null) {
                alert("Please upload a file");
                return;
            } else {
                Papa.parse(selectedFile, {
                    header: true,

                    step: function(row) {
                        original_url = row.data[0]["destination_url"];
                        csv_array += (original_url + ',' + get3PLink(original_url) + '\n');
                        console.log(row.data.length);
                    },
                    complete: function(results) {
                        // var blob = new Blob([csv_array], {type: "text/csv;charset=utf-8"});
                        // saveAs(blob, "BranchLinks.csv");
                    }
                });
            }
        }

        function toggleView() {
            $(".toggle").toggle();
        }
    </script>
</head>

<body class="container">
    <!-- Initialize clipboard.js -->
    <script>(function(){new Clipboard('#copy-button');})();</script>

    <div>
        </br>
        <img src="https://branch.io/img/logo-dark.svg" style="width:100px;">
        </br>
        </br>
        <h1 style="display:inline; vertical-align:middle">Create deep links for Sears</h1>
    </div>
    <br />
    <button class="form-control toggle" style="float:none; background-color:#d3d3d3; display:none;" onclick="toggleView()">I want to generate one-off links</button>

    <!-- Description for one-off link creation -->
    <section class="container toggle" id="description_oneoff">
        <p><ol>
            <li>"Add Query Parameters" - add any key-value pairs you'd like to add (i.e., target=song, product=704, etc)</li>
            <li>"Add Analytics Tags" - add optional branch analytics to segment data in Branch's dashboard</li>
            <li>"Create Email Link" - click this to build a Branch link that you can paste into your email</li>
        </ol></p>
        <br />
    </section>

    <!-- Description for CSV upload -->
    <section class="container toggle" id="description_csv" style="display:none">
        <h3>CSV Link Generator</h3>
        <h3>How to use this tool</h3>
        <p><ol>
            <li>Upload a CSV file consisting of a column of the destination URLs you're looking to "Branch-ify."
            <li>3P Link Generator will look for a header called "destination_url" and output a .csv file with columns "destination_url,3p_link"</li>
        </ol></p>
        <br />
    </section>

    <section class="container" id="link-creation">
        <!-- Table for user input -->
        <table>
            <tbody>
                <tr class="toggle">
                    <td><label style="margin-right: 10px">Original URL</label></td>
                    <td><input class="form-control" style="width:500px" id="originalUrl" type="text" placeholder="i.e., https://m.sears.com/appliances/b-1020003"/></td>
                    <td><div class="help-tip"><p style="margin-left:5px">This is the web URL you're converting into a deep link</p></div></td>
                </tr>
                <tr class="toggle" style="display:none;">
                    <td><label style="margin-right: 10px">File Upload</label></td>
                    <td><input  type="file" id="files"></td>
                </tr>
            </tbody>
        </table>
        <h5>NOTE: This will be the default redirect that Desktop users, and mobile users without the app, are sent to</h5>
        <br>
        <h3 class="toggle">Add Query Parameters</h3>
        <h5>(add key-value pairs to be included on the web redirect, and sent in app)</h5>
        <br>

        <!-- Deep linking parameters table -->
        <table id="query_params" class="toggle">
            <tr id="row-1">
                <td><label style="margin-right: 10px">Query Param 1</label></td>
                <td><input class="form-control" style="width:500px" id="query-key-1" type="text" placeholder="i.e., $desktop_url, $ios_url, etc"/></td>
                <td><input class="form-control" style="width:500px" id="query-value-1" type="text" placeholder="i.e., https://www.sears.com"/></td>
            </tr>
        </table>

        <br>
        <button class="btn toggle" id="add-query-button" style="background-color:#d3d3d3; display:inline;" onclick="addQuerylinkParam()">Add Query Param</button>
        <button class="btn toggle" id="remove-query-button" style="background-color:#d3d3d3; display:inline;"onclick="removeQuerylinkParam()">Remove Query Param</button>
        <br>

        <h3 class="toggle">Add Analytics Tags</h3>
        <h5>(add analytics tags for tracking in Branch dashboard)</h5>
        <br>

        <table id="analytic_params" class="toggle">
            <tr id="analytic-1">
                <td><label style="margin-right: 10px">utm_campaign</label></td>
                <td><input class="form-control" style="width:500px" id="analytic-key-1" type="text" value="utm_campaign" disabled="true"/></td>
                <td><input class="form-control" style="width:500px" id="analytic-value-1" type="text" placeholder="music promo"/></td>
            </tr>
            <tr id="analytic-3">
                <td><label style="margin-right: 10px">~tags</label></td>
                <td><input class="form-control" style="width:500px" id="analytic-key-3" type="text" value="~tags" disabled="true"/></td>
                <td><input class="form-control" style="width:500px" id="analytic-value-3" type="text" placeholder="version1,freecredits                                    Note: tags cannot contain spaces"/></td>
            </tr>
        </table>
        <br/>
        For more information about analytics tags, please visit <a href="https://docs.branch.io/pages/links/integrate/#analytical-labels">here</a>.
        You can view the performance of your Branch links on your <a href="https://dashboard.branch.io/email/analytics">Branch dashboard</a> and filter by these analytics tags. To learn more about filtering, please visit <a href="https://docs.branch.io/pages/emails/get-started/#visualizing-email-performance">here</a>.

    </section>

    <section>
        <br>
        <br>
        <div class="text-center"><button class="form-control toggle" style="float:none; background-color:#7FFF00;" onclick="generate3PLink()">Create Email Link</button></div>
        <div class="text-center"><button class="form-control toggle" style="float:none; background-color:#d3d3d3; display:none;" onclick="parseFile()">Process CSV</button></div>
        <br>
        <br>
    </section>

    <section class="container toggle" id="linkOutput">
        <h3>Generated Email Link
        <button class="btn" id="copy-button" style="background-color:#d3d3d3; display:inline;" data-clipboard-target="#generated3PLink">Copy Link</button>
        </h3>
        <textarea class="form-control" style="height:100px; margin-bottom:5%;" id="generated3PLink" type="text"></textarea>
    </section>
</body>
</html>
<commit_msg>builder<commit_after><!DOCTYPE html>
<html>
<head>
    <title>Create deep links for Sears</title>
    <link rel="icon" href="https://branch.io/img/press/kit/badge-black.png" />
    <link rel="stylesheet" href="style.css" />

    <!-- jQuery Library via Google CDN -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="<KEY>" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="<KEY>" crossorigin="anonymous">

    <!-- Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="<KEY>" crossorigin="anonymous"></script>

    <!-- Import clipboard.js -->
    <script src="https://cdn.jsdelivr.net/npm/clipboard@1/dist/clipboard.min.js"></script>

    <!-- Import Papa Parse -->
    <script src="PapaParse-4.3.2/papaparse.min.js"></script>

    <!-- Import FileSaver.js -->
    <script src="FileSaver.js-master/FileSaver.min.js"></script>


    <!-- Script to generate 3P link based on user inputs -->
    <script>
        function generate3PLink() {
            //var domain = window.document.getElementById("branchDomain").value;
            //var ESPProviderCode = window.document.getElementById("ESPProviderCode").value;
            var desktop_url = false;
            var original_url = window.document.getElementById("originalUrl").value;

            if (!original_url) {
                alert("Please enter a destination URL.");
                window.document.getElementById("originalUrl").focus();
                return
            } else if (original_url) {
                desktop_url = true;
            }
            var params = '';
            var output = '';
            // Get query parameters and add to params variable
            var table1 = window.document.getElementById('query_params');
            for (var i = 0, row; row = table1.rows[i]; i++) {
                var key = table1.rows[i].cells[1].children[0].value
                var value = table1.rows[i].cells[2].children[0].value
                var firstKey = table1.rows[0].cells[1].children[0].value
                var firstValue = table1.rows[0].cells[2].children[0].value
                if (key && value) {
                    params += (key + '=' + encodeURIComponent(value) + '&');
                }
            }

            var table2 = window.document.getElementById('analytic_params');
            for (var i = 0, row; row = table2.rows[i]; i++) {
                var key = table2.rows[i].cells[1].children[0].value
                var value = table2.rows[i].cells[2].children[0].value

                if (key && value) {
                    if (key == '~tags') {
                        var tags = value.split(',');
                        var validate = value.split(/[\s,]+/);
                        var tagLength = tags.length;
                        var validateLength = validate.length;
                        if (tagLength != validateLength) {
                            alert("For multiple tags, separate with commas and no spaces.");
                            window.document.getElementById("analytic-value-3").focus();
                            return
                        }
                        for (var n = 0; n < tagLength; n++) {
                            params += (key + '=' + tags[n] + '&');
                        }
                    } else {
                        params += (key + '=' + value + '&');
                    }
                } else if (key == 'utm_campaign' && !value) {
                    window.document.getElementById("generated3PLink").value = "utm_campaign is required";
                    return
                }
            }

            
            //var encodedURL = encodeURIComponent(original_url);
            if (!/(http(s?))\:\/\//.test(original_url)) {
                original_url = 'https://' + original_url;
            }
            if (desktop_url) {
                if (params == '') {
                    output = get3PLink(original_url);
                } else {
                    output = get3PLink(original_url) + '&' + params.slice(0, params.length - 1);
                }
                output = output + '&utm_channel=email';
            }

            window.document.getElementById("generated3PLink").value = output;
        }

        // Returns current number of query parameter rows
        function getRowCount() {
            var rowCount = window.document.getElementById('query_params').rows.length;

            return rowCount;
        }

        // Adds a new row for additional query parameters
        function addQuerylinkParam() {
            var newRowIndex = getRowCount() + 1;

            var newRowHTML = `<tr id="row-${newRowIndex}"><td><label style="margin-right:10px">Query Param ${newRowIndex}</label></td><td><input class="form-control" style="width:500px" id="query-key-${newRowIndex}" type="text"/></td><td><input class="form-control" style="width:500px" id="query-value-${newRowIndex}" type="text"/></td></tr>`;
            $("#query_params").append(newRowHTML);
        }

        // Removes a query parameter row
        function removeQuerylinkParam() {
            rowCount = getRowCount();
            if (rowCount > 1) {
                current_row = getRowCount();
                $(`#row-${current_row}`).remove();
            }

        }


        function get3PLink(original_url) {
            var branch_url = 'https://' + 'sears.app.link' + '/3p?' + encodeURIComponent('$3p') + '=' + 'e_rs' + '&' + encodeURIComponent('$original_url') + '=' + encodeURIComponent(original_url);

            return branch_url;
        }

        function parseFile() {
            var domain = window.document.getElementById("branchDomain").value;
            var ESPProviderCode = window.document.getElementById("ESPProviderCode").value;
            var selectedFile = document.getElementById('files').files[0];

            var csv_array = 'destination,3p_link\n';

            // Make sure we have everything
            if (domain == '') {
                alert("Add a Branch Domain");
                return;
            } else if (ESPProviderCode == 'np') {
                alert("Please select an ESP");
                return;
            } else if (selectedFile == null) {
                alert("Please upload a file");
                return;
            } else {
                Papa.parse(selectedFile, {
                    header: true,

                    step: function(row) {
                        original_url = row.data[0]["destination_url"];
                        csv_array += (original_url + ',' + get3PLink(original_url) + '\n');
                        console.log(row.data.length);
                    },
                    complete: function(results) {
                        // var blob = new Blob([csv_array], {type: "text/csv;charset=utf-8"});
                        // saveAs(blob, "BranchLinks.csv");
                    }
                });
            }
        }

        function toggleView() {
            $(".toggle").toggle();
        }
    </script>
</head>

<body class="container">
    <!-- Initialize clipboard.js -->
    <script>(function(){new Clipboard('#copy-button');})();</script>

    <div>
        </br>
        <img src="https://branch.io/img/logo-dark.svg" style="width:100px;">
        </br>
        </br>
        <h1 style="display:inline; vertical-align:middle">Create deep links for Sears</h1>
    </div>
    <br />
    <button class="form-control toggle" style="float:none; background-color:#d3d3d3; display:none;" onclick="toggleView()">I want to generate one-off links</button>

    <!-- Description for one-off link creation -->
    <section class="container toggle" id="description_oneoff">
        <p><ol>
            <li>"Original URL" - add a web url you want to convert to a deep link</li>
            <li>"Add Query Parameters" - add any key-value pairs you'd like to add (i.e., target=song, product=704, etc)</li>
            <li>"Add Analytics Tags" - add optional branch analytics to segment data in Branch's dashboard</li>
            <li>"Create Email Link" - click this to build a Branch link that you can paste into your email</li>
        </ol></p>
        <br />
    </section>

    <!-- Description for CSV upload -->
    <section class="container toggle" id="description_csv" style="display:none">
        <h3>CSV Link Generator</h3>
        <h3>How to use this tool</h3>
        <p><ol>
            <li>Upload a CSV file consisting of a column of the destination URLs you're looking to "Branch-ify."
            <li>3P Link Generator will look for a header called "destination_url" and output a .csv file with columns "destination_url,3p_link"</li>
        </ol></p>
        <br />
    </section>

    <section class="container" id="link-creation">
        <!-- Table for user input -->
        <table>
            <tbody>
                <tr class="toggle">
                    <td><label style="margin-right: 10px">Original URL</label></td>
                    <td><input class="form-control" style="width:500px" id="originalUrl" type="text" placeholder="i.e., https://m.sears.com/appliances/b-1020003"/></td>
                    <td><div class="help-tip"><p style="margin-left:5px">This is the web URL you're converting into a deep link</p></div></td>
                </tr>
                <tr class="toggle" style="display:none;">
                    <td><label style="margin-right: 10px">File Upload</label></td>
                    <td><input  type="file" id="files"></td>
                </tr>
            </tbody>
        </table>
        <h5>NOTE: This will be the default redirect that Desktop users, and mobile users without the app, are sent to</h5>
        <br>
        <h3 class="toggle">Add Query Parameters</h3>

        <!-- Deep linking parameters table -->
        <table id="query_params" class="toggle">
            <tr id="row-1">
                <td><label style="margin-right: 10px">Query Param 1</label></td>
                <td><input class="form-control" style="width:500px" id="query-key-1" type="text" placeholder="i.e., $desktop_url, $ios_url, etc"/></td>
                <td><input class="form-control" style="width:500px" id="query-value-1" type="text" placeholder="i.e., https://www.sears.com, valueABC"/></td>
            </tr>
        </table>

        <br>
        <button class="btn toggle" id="add-query-button" style="background-color:#d3d3d3; display:inline;" onclick="addQuerylinkParam()">Add Query Param</button>
        <button class="btn toggle" id="remove-query-button" style="background-color:#d3d3d3; display:inline;"onclick="removeQuerylinkParam()">Remove Query Param</button>
        <br>

        <h3 class="toggle">Add Analytics Tags</h3>
        <table id="analytic_params" class="toggle">
            <tr id="analytic-1">
                <td><label style="margin-right: 10px">utm_campaign</label></td>
                <td><input class="form-control" style="width:500px" id="analytic-key-1" type="text" value="utm_campaign" disabled="true"/></td>
                <td><input class="form-control" style="width:500px" id="analytic-value-1" type="text" placeholder="music promo"/></td>
            </tr>
            <tr id="analytic-3">
                <td><label style="margin-right: 10px">~tags</label></td>
                <td><input class="form-control" style="width:500px" id="analytic-key-3" type="text" value="~tags" disabled="true"/></td>
                <td><input class="form-control" style="width:500px" id="analytic-value-3" type="text" placeholder="version1,freecredits                                    Note: tags cannot contain spaces"/></td>
            </tr>
        </table>
        <br/>
        For more information about analytics tags, please visit <a href="https://docs.branch.io/pages/links/integrate/#analytical-labels">here</a>.
        You can view the performance of your Branch links on your <a href="https://dashboard.branch.io/email/analytics">Branch dashboard</a> and filter by these analytics tags. To learn more about filtering, please visit <a href="https://docs.branch.io/pages/emails/get-started/#visualizing-email-performance">here</a>.

    </section>

    <section>
        <br>
        <br>
        <div class="text-center"><button class="form-control toggle" style="float:none; background-color:#7FFF00;" onclick="generate3PLink()">Create Email Link</button></div>
        <div class="text-center"><button class="form-control toggle" style="float:none; background-color:#d3d3d3; display:none;" onclick="parseFile()">Process CSV</button></div>
        <br>
        <br>
    </section>

    <section class="container toggle" id="linkOutput">
        <h3>Generated Email Link
        <button class="btn" id="copy-button" style="background-color:#d3d3d3; display:inline;" data-clipboard-target="#generated3PLink">Copy Link</button>
        </h3>
        <textarea class="form-control" style="height:100px; margin-bottom:5%;" id="generated3PLink" type="text"></textarea>
    </section>
</body>
</html>

{'fraction_non_alphanumeric': 0.153648739120732, 'fraction_numerical': 0.012645986758907981, 'mean_word_length': 2.051526500964703, 'pattern_counts': {'":': 0, '<': 423, '<?xml version=': 0, '>': 423, 'https://': 28, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1840051', 'n_tokens_mistral': 7824, 'n_tokens_neox': 7362, 'n_words': 1629}