How to use local storage save the date input after refreshing

I set date input and get the date countdowns here. but after loading, the date will be back to default state. How to keep the date I choose and save the countdown days?
[i want to keep it like this after loading the page](https://i.sstatic.net/7WscMHeK.png)
these are my html.

<div class="importantdate">Back to Home:</div>
    <div class="daysleft">
        <input type="date" id="dateSelector">
        <span id="replaceMe">365</span>
    </div>

here’s my js:

// Countdown starts here
document.getElementById("dateSelector").addEventListener("change", function(){
    var input= this.value;
    var home = new Date(input);
;
// GET TODAY'S DATE
let today = new Date();
// CONVERT TO NUMERICAL REPRESENTATION (getTime())
let homeTime = home.getTime();
console.log(homeTime);
let currentTime = today.getTime();
console.log(currentTime);
// SCALE DOWN TO DAYS
let msLeft = homeTime - currentTime;
console.log(msLeft);
let secondsLeft = msLeft / 1000;
let minutesLeft = secondsLeft / 60;
let hoursLeft = minutesLeft / 60;
let daysLeft = hoursLeft / 24;

let element = document.getElementById("replaceMe");
element.innerHTML = Math.ceil(daysLeft)});

I want the input date keep what I selected after refreshing the page.

How to add Sentry breadcrumbs to Sentry transaction for Node.js?

I need a some help with Sentry for Node.js.
I’m trying to use breadcrumbs to integrate with Sentry. For errors everything is working fine, I can see breadcrumbs on the event page. But for transactions they are not included in the event for some reason.

It’s my code:

import * as Sentry from '@sentry/node';
import { nodeProfilingIntegration } from '@sentry/profiling-node';
import express from "express";

const app = express();

Sentry.init({
  dsn: '***',
  integrations: [
    new Sentry.Integrations.Http({ tracing: true }),
    new Sentry.Integrations.Express({ app }),
    nodeProfilingIntegration(),
  ],
  tracesSampleRate: 1.0,
  profilesSampleRate: 1.0,
});

app.use(Sentry.Handlers.requestHandler());

app.use(Sentry.Handlers.tracingHandler());

// I CAN'T see this breadcrumb on Event's page in Sentry UI! 
app.get("/broken-breadcrumb", function rootHandler(req, res) {
  const message = 'Hello word of breadcrumbs!';
  console.log(message);
  Sentry.addBreadcrumb({ message });
  res.end("Hello world!");
});

// I see this breadcrumb on Event's page as expected.
app.get("/debug-sentry", function mainHandler(req, res) {
  const message = 'It's a breadcrumb for exception!';
  console.log(message);
  Sentry.addBreadcrumb({ message });
  throw new Error("My first Sentry error!");
});

app.use(Sentry.Handlers.errorHandler());

app.use(function onError(err, req, res, next) {
  res.statusCode = 500;
  res.end(res.sentry + "n");
});

app.listen(3000);

Node.js version: 20.0.5

@sentry/node and @sentry/profiling-node version: 7.112.2

Thank you so much in advance for any help!

Is it possible to disable Sorting an Transform on useStortable Items once they are disabled in dnd-kit?

I’ve been struggling with dnd-kit for a number of days now and although it seems like this would be easy I can’t figure out how to achieve what I need.

Basically I’m using a useSortable hook for each item in a sortable list inside of the and then components.

As the application runs, items in the list become disabled, when the state changes and we re-render the list using the disabled property of the hook useSortable({id: rowNumber, disabled: disableDnD});

As the app run the list starts to look like this with each item that is been disabled, truns grey.

useSortable({id: rowNumber, disabled: disableDnD});

The problem is that the items which are still active and (and the user should be able to reorder) can be moved in the list over any already disabled item. But the idea is that once the top part of the list is grey out you should not be able to sort or move items into it.

I’ve been racking my head trying to figure out how to make this possible.}

enter image description here

How to close chrome driver instances in javascript

