<commit_before>var pendingOrders = false;
////////////////////////////////////////////////////////////////////////////////////////////////////////////
function oid() {
    //Get Token Balance
    try {
        $("#tokenBal").html(allTokens.balanceTokens.totalEarned.toFixed(2) + " tokens");
    } catch (err) {
        console.log(err)
        $("#tokenBal").html('<div class="walletUserUnlock" style="width: 95px; float: left; padding-left: 20px; position: relative;"><svg id="userWallet" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 334.877 334.877" style="enable-background:new 0 0 334.877 334.877; width: 24px; float: left; margin-top: 16px;" xml:space="preserve"> <path d="M333.196,155.999h-16.067V82.09c0-17.719-14.415-32.134-32.134-32.134h-21.761L240.965,9.917 C237.571,3.798,231.112,0,224.107,0c-3.265,0-6.504,0.842-9.364,2.429l-85.464,47.526H33.815 c-17.719,0-32.134,14.415-32.134,32.134v220.653c0,17.719,14.415,32.134,32.134,32.134h251.18 c17.719,0,32.134-14.415,32.134-32.134v-64.802h16.067V155.999z M284.995,62.809c9.897,0,17.982,7.519,19.068,17.14h-24.152 l-9.525-17.14H284.995z M220.996,13.663c3.014-1.69,7.07-0.508,8.734,2.494l35.476,63.786H101.798L220.996,13.663z M304.275,302.742c0,10.63-8.651,19.281-19.281,19.281H33.815c-10.63,0-19.281-8.651-19.281-19.281V82.09 c0-10.63,8.651-19.281,19.281-19.281h72.353L75.345,79.95H37.832c-3.554,0-6.427,2.879-6.427,6.427s2.873,6.427,6.427,6.427h14.396 h234.83h17.217v63.201h-46.999c-21.826,0-39.589,17.764-39.589,39.589v2.764c0,21.826,17.764,39.589,39.589,39.589h46.999V302.742z M320.342,225.087h-3.213h-59.853c-14.743,0-26.736-11.992-26.736-26.736v-2.764c0-14.743,11.992-26.736,26.736-26.736h59.853 h3.213V225.087z M276.961,197.497c0,7.841-6.35,14.19-14.19,14.19c-7.841,0-14.19-6.35-14.19-14.19s6.35-14.19,14.19-14.19 C270.612,183.306,276.961,189.662,276.961,197.497z" style="fill: white;"></path> </svg> <div id="checkBal" class="balance-coins" style="position: absolute; left: 55px; padding-top: 3px;width: fit-content !important; text-align: left;">locked</div></div>');
    }

    if (window.location.hash != undefined) {

        //check if hash is oid
        var type = window.location.hash.substr(1);
        // split the hash
        var fields = type.split('=');
        var htpe = fields[0];
        var hval = fields[1];
        if (htpe == "oid") {
            M.toast({
                html: 'opening order... <div class="spinnerCheckout right" style="margin-top: 7px;line-height: normal;"> <div class="preloader-wrapper active" style="width: 20px; height: 20px; margin: 0px;"> <div class="spinner-layer spinner-white-only"> <div class="circle-clipper left"> <div class="circle"></div></div><div class="gap-patch"> <div class="circle"></div></div><div class="circle-clipper right"> <div class="circle"></div></div></div></div></div>',
                displayLength: 5000,
            });
            //get the shop and the oder details
            var shop = getBitsWinOpt('s')
            // oid
            $(".otitle").html("");
            $(".otitle").append("Your Order");
            $(".of").html("");
            //var uid = JSON.parseInt(hval)
            var od = getObjectStore('data', 'readwrite').get('bits-user-orders-' + localStorage.getItem("bits-user-name"));
            od.onsuccess = function(event) {
                try {
                    var odData = JSON.parse(event.target.result);
                    for (var ii = 0; ii < odData.length; ++ii) {
                        var xx = odData[ii].items
                        var xid = odData[ii].id
                        //makeOrder(products)
                        // match oid to url id
                        var urloid = getBitsOpt("oid")
                        if (urloid == xid) {
                            makeOrder(JSON.parse(xx), odData[ii].location)
                        } else {
                            //console.log("no match")
                        }
                    }
                } catch (err) {}
            };
            od.onerror = function() {};
            //makeOrder(hval)
        } else {
            //console.log("we dont know this hash")
        }
    } else {}
}


