In Winwheel.js using calculatePrize result when finish the whell

I am working on Winwheel.js for draw. Everything works fine but I’m stuck somewhere. When the wheel is turned, I get some datas with axios from back and the result is determined. I want to use this response when the wheel is stopped, I tried many of things but I didn’t do it.

let theWheel = new Winwheel({
                //wheel settings//       
                'segments'        :             
                [                               
                   {'fillStyle' : '#008000', 'text' : '150 Coin', 'textFontSize' : 13, 'textFillStyle' : '#ffffff'},
                   ...,    

                ],
                'animation' :          
                {
                    'type'     : 'spinToStop',
                    'duration' : 10,    
                    'spins'    : 3,    
                    'callbackFinished' : alertPrize,
                    'callbackSound'    : playSound,  
                    'soundTrigger'     : 'pin'        
                },
                'pins' :                // Turn pins on.
                {
                    'number'     : 10,
                    'fillStyle'  : 'silver',
                    'outerRadius': 4,
                }
            });
async function calculatePrize(){
                let result = await axios.post("/draw-reward-win-wheel/", {}).then((response) => {
                let stopAt;
                if(response.data.text == '150') stopAt = (1 + Math.floor((Math.random() * 30)));
                //Other possibilities

                theWheel.animation.stopAngle = stopAt;

                 theWheel.startAnimation();
            }).catch((err) => {
                console.log(err);
            });

    }

            async function alertPrize(code)
            {
                //I need response.data.text here
            }

Frozen Columns in JSF Primefaces

I would like to freeze columns in jsf using js, i.e. I want by using one scroll all tables to move and the name column to move with it , currently it works for me only on the main table and in the tables in <row:Expansion/> no longer. For each name column in each table there is an added class .frozen-column with positon:Sticky; please help.
enter image description here
enter image description here

        <h:form id="budgetReportByLocationForm">
            <div class="grid table-demo">
                <div class="col-12">
                    <div class="card">
                        <div class="flex justify-content-between align-items-center mb-2">
                            <div class="flex justify-content-center align-items-center">
                                <h4 style="margin: 0!important;">Planowanie Budżetu #{budgetPlanBean.budgetYear} - #{budgetSessionScope.budgetPlanLocationName}</h4>
                                <p style="margin-left: 10px; color: #1b74c5; font-weight: bold;">Limit Budżetu: #{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.budgetLimit)}</p>
                            </div>
                            <div>
                                <h:outputText value="Opcje:" styleClass="mr-2"/>
                                <p:menuButton icon="pi pi-ellipsis-v" styleClass="rounded-button">
                                    <p:submenu label="Generuj plik" icon="pi pi-file">
                                        <p:menuitem value="XLS" styleClass="mr-2 mb-2">
                                            <p:dataExporter type="xls"
                                                            target="budgetReportByLocationForm:tableBudgetReportObject"
                                                            fileName="Budżet-#{budgetPlanBean.budgetYear}-#{budgetSessionScope.budgetPlanLocationName}"/>
                                        </p:menuitem>

                                        <p:menuitem value="XLSX" styleClass="mr-2 mb-2">
                                            <p:dataExporter type="xlsxstream"
                                                            target="budgetReportByLocationForm:tableBudgetReportObject"
                                                            fileName="Budżet-#{budgetPlanBean.budgetYear}-#{budgetSessionScope.budgetPlanLocationName}"/>
                                        </p:menuitem>

                                        <p:menuitem value="PDF" styleClass="mr-2 mb-2">
                                            <p:dataExporter type="pdf"
                                                            target="budgetReportByLocationForm:tableBudgetReportObject"
                                                            fileName="Budżet-#{budgetPlanBean.budgetYear}-#{budgetSessionScope.budgetPlanLocationName}"/>
                                        </p:menuitem>

                                        <p:menuitem value="CSV" styleClass="mr-2 mb-2">
                                            <p:dataExporter type="csv"
                                                            target="budgetReportByLocationForm:tableBudgetReportObject"
                                                            fileName="Budżet-#{budgetPlanBean.budgetYear}-#{budgetSessionScope.budgetPlanLocationName}"/>
                                        </p:menuitem>

                                        <p:menuitem value="XML" styleClass="mr-2 mb-2">
                                            <p:dataExporter type="xml"
                                                            target="budgetReportByLocationForm:tableBudgetReportObject"
                                                            fileName="Budżet-#{budgetPlanBean.budgetYear}-#{budgetSessionScope.budgetPlanLocationName}"/>
                                        </p:menuitem>
                                    </p:submenu>
                                    <p:menuitem value="Edytuj informacje o budżecie"  oncomplete="PF('budgetEditBudgetDialog').show()" process="@this" update="messages"  icon="ui-icon-pencil"/>

                                </p:menuButton>
                            </div>
                        </div>
                        <p:dataTable
                                var="budgetPlan" rowIndexVar="lp" id="tableBudgetReportObject"
                                editable="true" widgetVar="datatableVarBcg"
                                rowKey="#{budgetPlan.budgetPositionId}"
                                showGridlines="true"
                                emptyMessage="Brak elementów"
                                value="#{budgetPlanBean.budgetValues.budgetPositionList}">
                            <p:ajax event="rowToggle"
                                    listener="#{budgetPlanBean.updateBudgetPlanMap(budgetPlan.budgetPositionId)}"/>