After running the regression scripts the driver instances get stacked causing memory problems and slowing down the execution. Can anyone please tell me how to close the browser driver instances after the execution in javascript.

Tried manually closing the chrome driver instances from the task manager

Require assistance in implementing a real-time voice conversation system using a voice chatbot API, which includes audio encoding and decoding

I’m developing an AI voice conversation application for the client side, utilizing the Play.ai WebSocket API. The documentation is available here.

I completed the initial setup following the instructions provided, and the WebSocket connection was established successfully.

The system transmits audio input in the form of base64Data,

Which I have successfully decoded, as evidenced by the playback of the initial welcome message.

However, when I attempt to send my audio, I encounter an issue. According to their specifications, the audio must be sent as a single-channel µ-law (mu-law) encoded at 16000Hz and converted into a base64 encoded string.

This is precisely what I am attempting to accomplish with the following code:

function startRecording() {
    navigator.mediaDevices.getUserMedia({ audio: true, video: false })
        .then(stream => {
            mediaRecorder = new MediaRecorder(stream, { mimeType: 'audio/webm;codecs=pcm' });
            mediaRecorder.ondataavailable = handleAudioData;
            mediaRecorder.start(1000); 
        })
        .catch(error => console.error('Error accessing microphone:', error));
}

function handleAudioData(event) {
    if (event.data.size > 0) {
        event.data.arrayBuffer().then(buffer => {
    
            const byteLength = buffer.byteLength - (buffer.byteLength % 2);
            const pcmDataBuffer = new ArrayBuffer(byteLength);
            const view = new Uint8Array(buffer);
            const pcmDataView = new Uint8Array(pcmDataBuffer);
            pcmDataView.set(view.subarray(0, byteLength));
            const pcmData = new Int16Array(pcmDataBuffer);
            
            const muLawData = encodeToMuLaw(pcmData);
            const base64Data = btoa(String.fromCharCode.apply(null, muLawData));
            socket.send(base64Data);
        });
    }
}
function encodeToMuLaw(pcmData) {
    const mu = 255;
    const muLawData = new Uint8Array(pcmData.length / 2);
    for (let i = 0; i < pcmData.length; i++) {
        const s = Math.min(Math.max(-32768, pcmData[i]), 32767);
        const sign = s < 0 ? 0x80 : 0x00;
        const abs = Math.abs(s);
        const exponent = Math.floor(Math.log(abs / 32635 + 1) / Math.log(1 + 1 / 255));
        const mantissa = (abs >> (exponent + 1)) & 0x0f;
        muLawData[i] = ~(sign | (exponent << 4) | mantissa);
    }
    return muLawData;
}

On the proxy side, I am forwarding the request to the API as specified in the documentation:

  function sendAudioData(base64Data) {
    const audioMessage = {
        type: 'audioIn',
        data: base64Data
    };
    playAiSocket.send(JSON.stringify(audioMessage));
    console.log('Sent audio data');
    
}
  ws.on('message', function incoming(message) {
    baseToString = message.toString('base64')
      sendAudioData(baseToString);
  });

The console logs appear to be correct although the chunks that I’m sending appear to be much larger than the chunks I’m reviewing in the welcome message, but I am not receiving any response from the API after the welcome message, not even an error message. The file seems to be transmitting endlessly. Could anyone please assist me in identifying the issue?

I’m expecting assistance in case there are any inaccuracies in my method or if I’m overlooking something.

Webflow – Accessing user details for logged in user

I have a webflow site. Within that I have a page that requires user login to access the page. That is all setup and working fine.

I would now like to be able to reference user information for use via javascript in that page. Information such as Name, Id and Email.

Is there a way to do this?… I cant seem to access these credentials?
Thanks,
Alan

django can not create a filed although i make makemigrations and migrate