function getUserOders(f) {
    doFetch({
        action: 'getAllOrders',
        uid: localStorage.getItem("bits-user-name")
    }).then(function(e) {
        if (e.status == "ok") {
            userOrders = e.data;
            var pendingCount = 0;
            $(".allUserOrders").html('');
            for (ordersPending in userOrders) {

                if (userOrders[ordersPending].state == 'cancelled') {
                    var typeIcn = 'cancel';
                } else if (userOrders[ordersPending].state == 'wishlist') {
                    var typeIcn = 'loyalty';
                } else if (userOrders[ordersPending].state == 'pending') {

                    pendingCount++;
                    var typeIcn = 'schedule';
                } else if (userOrders[ordersPending].state == 'delivering') {
                    var typeIcn = 'motorcycle';

                    pendingCount++;
                } else if (userOrders[ordersPending].state == 'complete') {
                    var typeIcn = 'done_all';
                }

                //list orders for this service

                if (parseInt(getBitsWinOpt('s')) == userOrders[ordersPending].toservice) {
                    if (userOrders[ordersPending].state == 'pending') {
                        var orderDetails = userOrders[ordersPending];
                        if (userOrders[ordersPending].delPrice == "") {
                            userOrders[ordersPending].delPrice = 0
                        }
                        var totalPrice = parseInt(userOrders[ordersPending].proPrice) + parseInt(userOrders[ordersPending].delPrice);
                        $(".allUserOrders").append('<li id="' + userOrders[ordersPending].id + '" class="row" style=" background: #e2e2e2; border-radius: 3px; padding: 2px 10px; margin-bottom: 0px;"> <h6 style=" font-size: 1em;"><span style=" font-weight: bold;">Order ID:</span> ' + userOrders[ordersPending].id + '</h6><p style=" margin: 0px;"><span style=" font-weight: bold;">Item Price: </span> ' + userOrders[ordersPending].proPrice + '</p><p style=" margin: 0px;"><span style=" font-weight: bold;">Delivery Price: </span> ' + userOrders[ordersPending].delPrice + '</p><p style=" margin: 0px;"><span style=" font-weight: bold;">Total Price: </span> ' + totalPrice + '</p><p></p><button class="btn bits completeOrder" style=" display: block; margin-left: auto; margin-right: auto; margin-bottom: 10px;" onclick="completeOrder(' + orderDetails.id + ', ' + orderDetails.fromU + ', ' + orderDetails.toservice + ')">complete order</button> </li>');
                    }
                }

            }
            if (pendingCount > 1) {
                pendingOrders = true;
                $('.pendingOdersActive').html('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" viewBox="0 0 486.463 486.463" style="enable-background:new 0 0 486.463 486.463;width: 25px;" xml:space="preserve"><path d="M243.225,333.382c-13.6,0-25,11.4-25,25s11.4,25,25,25c13.1,0,25-11.4,24.4-24.4 C268.225,344.682,256.925,333.382,243.225,333.382z" fill="#D80027"></path><path d="M474.625,421.982c15.7-27.1,15.8-59.4,0.2-86.4l-156.6-271.2c-15.5-27.3-43.5-43.5-74.9-43.5s-59.4,16.3-74.9,43.4 l-156.8,271.5c-15.6,27.3-15.5,59.8,0.3,86.9c15.6,26.8,43.5,42.9,74.7,42.9h312.8 C430.725,465.582,458.825,449.282,474.625,421.982z M440.625,402.382c-8.7,15-24.1,23.9-41.3,23.9h-312.8 c-17,0-32.3-8.7-40.8-23.4c-8.6-14.9-8.7-32.7-0.1-47.7l156.8-271.4c8.5-14.9,23.7-23.7,40.9-23.7c17.1,0,32.4,8.9,40.9,23.8 l156.7,271.4C449.325,369.882,449.225,387.482,440.625,402.382z" fill="#D80027"></path><path d="M237.025,157.882c-11.9,3.4-19.3,14.2-19.3,27.3c0.6,7.9,1.1,15.9,1.7,23.8c1.7,30.1,3.4,59.6,5.1,89.7 c0.6,10.2,8.5,17.6,18.7,17.6c10.2,0,18.2-7.9,18.7-18.2c0-6.2,0-11.9,0.6-18.2c1.1-19.3,2.3-38.6,3.4-57.9 c0.6-12.5,1.7-25,2.3-37.5c0-4.5-0.6-8.5-2.3-12.5C260.825,160.782,248.925,155.082,237.025,157.882z" fill="#D80027"></path></svg>')<commit_msg>pending orders update<commit_after>var pendingOrders = false;
////////////////////////////////////////////////////////////////////////////////////////////////////////////
function oid() {
    //Get Token Balance
    try {
        $("#tokenBal").html(allTokens.balanceTokens.totalEarned.toFixed(2) + " tokens");
    } catch (err) {
        console.log(err)
        $("#tokenBal").html('<div class="walletUserUnlock" style="width: 95px; float: left; padding-left: 20px; position: relative;"><svg id="userWallet" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 334.877 334.877" style="enable-background:new 0 0 334.877 334.877; width: 24px; float: left; margin-top: 16px;" xml:space="preserve"> <path d="M333.196,155.999h-16.067V82.09c0-17.719-14.415-32.134-32.134-32.134h-21.761L240.965,9.917 C237.571,3.798,231.112,0,224.107,0c-3.265,0-6.504,0.842-9.364,2.429l-85.464,47.526H33.815 c-17.719,0-32.134,14.415-32.134,32.134v220.653c0,17.719,14.415,32.134,32.134,32.134h251.18 c17.719,0,32.134-14.415,32.134-32.134v-64.802h16.067V155.999z M284.995,62.809c9.897,0,17.982,7.519,19.068,17.14h-24.152 l-9.525-17.14H284.995z M220.996,13.663c3.014-1.69,7.07-0.508,8.734,2.494l35.476,63.786H101.798L220.996,13.663z M304.275,302.742c0,10.63-8.651,19.281-19.281,19.281H33.815c-10.63,0-19.281-8.651-19.281-19.281V82.09 c0-10.63,8.651-19.281,19.281-19.281h72.353L75.345,79.95H37.832c-3.554,0-6.427,2.879-6.427,6.427s2.873,6.427,6.427,6.427h14.396 h234.83h17.217v63.201h-46.999c-21.826,0-39.589,17.764-39.589,39.589v2.764c0,21.826,17.764,39.589,39.589,39.589h46.999V302.742z M320.342,225.087h-3.213h-59.853c-14.743,0-26.736-11.992-26.736-26.736v-2.764c0-14.743,11.992-26.736,26.736-26.736h59.853 h3.213V225.087z M276.961,197.497c0,7.841-6.35,14.19-14.19,14.19c-7.841,0-14.19-6.35-14.19-14.19s6.35-14.19,14.19-14.19 C270.612,183.306,276.961,189.662,276.961,197.497z" style="fill: white;"></path> </svg> <div id="checkBal" class="balance-coins" style="position: absolute; left: 55px; padding-top: 3px;width: fit-content !important; text-align: left;">locked</div></div>');
    }

    if (window.location.hash != undefined) {

        //check if hash is oid
        var type = window.location.hash.substr(1);
        // split the hash
        var fields = type.split('=');
        var htpe = fields[0];
        var hval = fields[1];
        if (htpe == "oid") {
            M.toast({
                html: 'opening order... <div class="spinnerCheckout right" style="margin-top: 7px;line-height: normal;"> <div class="preloader-wrapper active" style="width: 20px; height: 20px; margin: 0px;"> <div class="spinner-layer spinner-white-only"> <div class="circle-clipper left"> <div class="circle"></div></div><div class="gap-patch"> <div class="circle"></div></div><div class="circle-clipper right"> <div class="circle"></div></div></div></div></div>',
                displayLength: 5000,
            });
            //get the shop and the oder details
            var shop = getBitsWinOpt('s')
            // oid
            $(".otitle").html("");
            $(".otitle").append("Your Order");
            $(".of").html("");
            //var uid = JSON.parseInt(hval)
            var od = getObjectStore('data', 'readwrite').get('bits-user-orders-' + localStorage.getItem("bits-user-name"));
            od.onsuccess = function(event) {
                try {
                    var odData = JSON.parse(event.target.result);
                    for (var ii = 0; ii < odData.length; ++ii) {
                        var xx = odData[ii].items
                        var xid = odData[ii].id
                        //makeOrder(products)
                        // match oid to url id
                        var urloid = getBitsOpt("oid")
                        if (urloid == xid) {
                            makeOrder(JSON.parse(xx), odData[ii].location)
                        } else {
                            //console.log("no match")
                        }
                    }
                } catch (err) {}
            };
            od.onerror = function() {};
            //makeOrder(hval)
        } else {
            //console.log("we dont know this hash")
        }
    } else {}
}


function getUserOders(f) {
    doFetch({
        action: 'getAllOrders',
        uid: localStorage.getItem("bits-user-name")
    }).then(function(e) {
        if (e.status == "ok") {
            userOrders = e.data;
            var pendingCount = 0;
            $(".allUserOrders").html('');
            for (ordersPending in userOrders) {

                if (userOrders[ordersPending].state == 'cancelled') {
                    var typeIcn = 'cancel';
                } else if (userOrders[ordersPending].state == 'wishlist') {
                    var typeIcn = 'loyalty';
                } else if (userOrders[ordersPending].state == 'pending') {

                    pendingCount++;
                    var typeIcn = 'schedule';
                } else if (userOrders[ordersPending].state == 'delivering') {
                    var typeIcn = 'motorcycle';

                    pendingCount++;
                } else if (userOrders[ordersPending].state == 'complete') {
                    var typeIcn = 'done_all';
                }

                //list orders for this service

                if (parseInt(getBitsWinOpt('s')) == userOrders[ordersPending].toservice) {
                    if (userOrders[ordersPending].state == 'pending') {
                        var orderDetails = userOrders[ordersPending];
                        if (userOrders[ordersPending].delPrice == "") {
                            userOrders[ordersPending].delPrice = 0
                        }
                        var totalPrice = parseInt(userOrders[ordersPending].proPrice) + parseInt(userOrders[ordersPending].delPrice);
                        $(".allUserOrders").append('<li id="' + userOrders[ordersPending].id + '" class="row" style=" background: #e2e2e2; border-radius: 3px; padding: 2px 10px; margin-bottom: 0px;"> <h6 style=" font-size: 1em;"><span style=" font-weight: bold;">Order ID:</span> ' + userOrders[ordersPending].id + '</h6><p style=" margin: 0px;"><span style=" font-weight: bold;">Item Price: </span> ' + userOrders[ordersPending].proPrice + '</p><p style=" margin: 0px;"><span style=" font-weight: bold;">Delivery Price: </span> ' + userOrders[ordersPending].delPrice + '</p><p style=" margin: 0px;"><span style=" font-weight: bold;">Total Price: </span> ' + totalPrice + '</p><p></p><button class="btn bits completeOrder" style=" display: block; margin-left: auto; margin-right: auto; margin-bottom: 10px; background: ' + shopData.theme + ';" onclick="completeOrder(' + orderDetails.id + ', ' + orderDetails.fromU + ', ' + orderDetails.toservice + ')">complete order</button> </li>');
                    }
                }

            }
            if (pendingCount > 1) {
                pendingOrders = true;
                $('.pendingOdersActive').html('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" viewBox="0 0 486.463 486.463" style="enable-background:new 0 0 486.463 486.463;width: 25px;" xml:space="preserve"><path d="M243.225,333.382c-13.6,0-25,11.4-25,25s11.4,25,25,25c13.1,0,25-11.4,24.4-24.4 C268.225,344.682,256.925,333.382,243.225,333.382z" fill="#D80027"></path><path d="M474.625,421.982c15.7-27.1,15.8-59.4,0.2-86.4l-156.6-271.2c-15.5-27.3-43.5-43.5-74.9-43.5s-59.4,16.3-74.9,43.4 l-156.8,271.5c-15.6,27.3-15.5,59.8,0.3,86.9c15.6,26.8,43.5,42.9,74.7,42.9h312.8 C430.725,465.582,458.825,449.282,474.625,421.982z M440.625,402.382c-8.7,15-24.1,23.9-41.3,23.9h-312.8 c-17,0-32.3-8.7-40.8-23.4c-8.6-14.9-8.7-32.7-0.1-47.7l156.8-271.4c8.5-14.9,23.7-23.7,40.9-23.7c17.1,0,32.4,8.9,40.9,23.8 l156.7,271.4C449.325,369.882,449.225,387.482,440.625,402.382z" fill="#D80027"></path><path d="M237.025,157.882c-11.9,3.4-19.3,14.2-19.3,27.3c0.6,7.9,1.1,15.9,1.7,23.8c1.7,30.1,3.4,59.6,5.1,89.7 c0.6,10.2,8.5,17.6,18.7,17.6c10.2,0,18.2-7.9,18.7-18.2c0-6.2,0-11.9,0.6-18.2c1.1-19.3,2.3-38.6,3.4-57.9 c0.6-12.5,1.7-25,2.3-37.5c0-4.5-0.6-8.5-2.3-12.5C260.825,160.782,248.925,155.082,237.025,157.882z" fill="#D80027"></path></svg>')
{'fraction_non_alphanumeric': 0.20693201064601985, 'fraction_numerical': 0.17916767481248488, 'mean_word_length': 2.259660883280757, 'pattern_counts': {'":': 0, '<': 117, '<?xml version=': 0, '>': 117, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1649892', 'n_tokens_mistral': 7860, 'n_tokens_neox': 6271, 'n_words': 801}