<!--                            <p:ajax update="messages" action="#{budgetPlanBean.checkBudgetLimit}" event="load"/>-->
                            <div class="linked">
                                <p:columnGroup type="header">
                                    <p:row>
                                        <p:column rowspan="2" headerText="Lp."
                                                  style="width:20px;!important;" styleClass="frozen-column"/>
                                        <p:column colspan="2" headerText="Nazwa grupy kosztowej"
                                                  style="width:300px;!important; position: sticky!important; background-color: #f8f9fa; "
                                                  styleClass="frozen-column"/>
                                        <p:column colspan="2" headerText="Edycja" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="MPK"
                                                  style="width:100px;!important; background-color: #f8f9fa; "/>
                                        <p:column colspan="2" headerText="Suma roczna" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Styczeń" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Luty" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Marzec" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Kwiecień" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Maj" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Czerwiec" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Lipiec" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Sierpień" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Wrzesień" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Październik" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Listopad" style="width: 100px!important;"/>
                                        <p:column colspan="2" headerText="Grudzień" style="width: 100px!important;"/>

                                    </p:row>
                                    <p:row>
                                        <p:column colspan="2" headerText="Suma" style="width: 300px!important;"
                                                  styleClass="frozen-column"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" headerText="" style=""/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" headerText="" style=""/>
                                        <p:column styleClass="columnBcgOdd" colspan="2"
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.yearValue)}"
                                                  style="color: #{budgetPlanBean.isBudgetLimitExceededSum() ? 'red' : 'inherit'};"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[0])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[1])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[2])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[3])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[4])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[5])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[6])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[7])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[8])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[9])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[10])}"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style=""
                                                  headerText="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlanBean.budgetValues.monthValueList[11])}"/>
                                    </p:row>
                                </p:columnGroup>

                                <p:column style=" width: 20px!important;" styleClass="frozen-column">
                                    <h:outputText value="#{lp+1}"/>
                                </p:column>

                                <p:column style="width:300px;!important; " styleClass="frozen-column" colspan="2">
                                    <p:rowToggler rendered="#{not budgetPlan.last}"/>
                                    <h:outputText value="#{budgetPlan.budgetPositionName}"/>
                                </p:column>
                                <p:column rendered="#{not budgetPlan.last}" style="width: 100px!important;"
                                          colspan="2"/>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="width: 100px!important;"
                                          rendered="#{budgetPlan.last}">
                                    <div style="display: flex!important; justify-content: center!important; align-items: center!important;">
                                        <p:commandButton icon="pi pi-pencil"
                                                         styleClass="rounded-button ui-button-flat ui-button-flat"
                                                         onclick="PF('openingPlanEdit').show()"
                                                         process="@this"
                                                         update="dialogForm messages"
                                                         actionListener="#{budgetPlanBean.initUpdateBudgetPlanPosition(budgetPlan)}"

                                        />
                                        <p:commandButton icon="pi pi-times"
                                                         styleClass="rounded-button ui-button-danger ui-button-flat"
                                                         process="@this"
                                                         ajax="false"
                                                         update="budgetReportByLocationForm"
                                                         actionListener="#{budgetPlanBean.clearBudgetPlanPosition(budgetPlan)}"
                                                         onstart="return confirm('Czy na pewno chcesz wyzerować?')"/>
                                    </div>

                                </p:column>
                                <p:column style="width:100px;!important; " colspan="2">
                                    <h:outputText value="#{budgetPlan.budgetPositionMpk}"/>
                                </p:column>
                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.yearValue)}"/>
                                </p:column>
                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[0])}"/>
                                </p:column>
                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[1])}"/>
                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[2])}"/>
                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[3])}"/>
                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[4])}"/>
                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[5])}"/>
                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[6])}"/>
                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[7])}"/>
                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[8])}"/>
                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[9])}"/>
                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[10])}"/>

                                </p:column>

                                <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                    <h:outputText
                                            value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan.monthValueList[11])}"/>
                                </p:column>

                            </div>


                            <p:rowExpansion rendered="#{not budgetPlan.last}">
                                <p:dataTable value="#{budgetPlanBean.budgetPlanMap.get(budgetPlan.budgetPositionId)}"
                                             rowKey="#{budgetPlan2.budgetPositionId}"
                                             emptyMessage="Brak elementów"
                                             styleClass="linked"
                                             showGridlines="true"
                                             id="tableBcge" var="budgetPlan2" rowIndexVar="lp">
                                    <p:ajax event="rowToggle"
                                            listener="#{budgetPlanBean.updateBudgetPlanMap(budgetPlan2.budgetPositionId)}"/>
                                    <div class="linked">
                                        <p:column style="" styleClass="frozen-column">
                                            <h:outputText value="#{lp+1}"/>
                                        </p:column>

                                        <p:column style="width:300px;!important; margin-left: 0!important; "
                                                  styleClass="frozen-column" colspan="2">
                                            <p:rowToggler rendered="#{not budgetPlan2.last}"/>
                                            <h:outputText value="#{budgetPlan2.budgetPositionName}"/>
                                        </p:column>
                                        <p:column rendered="#{not budgetPlan2.last}" style="width: 100px!important;"
                                                  colspan="2"/>
                                        <p:column styleClass="columnBcgOdd" colspan="2"
                                                  style="flex-direction: column!important; width: 100px!important;"
                                                  rendered="#{budgetPlan2.last}">
                                            <div style="display: flex!important; justify-content: center!important; align-items: center!important;">

                                                <p:commandButton icon="pi pi-pencil"
                                                                 styleClass="rounded-button ui-button-flat ui-button-flat"
                                                                 onclick="PF('openingPlanEdit').show()"
                                                                 process="@this"
                                                                 update="dialogForm messages"
                                                                 actionListener="#{budgetPlanBean.initUpdateBudgetPlanPosition(budgetPlan2)}"
                                                />
                                                <p:commandButton icon="pi pi-times"
                                                                 styleClass="rounded-button ui-button-danger ui-button-flat"
                                                                 process="@this"
                                                                 update="budgetReportByLocationForm"
                                                                 actionListener="#{budgetPlanBean.clearBudgetPlanPosition(budgetPlan2)}"
                                                                 onstart="return confirm('Czy na pewno chcesz wyzerować?')"/>
                                            </div>
                                        </p:column>
                                        <p:column style="width:100px;!important; " colspan="2">
                                            <h:outputText value="#{budgetPlan2.budgetPositionMpk}"/>
                                        </p:column>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.yearValue)}"/>
                                        </p:column>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[0])}"/>
                                        </p:column>
                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[1])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[2])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[3])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[4])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[5])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[6])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[7])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[8])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[9])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[10])}"/>
                                        </p:column>

                                        <p:column styleClass="columnBcgOdd" colspan="2" style="">
                                            <h:outputText
                                                    value="#{numberFormatter.formatDecimalNumberWithCommas(budgetPlan2.monthValueList[11])}"/>
                                        </p:column>

                                    </div>