hi i have a filed i cannot make it in database although i make makemigrations and migrte this is models.py

     class Display(models.Model) :
      url=models.URLField(unique=True)
     text = models.CharField(max_length=150) 
    
    class  Display_Data(models.Model) :
         displays = models.ManyToManyField(Display,related_name='display_data')  
        users= models.ForeignKey(UserProfile,on_delete=models.CASCADE,default="1")
         choosenum=models.IntegerField()
         puplish_date =models.DateTimeField(default=datetime.now)  
and this is models.py for accounts app 

  `class UserProfile(models.Model):
   user=models.OneToOneField(User,on_delete=models.CASCADE)
   `user_nickname=models.CharField(max_length=150)
    `nikename_url=models.URLField()
   `userphoto =models.ImageField(upload_to='imageprofile/%Y/%m/%d/')
and this is views.py for display app

  def check_url_exists_and_person(url_to_check):

   user_info_array = []

 for i in range(1, 6):
     latest_successful_record = Display_Data.objects.filter(displays__url=url_to_check,
     choosenum=i).order_by('-puplish_date').first()

      if latest_successful_record:
          user_info = {
             'user_nickname': latest_successful_record.users.userprofile.nikename,
             'url': latest_successful_record.users.userpofile.nikename_url
         }
    else:
        user_info = None

        user_info_array.append(user_info)

           return user_info_array