.frozen-column { position: sticky!important; left: 0!important; color: #657380!important; z-index: 997; background: #F6F9FE!important; }

I tried using the built-in frozen-column in primefaces but it was crashing my table

Rebuild or Maintain a connection between android and MySQL database

I am creating an app with a html, css, js inside a webview, and also several databases to store data. My app is designed to be used for 10 to 11 hours each time.

A big problem was found that android will kill my app in background after leaving for a while. However, app gets killed will lead to a big problem as it means the whole task has to redo again. I have to maintain OR rebuild the connection between database and android to ensure my app can keep running smoothly.

I would like to know:
1.) is there any way to maintain the connection between database and android (e.g. put it in foreground service?) so that killing app will not affect the connection?

2.) can I ask android and js to rebuild the connection (e.g. synchronize the database?) between android and js after the app get killed by OS?

How to save response file every iterationData in newman librarty

Hallo I want to save file response every iterationData in newman library node js.
In collection I have one request. This is my file.

const newman = require('newman');
const fs = require('fs');
      let today = new Date().toISOString().slice(0, 10)
      let time = Date.now();
      let jsonFile = './response.json'
newman.run({
    collection: require('./collection.json'),
    reporters: 'cli',
    iterationData: jsonFile,
    verbose: true
}).on('request', function (error, data) {
    if (error) {
        console.error(error);
        return; 
    }
    const requestname = data.item.name; 
    const filename = 'response_'+requestname+ '_' + today + '_' + time+'.json'; 
    const content  = data.response.json(); 
    fs.writeFile(filename, JSON.stringify(content), function (error) {
        if (error) { 
            console.error(error);
        }
    });
console.log('Request name: ' + data.item.name);
        });  

connection issue to aws neptune in nodejs

i am trying to implement aws neptune in my nodejs application. i’ve successfully created the database, and i have written the code for connection with neptune. i am unable to connect. following error appears:

ERROR Error: connect ETIMEDOUT 172.31.23.182:8182
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1595:16) {
  errno: -4039,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '172.31.23.182',
  port: 8182
}

i am using npm i gremline, in nodejs to establish a connection with aws neptune

following is my code for it

const gremlin = require("gremlin");
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
const Graph = gremlin.structure.Graph;

dc = new DriverRemoteConnection(
  "wss://db-neptune-1-instance-1.crgy0cuiqvqy.ap-southeast-2.neptune.amazonaws.com:8182",
  {}
);
// console.log(process.env.wws_connection_PORT);

const graph = new Graph();
const g = graph.traversal().withRemote(dc);

g.V()
  .limit(1)
  .count()
  .next()
  .then((data) => {
    console.log(data);
    dc.close();
  })
  .catch((error) => {
    console.log("inside catch")
    console.log("ERROR", error);
    dc.close();
  });

SharePoint online Autocomplete javascript

Two SharePoint lists, List A and List B, are connected. List B uses a lookup value that references List A. This lookup functionality works well when there are less than 5,000 items in List A. However, it breaks once the number of items in List A exceeds this limit.

I’ve tried replacing the lookup with a custom Autocomplete JavaScript solution, but unfortunately, the autocomplete function also encounters the same issue and only works for lists with less than 5,000 entries. Here’s the script for reference. Could anyone offer assistance in resolving this problem as soon as possible?

Code:

<script src="/sites/xxxxx/SiteAssets/jquery.min.js"></script>
<script src="/sites/xxxxx/SiteAssets/jquery.SPServices-2014.02.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $().SPServices.SPAutocomplete({
            sourceList: "ABC",
            sourceColumn: "XYZ",
            columnName: "AtoZ",
            ignoreCase: true,
            numChars: 2,
            slideDownSpeed: 'fast'
        });
    });
</script>

three.js: cube with text on each surface

my goal is to create a cube with text on each surface.

I succeeded with a cube and text on one surface enter image description here

I found a nice example for text on each surface here: https://hofk.de/main/discourse.threejs/2020/DodecahedronCanvasTexture/DodecahedronCanvasTexture.html
enter image description here

But when I try to adopt this example I fail with enter image description here

Can anyone please help me what I’m doing wrong? You can see my broken try here: https://github.com/StephanPraetsch/react-three/blob/82995143844a768d6ccb10771f25d22713b37a48/src/components/Dodecahedron/Dodecahedron.tsx

there was an issue while adopting the example: the onBeforeCompile has been moved and it doesn’t work anymore. I don’t know if that is the crucial part.

When I change from tsx to jsx In next js , the design on the browser page changes

I am building a project using typescript for some files, for other files that were in tsx I changed them to jsx but the issue I am facing is that the design in the browser of that file changes! ,

I did not make any changes to the tailwind or CSS related to those files, its only from the conversion of tsx to jsx (if I convert back to TSX the design will be okay again )

I am using Next js 14 and tailwind CSS

How to prioritize VS Code Auto-Import modules from my local directories over node_modules?

I often face an issue with the auto-import feature in VS Code where, upon typing the name of a module that exists both as a local module (or function) and within node_modules, VS Code’s auto-import feature prefers the version in node_modules.

For example, when I type cx and save, the auto-import adds:

import { cx } from "class-variance-authority";

However, I would like it to prioritize and auto-import my local version instead, like so:

import { cx } from "@/app/_utils/cx";

Another example, when I type <Button/> and save, the auto-import adds:

import Button from "@mui/material/Button";

However, I would like the auto-import to add my local version, like so:

import Button from "@/app/components/Button";

If this configuration cannot be achieved directly in VS Code, I would appreciate any recommendations for an extension that could facilitate this.

Export a HTML table to a XLS/XLSX file without external libraries/packages

I have this JavaScript code to clone a table with selected columns and then export the cloned table to an XLS file:

const empTable = document.getElementById('emp-index-table-main');
const xlsExportBtn = document.getElementById('toXLS');