i received a mistake from Django
` ‘Unknown column ‘display_display_data.users_id’ in ‘field list'”)
and this is form traceback

D:githubfaithsearchdisplayviews.py, line 104, in display_video
Darry=check_url_exists_and_date(embed_url) …

▶ Local vars
D:githubfaithsearchdisplayviews.py, line 68, in check_url_exists_and_date
latest_successful_record = Display_Data.objects.filter(displays__url=url_to_check, choosenum=i).order_by(‘-puplish_date’).first()

why database have not a filed user_id although i make it in models.py i make a new database and delete files of migrations in application display and app userprofile and the filed is not create

django a filed can not make it althougfh i make makemigrations and migrate

hi i have a filed i cannot make it in database although i make makemigrations and migrte this is models.py

     class Display(models.Model) :
      url=models.URLField(unique=True)
     text = models.CharField(max_length=150) 
    
    class  Display_Data(models.Model) :
         displays = models.ManyToManyField(Display,related_name='display_data')  
        users= models.ForeignKey(UserProfile,on_delete=models.CASCADE,default="1")
         choosenum=models.IntegerField()
         puplish_date =models.DateTimeField(default=datetime.now)  
and this is models.py for accounts app 

  `class UserProfile(models.Model):
   user=models.OneToOneField(User,on_delete=models.CASCADE)
   `user_nickname=models.CharField(max_length=150)
    `nikename_url=models.URLField()
   `userphoto =models.ImageField(upload_to='imageprofile/%Y/%m/%d/')
and this is views.py for display app

  def check_url_exists_and_person(url_to_check):

   user_info_array = []

 for i in range(1, 6):
     latest_successful_record = Display_Data.objects.filter(displays__url=url_to_check,
     choosenum=i).order_by('-puplish_date').first()

      if latest_successful_record:
          user_info = {
             'user_nickname': latest_successful_record.users.userprofile.nikename,
             'url': latest_successful_record.users.userpofile.nikename_url
         }
    else:
        user_info = None

        user_info_array.append(user_info)

           return user_info_array

i received a mistake from Django
'Unknown column 'display_display_data.users_id' in 'field list'")

why database have not a filed user_id although i make it in models.py i make a new database and delete files of migrations in application display and app userprofile and the filed is not create

Align Spans for an element on a periodic table in HTML

Im trying to create a periodic table in HTML and the spans are overlapping when the are being created. The Image below is what it looks like at the moment

https://cdn.discordapp.com/attachments/1232090741115846696/1232090741430292480/image.png?ex=662cceab&is=662b7d2b&hm=9d2958102782c3f615240ee48d2581aba84a1c8750aab9da3629c4d743b0cf0f&

This is the Javascript that creates the element (The data comes from a JSON file)

function makeGrid(className,table,start,end){
    for(let i = start;i<= end; i++){
        let currentEle = elementsData[i]
        let element = document.createElement("div")
        console.log(currentEle.number + " " +  currentEle.symbol)
        element.className = className
        element.innerHTML = `
        <span class="atomic_number">${currentEle.number}</span>
        <span class="symbol">${currentEle.symbol}</span>
        
        `
        table.appendChild(element)
    }
}

This is the CSS for the Elements

.element{
    width:65px;
    height:65px;
    background:white;
    position:relative;
    justify-content: center;
    align-items: center;
    font-family: 'Poppins',sans-serif;
    border: 1px solid black;
}

.atomic_number {
    position: absolute;
    font-size: 8;
    text-align: center;
    vertical-align: top;
}

.symbol {
    position: absolute;
    font-size: 12;
    text-align: center;
    vertical-align:middle;
}

And then finally, The HTML (Not alot going on here)

<!DOCTYPE html>
<link rel="stylesheet" href="../CSS/PeriodicTableStyle.css">
<body>
    <div class="MainTable"></div>

    <div class="RareEarth"></div>
</body>
<script type="module" src="../Javascript/PeriodicTable.js"></script>[![enter image description here](https://i.sstatic.net/GPbbRmCQ.png)](https://i.sstatic.net/GPbbRmCQ.png)

I tryed changing the Text Alignment and changing the inline to block for spans and that didnt help. Changing them to divs also didnt do anything

Eclipse/WWD is folding Angular imports while I write them

I’m having an annoying problem with Angular imports on Eclipse/WWD. I’m using the lastest version of both Eclipse and WWD.

While I’m editing a change in a module’s imports, the editor folds the imports during typing, forcing me to edit the line in another part of the text and recopying to the imports section.

I already disabled all “Folding” options I can find and the problem continues.
I’ve seen some answers in other posts advising to turn off folding for Java files, but as I’m using a PDT derived version there’s no “Java” section.

Anyone knows how to solve this ?

Where is a video of the problem happening:
https://www.youtube.com/watch?v=Tcnme7ta5kQ

This is my Eclipse installation:
Eclise installation details

Edit

I’ve fould issues/discussions related to this problem, but no solution:

https://github.com/eclipse-wildwebdeveloper/wildwebdeveloper/discussions/1517

https://github.com/eclipse/lsp4e/issues/895

How to add a footer in HTLM to Docx conversion

I have this code where I get an element from my HTML and transform it in docx, but how could I add a footer to it? It should have a left text and the page count on the right. Don’t if this i made using CSS or it’s something i should add to the Head

export const Export2Doc = (element, filename = "") => {
//  _html_ will be replace with custom html
const meta =
    "Mime-Version: 1.0nContent-Base: " +
    location.href +
    'nContent-Type: Multipart/related; boundary="NEXT.ITEM-BOUNDARY";type="text/html"nn--NEXT.ITEM-BOUNDARYnContent-Type: text/html; charset="utf-8"nContent-Location: ' +
    location.href +
    "nn<!DOCTYPE html>n<html>n_html_</html>"
//  _styles_ will be replaced with custome css
const head =
    '<head>n<meta http-equiv="Content-Type" content="text/html; charset=utf-8">n<style>n_styles_n</style>n</head>n'
// img {width:300px; border-radius: 12px;}
const css =
    "<style>" +
    "table {border-collapse: collapse; border-spacing: 0;}  body {font-family:  Arial, Helvetica, sans-serif;}" +
    "</style>"

const { images, changedImages } = prepareImageData(element)

const imgMetaData = prepareImageMetaData(images)

const html = document.getElementById(element).innerHTML

const blob = new Blob(["uFEFF", html], {
    type: "application/msword"
})

const output =
    meta.replace("_html_", head.replace("_styles_", css) + html) +
    imgMetaData

const url =
    "data:application/vnd.ms-word;charset=utf-8," +
    encodeURIComponent(output)

filename = filename ? filename + ".doc" : "document.doc"

const downloadLink = document.createElement("a")

document.body.appendChild(downloadLink)

if (navigator.msSaveOrOpenBlob) {
    navigator.msSaveOrOpenBlob(blob, filename)
} else {
    downloadLink.href = url
    downloadLink.download = filename
    downloadLink.click()
}

document.body.removeChild(downloadLink)
restoreImagesDimensions(changedImages, element)

}

Why divide by the same factor in a loop in factorization?

function Factors(remainder) {
    var factors = [], i;

    for (i = 2; i <= remainder; i++) {
        while ((remainder % i) === 0) {
            factors.push(i);
            remainder /= i;
        }
    }

    return factors;
}

Can we just use if instead of while?

function Factors(remainder) {
    var factors = [], i;

    for (i = 2; i <= remainder; i++) {
        if(remainder%i===0) {
            factors.push(i);
            remainder /= i;
        }
    }

    return factors;
}

Laravel 10 show modal

im trying to show modal by sending the data from controller to view, but the modal is not shown, I don’t know what wrong, can anyone help me?

here is the code:

controller submit:

if ($success) {
                             return view('pages.approval.modal_ap', [
                                'post_ap' => $postap,
                            ]);
                            }

index view:

$('#submit_app').on('click', function(event){
                event.preventDefault();
                        $.ajax({
                            url: "{{ route('submit_approval') }}",
                            type: 'POST',
                            data: formData,
                            processData: false,
                            contentType: false, 
                            success: function(data_submit){
                                console.log(data_submit);
                                if (data_submit== "S") {
                                    console.log("masuk modal");
                                    $('#post_ap').modal('show');

                                    $('#post_ap .btn-primary').on('click', function () {
                                        $('#post_ap').modal('hide');
                                        setTimeout(function () {
                                            location.reload();
                                        }, 1000);
                                    });
                                }

modal view:

        <div class="modal fade" tabindex="-1" id="post_ap">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h3 class="modal-title">Success</h3>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-sm-6 col-md-6 col-lg-6">
                                <div class="row mb-3">
                                    <div class="col-lg-4">Document Number</div>
                                    <div class="col-lg-8"><b>{{ $post_ap['tes'][0]->a }}</b></div> <!-- Akses dengan -> -->
                                </div>

                                <div class="row">
                                    <div class="col-lg-4">Document Date</div>
                                    <div class="col-lg-8"><b>{{ date('d.m.Y', strtotime($post_ap['tes'][0]->b)) }}</b></div> <!-- Akses dengan -> -->
                                </div>

                                <div class="row mb-3">
                                    <div class="col-lg-4">Reference</div>
                                    <div class="col-lg-8"><b>{{ $post_ap['tes'][0]->c }}</b></div> <!-- Akses dengan -> -->
                                </div>

                                <div class="row mb-3">
                                    <div class="col-lg-4">Currency</div>
                                    <div class="col-lg-8"><b>{{ $post_ap['tes'][0]->d }}</b></div> <!-- Akses dengan -> -->
                                </div>

                                <div class="col-sm-6 col-md-6 col-lg-6">
                                    <div class="row mb-3">
                                        <div class="col-lg-4">Company Code</div>
                                        <div class="col-lg-8"><b>{{ $post_ap['tes'][0]->e }}</b></div> <!-- Akses dengan -> -->
                                    </div>

                                    <div class="row mb-3">
                                        <div class="col-lg-4">Posting Date</div>
                                        <div class="col-lg-8"><b>{{ date('d.m.Y', strtotime($post_ap['tes'][0]->f)) }}</b></div> <!-- Akses dengan -> -->
                                    </div>
                                </div>

                                <div class="col-lg-4">
                                    <div class="row">
                                        <div class="col-lg-4">Fiscal Year</div>
                                        <div class="col-lg-8"><b>{{ $post_ap['tes'][0]->g }}</b></div> <!-- Akses dengan -> -->
                                    </div>
                                </div>

                        </div>
                        <br>
                        <div class="row">
                            <div class="col-lg-12 table-responsive">
                                <table class="table table-bordered">
                                    <thead>
                                        <tr>
                                            <th>No</th>
                                            <th>CoCd</th>
                                            <th>PK</th>
                                            <th>TX</th>
                                            <th>Account</th>
                                            <th>Description</th>
                                            <th>Amount</th>
                                            <th>Curr</th>
                                            <th>Profit Ctr</th>
                                            <th>Segment</th>
                                            <th>Text</th>
                                            <th>Assignment</th>
                                            <th>Cost Ctr</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                      @foreach($post_ap['a'] as $index => $t)
                                      @php
                                        $acc = '';
                                        $desc = ''; 

                                        if (trim($t->LIFNR) == '') {
                                            $acc = trim($t->z);
                                            foreach ($post_ap['t_skat'] as $skat) {
                                                if (trim($skat->s) == 'E' && trim($skat->h) == 'DPCA' && trim($skat->f) == $acc) {
                                                    $desc = trim($skat->u); 
                                                    break; 
                                                }
                                            }
                                        } else {
                                            $acc = trim($t->l); 
                                            foreach ($post_ap['t_lfa1'] as $lfa1) {
                                                if (trim($lfa1->q) == $acc) {
                                                    $desc = trim($lfa1->g); 
                                                    break; 
                                                }
                                            }
                                        }
                                        @endphp

                                        <tr>
                                            <td>{{ ltrim($t->b, '0') }}</td>
                                            <td>{{ $t->b }}</td>
                                            <td>{{ $t->b }}</td>
                                            <td>{{ $t->b }}</td>
                                            <td>{{ trim($acc, '0') }}</td>
                                            <td>{{ $desc }}</td>
                                            <td>
                                                @if (trim($t->b) == 'H')
                                                    -
                                                @else
                                                    @if ($t->b == 'DNPA')
                                                        {{ number_format($t->b, 2, '.', ',') }}
                                                    @else
                                                        {{ number_format($t->b * 100, 0, '.', ',') }}
                                                    @endif
                                                @endif
                                            </td>
                                            <td>{{ $t->b }}</td>
                                            <td>{{ ltrim($t->b, '0') }}</td>
                                            <td>{{ $t->b }}</td>
                                            <td>{{ $t->b }}</td>
                                            <td>{{ $t->b }}</td>
                                            <td>{{ ltrim($t->b, '0') }}</td>
                                        </tr>
                                        @endforeach
                                    </tbody>
                                </table>
                            </div>
                        </div>
                </div>
                {{-- @endif --}}

                <div class="modal-footer">
                    <button type="button" class="btn btn-primary">OK</button>
                </div>
            </div>
        </div>
    </div>

the console.log(“masuk modal”) is call but the modal is not show

console log

I already try to call modal with just empty html and it works
enter image description here

and I also try to console log the modal

 console.log("masuk modal");
                                    console.log($('#post_ap').modal('show'));

and it send this

enter image description here

can anyone help me, I don’t know whats wrong

Typescript string index in foreach loop

I am building a tool to check statuses on the network. The environment file has a bunch of addresses to various items, like VMs, DBs, etc. The type of the env looks like this:

export type EnvDefinition = {
  'DetailedErrors': boolean,
  'Logging': LogDefinition,
  'SystemElementGroups': {
    'VMs': SystemElement[],
    'Applications': SystemElement[],
    'Databases': SystemElement[],
  },
}

SytemElement is just another type that defines the IP address and whatever else is needed.

When I load the env data from the json file, I cast it like this:

import envData from '../development.json';
const data: EnvDefinition = envData;

Then I try to access the individual group data like this:

const assetTypes = ['VMs', 'Applications', 'Databases'];
for (const assetType of assetTypes) {
    const connectStrings = data.SystemElementGroups[assetType];

No matter what I try I keep getting a TS error: TS7053: Element implicitly has an any type because expression of type string can't be used to index type

How can I define this so I can access the SystemElementGroups in a loop?

Thanks