const exportToXLS = (empTable, columns) => {
    let clonedTable = empTable.cloneNode(true);
    let clonedTableBody = clonedTable.querySelector("#employeeTableBody");
    let selectedColumns = [];

    clonedTable.querySelectorAll("td, th").forEach(cell => {
        cell.style.display = "none";
    });

    columns.forEach(columnClass => {
        let firstCell = clonedTableBody.querySelector(`.${columnClass}`);
        if (firstCell) {
            let headerTitle = firstCell.getAttribute('data-title');
            selectedColumns.push({ class: columnClass, title: headerTitle });
        }
    });

    let idOrder = clonedTableBody.querySelectorAll('[id^="employee-"]');
    let classOrder = [];
    for (let i = 0; i < idOrder.length; i++) {
        let idC = idOrder[i].id;
        idC = idC.replace(/-td/g, '');
        if (!classOrder.includes(idC)) {
            classOrder.push(idC);
        }
    }

    let selectedColumnsInOrder = [];
    classOrder.forEach(column => {
        let checkColumn = selectedColumns.find(e => e.class === column);
        if (checkColumn) {
            selectedColumnsInOrder.push({ class: column, title: checkColumn.title });
        }
    });

    let newTableHeader = document.createElement("thead");
    let newTableRow = document.createElement("tr");
    selectedColumnsInOrder.forEach(column => {
        let newHeaderCell = document.createElement("th");
        newHeaderCell.textContent = column.title;
        newTableRow.appendChild(newHeaderCell);
    });
    newTableHeader.appendChild(newTableRow);
    clonedTable.insertBefore(newTableHeader, clonedTableBody);

    selectedColumnsInOrder.forEach(column => {
        clonedTable.querySelectorAll(`.${column.class}`).forEach(cell => {
            cell.style.display = "table-cell";
        });
    });

    const html_code = `
    <!DOCTYPE html>
    <html>
    <head>
        <style>
        @media print {
            table, table td, table th {
                border: 1px solid #000;
                border-collapse: collapse;
            }
            table {
                width: 100%;
            }
            table th, td {
                padding: 2px 1px;
            }
            .employee-firstname, .employee-middlename, .employee-lastname, .employee-fullname, .employee-localaddress {
                padding: 2px 0px 2px 10px !important;
            }
            .employee-id, .employee-gender, .employee-dateofbirth, .employee-phonenumber, .employee-email, .employee-departmentname, .employee-positionname, .employee-startdate, .employee-enddate {
                text-align: center;
            }
        }
        </style>
    </head>
    <body>
        <table id="emp-index-table-main" class="tablehead"">${clonedTable.innerHTML}</table>
    </body>
    </html>`;

    const blob = new Blob([html_code], { type: 'application/vnd.ms-excel' });

    const link = document.createElement('a');
    link.href = URL.createObjectURL(blob);
    link.download = 'EmployeeData.xls';
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
};

xlsExportBtn.addEventListener('click', () => {
    $('#selectColumnModal').modal('show');
    $('#select-column-done-btn').one('click', function () {
        let columns = Array.from(document.querySelectorAll('.columnToggle:checked')).map(el => el.value);
        exportToXLS(empTable, columns);
    });
});

I successfully cloned the original employee list table with a selection of columns (I actually use this way to export to a PDF file). However, after the step of sending the Blob object, the downloaded .xls file contains the whole original table with an extra row of selected columns’ headers right below the original headers.
What is wrong here? And if I want to export a .xlsx file, is the process the same as exporting the .xls file?

React: Issue Updating Weather Details Based on Selected City

I’m encountering an issue with my React application where I’m unable to update the weather details based on the selected city using the OpenWeatherMap API. Here’s the setup:

  1. I have a parent component App which manages the state of latitude and longitude.

  2. Inside App, I have a child component DisplayFetch that fetches weather details based on latitude and longitude.

  3. I also have another child component SearchCities inside DisplayFetch, which allows users to search for a city and updates the latitude and longitude when a city is selected.

The problem arises when I select a new city in SearchCities. Although the latitude and longitude are updated correctly in the App component, the weather details displayed in DisplayFetch do not update accordingly. The weather details remain associated with the previous location, rather than updating to the weather of the newly selected city.

I’ve ensured that the updateLocation function in the App component correctly updates the state of latitude and longitude, and it is being passed down to DisplayFetch and further to SearchCities. Additionally, I’ve confirmed that the update function (passed from DisplayFetch to SearchCities) is being called when a new city is selected, and it is correctly updating the latitude and longitude.

import React, { useState, useEffect } from "react";
import DisplayFetch from "./components/DisplayFetch";

export default function App() {
  const [latitude, setLatitude] = useState(null);
  const [longitude, setLongitude] = useState(null);

  useEffect(() => {
    navigator.geolocation.getCurrentPosition(
      (position) => {
        console.log(position.coords.latitude);
        console.log(position.coords.longitude);
        setLatitude(position.coords.latitude);
        setLongitude(position.coords.longitude);
      },
      (error) => {
        console.error("Error getting current geolocation:", error);
      }
    );
  }, []);

  const updateLocation = (lat, long) => {
    setLatitude(lat);
    setLongitude(long);
  };

  return (
    <div className="flex items-center justify-center h-screen bg-darkSlate">
      <div>
        {latitude} {longitude}
      </div>
      {latitude !== null && longitude !== null ? (
        <DisplayFetch
          latitude={latitude}
          longitude={longitude}
          updateLocation={updateLocation}
        />
      ) : (
        <p>Loading...dasdasdasdasdas</p>
      )}
    </div>
  );
}
import React, { useState, useEffect } from "react";
import WeatherBox from "./WeatherBox";
import { CiLocationOn } from "react-icons/ci";
import { AsyncPaginate } from "react-select-async-paginate";
import SearchCities from "./SearchCities";

const DisplayFetch = ({ latitude, longitude, updateLocation }) => {
  const [data, setData] = useState([]);
  const [loading, setLoading] = useState(true);
  const [error, setError] = useState(null);

  useEffect(() => {
    fetchData();
  }, []);

  const fetchData = async () => {
    try {
      const response = await fetch(
        `https://api.openweathermap.org/data/2.5/weather?lat=${latitude}&lon=${longitude}&appid=MYAPI`
      );
      // Replace with your API endpoint
      if (!response.ok) {
        throw new Error("Network response was not ok.");
      }
      const data = await response.json();
      setData(data);
      setLoading(false);
    } catch (error) {
      setError(error.message);
      setLoading(false);
    }
  };
  return (
    <>
      {loading ? (
        <p>Loading...</p>
      ) : error ? (
        <p>Error: {error}</p>
      ) : (
        <div className="bg-paleBlue p-8 rounded-lg shadow-lg flex flex-col">
          <div className="relative border border-solid border-gray-300 rounded-md mb-4">
            <div>
              {latitude} {longitude}
            </div>
            <SearchCities
              latCity={latitude}
              longCity={longitude}
              update={updateLocation} // Pass updateLocation here
            />
            <div className="absolute inset-y-0 right-0 flex items-center pr-2"></div>
          </div>
          <div className="grid grid-cols-2 gap-4">
            <WeatherBox title="Min Temp" value={`${data.main.temp_min}°C`} />
            <WeatherBox title="Max Temp" value={`${data.main.temp_max}°C`} />
            <WeatherBox
              title="Feels Like"
              value={`${data.main.feels_like}°C`}
            />
            <WeatherBox title="Pressure" value={`${data.main.pressure} hPa`} />
            <WeatherBox title="Humidity" value={`${data.main.humidity}%`} />
            <WeatherBox title="Wind Speed" value={`${data.wind.speed} m/s`} />
          </div>
        </div>
      )}
    </>
  );
};

export default DisplayFetch;
import React, { useState, useEffect } from "react";
import { AsyncPaginate } from "react-select-async-paginate";
import { geoApiOptions, GEO_API_URL } from "../components/api";
import DisplayFetch from "./DisplayFetch";

const SearchCities = ({ latCity, longCity, update }) => {
  const [search, setSearch] = useState(null);

  const loadOptions = (inputValue) => {
    return fetch(
      `${GEO_API_URL}/cities?minPopulation=1000&namePrefix=${inputValue}`,
      geoApiOptions
    )
      .then((response) => response.json())
      .then((response) => {
        return {
          options: response.data.map((city) => {
            return {
              value: `${city.latitude} ${city.longitude}`,
              label: `${city.name}, ${city.countryCode}`,
            };
          }),
        };
      });
  };

  const handleOnChange = (searchData) => {
    setSearch(searchData);

    console.log(latCity);
    console.log(longCity);
    if (searchData) {
      const [lat, long] = searchData.value.split(" ");
      update(lat, long);
    } else {
      // Clear the latitude and longitude when no city is selected
      update(null, null);
    }
    console.log(latCity);
    console.log(longCity);
  };
  return (
    <>
      <AsyncPaginate
        placeholder="Search for city"
        debounceTimeout={600}
        value={search}
        onChange={handleOnChange}
        loadOptions={loadOptions}
      />
      <>
        <div>
          {latCity} from search city{longCity}
        </div>
      </>
    </>
  );
};

export default SearchCities;

please anybody find my eroors . i am strucked and tired….

Login limit counter not showing

I’m new with programming language and currently doing a laravel project. What I’m trying to do is create a login time limit, if a user mistype a password of an user account they will be given 5 trial to re type the password until reach the limit.

I modified the LoginController.php to create a custom login function and when I call the function the code was running perfectly.

$validate = Validator::make($request->all(), [
            'email' => ['required', 'string'],
            'password' => ['required', 'string'],
        ]);

        // If Validator Fail
        if ($validate->fails()) {
            $is_limit = 0;
            $refresh_time = 0;
            return redirect('/login')->with([$is_limit, $refresh_time])->withErrors($validate)->withInput();
        }

        if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {
            // Trying to log in
            Session::put('working_area', null);
            return redirect($this->redirectTo);
        }

        $data = $this->limit_check($request->email);
        $is_limit = $data[0];
        $refresh_time = $data[1];
        $email = $request->email;
        // return $data;
        return view('auth.login', compact('is_limit', 'refresh_time', 'email'));

But when the limit was reach the counter didn’t show in the page, here is my login.blade.php

@extends('layouts.auth')

@section('content')

<div class="logo">
    <img src="{{ asset('public/images/authentication/sign-in-logo.svg') }}" alt="">
</div>
<div class="whitebox">
    <img src="{{ asset('public/images/authentication/sign-in-whitebox.svg') }}" alt="">
</div>
<div class="whitebox-text">
    <div class="subtitle"><span>&#62;&#46;&nbsp;</span><span id="typewritter">SIGN IN</span></div>
    <div class="form-group">
        <form action="{{ route('login') }}" method="POST">
        @method('POST')
        @csrf
        <div class="field-holder">
            <input class="form-input @error('email') is-invalid @enderror" type="email" id="email" name="email" value="{{ $email }}" required>
            <label for="email">email</label>
            @error('email')
                <div class="alert alert-danger">{{ $message }}</div>
            @enderror
        </div>
        <div class="field-holder">
            <input class="form-input" type="password" id="password" name="password" required>
            <label for="password">password</label>
        </div>
        <div class="field-link">
            <a href="{{ route('password.email') }}" id="forgot">FORGOT PASSWORD</a>
        </div>
        <div class="field-holder">
            <div id="refreshTime">
                <span id="title"></span>
                <span id="time"></span>
            </div>
            <button class="btn" id="submit">SIGN IN</button>
        </div>
    </div>
    <div class="title">ASSET MANAGEMENT SYSTEM</div>
</div>
<script>
    let is_limit = @json($is_limit);
    let refresh_time = @json($refresh_time);
    let email = @json($email);
    if (is_limit == 1) {
        document.getElementById('title').innerHtml = 'refresh time : ';
        setInterval(() => {
            document.getElementById('time').innerHtml = refresh_time; 
        }, refresh_time);
    }
</script>
@endsection

I had tried test inserting javascript code to show a text by doing this

document.getElementBy('time').innerHTML = "refresh in :"

and checked the script src

<script src="{{asset('public/dist/bootstrap-5.1.3/js/bootstrap.js')}}"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>

from the test above the “refresh in :” text also not showing

In my thought the code logic was clear, but when I tested it it doesn’t work.
I don’t have any idea why my code won’t work…
Any idea about how to make my code work

Express using default error handling page instead of view?

I’m following this MDN Express tutorial on creating a “Local Library” app, that uses Pug (Jade) as its templating engine. In this part of the tutorial, it details creating a controller for handling a form POST request for a “create genre” page.

exports.genre_create_get = (req, res, next) => {
  res.render("genre_form", { title: "Create Genre" });
};

// Handle Genre create on POST.
exports.genre_create_post = [
  // Validate and sanitize the name field.
  body("name", "Genre name must contain at least 3 characters")
    .trim()
    .isLength({ mid: 3 })
    .escape(),

  // Process request after validation and sanitization.
  asyncHandler(async (req, res, next) => {
    // Extract the validation errors from a request.
    const errors = validationResult(req);

    // Create a genre object with escaped and trimmed data.
    const genre = new Genre({ name: req.body.name });

    if (!errors.isEmpty()) {
      // There are errors. Render the form again with sanitized values/error messages.
      res.render("genre_form", {
        title: "Create Genre",
        genre: genre,
        errors: errors.array(),
      });

      return;
    } else {
      // Data from form is valid.
      // Check if Genre with same name already exists.
      const genreExists = await Genre.findOne({ name: req.body.name })
        .collation({ locale: "en", strength: 2 })
        .exec();
      if (genreExists) {
        // Genre exists, redirect to its detail page.
        res.redirect(genreExists.url);
      } else {
        await genre.save();
        // New genre saved. Redirect to genre detail page.
        res.redirect(genre.url);
      }
    }
  }),
];

Here is the view that it corresponds to:

extends layout

block content

  h1 #{title}

  form(method="POST")
    div.form-group
      label(for="name") Genre:
      input#name.form-control(type="text", placeholder="Fantasy, Poetry etc." name="name" required value=(undefined===genre ? "" : genre.name) )
    button.btn.btn-primary(type="submit") Submit

  if errors
    ul
      for error in errors
        li!= error.msg

Looking at the bottom of the tutorial, it shows you what is supposed to happen when the user tries to send an invalid form: it should create a list element that appears below the form field detailing the error. However, here’s what happens when I try to reproduce the error in my own localhost:enter image description here

For some reason, Express seems to be taking over the error handling and generating it’s own error page. Does anyone know how to fix this issue?

I compared my controller and template code with the finished repo’s code, and it seems to be exactly the same.

Redux state updating causing unwanted rerendering of component

I have an application where i fetch a list of users and display them as a list initially. I also have a search where you can search for a single user and it makes an api call and fetches the single user and displays it. You can also click on a any user item in the list and it should open up a modal to show some extra details about the user onclick of modal i am again making an api call for fetching single user same as search. Problem is when the singleUser is updated in redux both the List component where the signle user is displayed on search and the component containing modal is updated causing a rerender and modal closing. Should i keep a separate state for the user fetched on click of modal and search or is there another way to do it?

userSlice.js
import {createSlice, createAsyncThunk} from '@reduxjs/toolkit';
import { getData } from '../../service';

const initialState={
    users:[],
    singleUser:{},
    loading:false,
    error:{},
    isModalUser:false
}

export const fetchUserData=createAsyncThunk(
    'users/fetchUsers',
    async (endpoint)=>{
        const res= await getData(endpoint);
        return res.data
    }
)

export const fetchUser=(endpoint)=>fetchUserData(endpoint);
export const fetchSingleUser=(endpoint)=>fetchUserData(endpoint);

const usersSlice=createSlice({
    name:'users',
    initialState,
    reducers:{
        resetSingleUser:(state)=>{
            state.singleUser={}
        },
        setModalUser:(state,action)=>{
            state.isModalUser=action.payload;
        }
    },
    extraReducers:(builder)=>{
        builder.addCase(fetchUserData.fulfilled,(state,action)=>{
            if(Array.isArray(action.payload))
                state.users=action.payload
            else
                state.singleUser=action.payload

                state.loading=false
                state.error={}
        })
        .addCase(fetchUserData.pending,(state,action)=>{
           if(action.meta.arg==='users')
            state.users=[]
           
            state.singleUser={}
            state.loading=true;
        })
        .addCase(fetchUserData.rejected,(state,action)=>{
            if(action.meta.arg==='users')
                state.users=[]
            else
                state.singleUser={}

            state.loading=false;
            state.error=action.payload
        });
        
    }
})


export const {getAllUsers,getSingleUser,resetSingleUser,setModalUser}=usersSlice.actions
export const selectAllUsers=(state)=>state.users.users;
export const selectUser=(state)=>state.users.singleUser;
export const loadingState=(state)=>state.users.loading;
export const errorState=(state)=>state.users.error;
export const isModalUserState=(state)=>state.users.isModalUser;
export default usersSlice.reducer
List.jsx
import React, { useEffect } from 'react'
import {useSelector, useDispatch} from 'react-redux'
import { selectAllUsers, selectUser,loadingState, isModalUserState } from './usersSlice'
import { fetchUser } from './usersSlice';

import User from '../User/User';

export default function List() {
   
    const users=useSelector(selectAllUsers);
    const singleUser=useSelector(selectUser)
    const loading=useSelector(loadingState)
    const isModalUser=useSelector(isModalUserState)
    const dispatch=useDispatch()
    
    useEffect(()=>{
        dispatch(fetchUser('users'))
    },[])

    console.log(users,singleUser)

  return (
    <>
        {loading && <div className='container'>Loading ...</div>}
        {!isModalUser && singleUser?.login && <User name={singleUser.login} githubUrl={singleUser.url} pic={singleUser.avatar_url}/>}
        {!singleUser?.login && users.length>0 && users.map((user)=>(
            <User key={user.url} name={user.login} githubUrl={user.url} pic={user.avatar_url}/>
        ))}
        
    </>
  )
}
User.jsx
import React ,{ useState } from 'react';
import UserDetail from './UserDetail';
import { useDispatch, useSelector } from 'react-redux';
import { fetchSingleUser,selectUser,resetSingleUser,setModalUser } from '../List/usersSlice';
import ReactModal from 'react-modal';

export default function User({pic,name,githubUrl}) {
  const [isModalOpen,setIsModalOpen]=useState(false);
  const dispatch=useDispatch();

  const user=useSelector(selectUser);

  const handleModalOpen=()=>{
      console.log('open')
      dispatch(fetchSingleUser(`users/${name}`))
      dispatch(setModalUser(true))
      setIsModalOpen(!isModalOpen)
    }

    const handleModalClose=()=>{
      console.log('closed')
      setIsModalOpen(!isModalOpen)
      dispatch(setModalUser(false))
      dispatch(resetSingleUser())
    }

  return (
    <>
      <div onClick={handleModalOpen}>
        <UserDetail img={pic} name={name} githubUrl={githubUrl}/>
      </div>
      <ReactModal isOpen={isModalOpen} onRequestClose={handleModalClose} style={{overlay:{backgroundColor: 'rgba(0, 0, 0, 0.8)'},content:{margin:'5rem auto',height:'15rem'}}}>
        <UserDetail img={pic} name={name} githubUrl={githubUrl} followers={user.followers} following={user.following}/>
      </ReactModal>
    </>
  )
}
Search.jsx
import React, { useEffect, useState } from 'react'
import { useDispatch} from 'react-redux';
import { fetchSingleUser } from '../List/usersSlice';

export default function Search() {
    const [searchInput,setSearchInput]=useState('');

    const dispatch=useDispatch();

    const handleSearchInput=(e)=>{
        setSearchInput(e.target.value)
    }

    useEffect(()=>{
        const id=setTimeout(()=>{
            dispatch(fetchSingleUser(`users/${searchInput}`))
        },1000)

        return()=>clearTimeout(id)
        
    },[searchInput])

  return (
    <div className='container search-container'>
        <label className='search-container-label'>Search: <input className='search-container-input' name='Search' onChange={handleSearchInput}/></label>
    </div>
  )
}