How do I generate new text when clicking a button in html/javascript?

I am trying to create a button where every time you click, a new sentence generates from a list. What I have now is only generating a new sentence when I refresh the page and I’m not sure what to try. I only started learning yesterday so be nice to me please.

Here is what I have so far.

<div>
    <button onclick="button" id="myButton">Hit me.</button>
    <p id="randomQuote"> </p>
</div>

<script>

    var quote = ["S1","S2","S3","S4",  ];

    var randomQuote = Math.floor(Math.random() * quote.length);
    document.getElementById("randomQuote").innerHTML = quote[randomQuote];

</script> 

How to disable ng build linting on certain directory?

I have this directory that was part of the template, and I want to exclude it on linting. I already excluded it on tsconfig and eslint. runnig eslint it works fine, but when doing ng build it will include the directory on linting and will produce errors.

The subject directory is src/fuse.

I already added this to my config.

eslintignore

build/
dist/
www/
src/@fuse/

eslintrc

    "ignorePatterns": [
        "src/@fuse/**/*",
        "./src/@fuse/**/*",
        "src/@fuse",
        "./src/@fuse"
    ],

tsconfig

    "exclude": ["./src/@fuse", "src/@fuse"]

When doing ng build I will get this. It still apply the linting even it was excluded
enter image description here

Html will not scroll when widow is floating/smaller than content

My page seems OK when it’s maximized, and everything is visible, but when i un-maximize to a floating window that cuts off any of the content, I can’t scroll. You can’t see the overflow content unless you maximize again.
Here is the isolated page: text

I looked at the other posts related and they don’t seem to apply to my specific scenario.
There are so many files that contain the same variables I wouldn’t know which one to change anyway.

Firebase cloud function to respond within 3 seconds but continue running

I have a Streamchat webhook that triggers a Firebase Cloud Function everytime a chat is sent. The webhook expects a response within 3 seconds but my logic takes longer than that to run. How can I make my cloud function close the webhook within the 3 seconds and continue running? The function is also taking a long time to actually send the response message to the chat.

export const chatBot = onRequest(
  { timeoutSeconds: 15, region: ["europe-west2"], maxInstances: 5 },
  async (request, response) => {
    try {
      if (request.body.user.id !== "system-user") {
        //I thought this would close the webhook before continuing to run the function
        response.status(200);
        const client = StreamChat.getInstance("abc", "abc123");
        const signature = request.headers["x-signature"] as string;
        const valid = client.verifyWebhook(request.rawBody, signature);
        if (!valid) {
          return;
        } else {
          const channel = client.channel(
            request?.body?.channel?.type,
            request?.body?.channel?.id
          );
          const messageHistory = new FirestoreChatMessageHistory({
            collections: ["users", "chats"],
            docs: [request.body.user.id, request.body.channel.name],
            sessionId: request.body.user.id,
            userId: request.body.user.id,
            config: {
              projectId: "xyz",
              credential: admin.credential.cert({
                projectId: "xyz",
                privateKey:
                  "-----BEGIN PRIVATE KEY----------END PRIVATE KEY-----n",
                clientEmail: "[email protected]",
              }),
            },
          });

          const llm = new ChatOpenAI({
            modelName: "gpt-3.5-turbo-1106",
            temperature: 0,
            openAIApiKey: "abc123",
          });

          const prompt = ChatPromptTemplate.fromMessages([
            ["system", "You are a helpful assistant"],
            new MessagesPlaceholder("chat_history"),
            ["user", "{input}"],
            new MessagesPlaceholder("agent_scratchpad"),
          ]);

          const tools = [
            new DynamicTool({
              name: "date-time",
              description:
                "Call this to get the date and time right now. Input should be an empty string.",
              func: async () => new Date(Date.now()).toString(),
            }),
          ];

          const agent = await createOpenAIToolsAgent({
            llm,
            tools,
            prompt,
          });

          const agentExecutor = new AgentExecutor({
            agent,
            tools,
          });

          const conversationalAgentExecutor = new RunnableWithMessageHistory({
            runnable: agentExecutor,
            getMessageHistory: (_sessionId) => messageHistory,
            inputMessagesKey: "input",
            outputMessagesKey: "output",
            historyMessagesKey: "chat_history",
          });

          const chatBotRes = await conversationalAgentExecutor.invoke(
            {
              input: request.body.message.text,
            },
            {
              configurable: {
                sessionId: request?.body?.user?.id,
              },
            }
          );
          await channel.sendMessage({
            user_id: "system-user",
            text: chatBotRes.output,
          });
        }
      }
      response.status(200).end();
      return;
    } catch (err) {
      logger.info(err);
      response.status(200).end();
      return;
    }
  }
);

Is there something wrong? I keep getting an axios timeout error. Despite the timeout error, it still works but I don’t know if it causes any performance issues or if this is why it’s taking so long for the message to be sent back. The chatbot response takes about 3 minutes to be sent to the chat. Thank you for your help!

call procedure with parameter from Html template in TMS WEB CORE

I have a simple project in tms web core.
I want to create a series of buttons at runtime in a loop through THTMLWEBDIV and call the Delphi function based on the loop index of each button.
I have a function on the Delphi side that takes input and sends shomessage.
My problem is that I don’t know how to call a function with a parameter from the template side

my unit Code:

unit Unit1;

interface

uses
  System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
  WEBLib.Forms, WEBLib.Dialogs, Vcl.Controls, WEBLib.WebCtrls;

type
  TForm1 = class(TWebForm)
    WebHTMLDiv1: TWebHTMLDiv;
    procedure WebFormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure myFunc(ACode: string);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
{ TForm1 }

procedure TForm1.myFunc(ACode: string);
begin
  ShowMessage(ACode);
end;

procedure TForm1.WebFormShow(Sender: TObject);
var
  i: integer;
begin
  WebHTMLDiv1.HTML.Text := '';
  for i := 1 to 5 do
    WebHTMLDiv1.HTML.Text := WebHTMLDiv1.HTML.Text +
      '<button type="button" onclick="myFunc(' + i.ToString +
      ')" class="btn btn-primary btn-sm">BtnNum' + i.ToString + '</button>';
end;

end.

my html template

<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title>TMS Web Project</title>
    <style>
    </style>
  </head>
  <body>
  <div id = "htmlDiv">
  </div>
  </body>
</html>

How to work with github action in Cypress?

I have url likes dev, stagging and prod I want to run each url for same code.

I have created .github and workflow.
the with: directive we are telling Cypress to:

project: Look for Cypress and our tests inside of the site/ directory.
browser: run our tests inside of the chrome browser.
build: run the build script in the package.json in the root of the repo which builds the production version of our Next.js application.
start: run the start script in the package.json in the root of the repo which serves the production build of our application with a local dev server.
wait-on: tells Cypress to make sure that http://localhost:3000 is up and running before it runs our tests.
You can find the documentation for this action here.
project: Look for Cypress and our tests inside of the site/ directory.
browser: run our tests inside of the chrome browser.
build: run the build script in the package.json in the root of the repo which builds the production version of our Next.js application.
start: run the start script in the package.json in the root of the repo which serves the production build of our application with a local dev server.
wait-on: tells Cypress to make sure that http://localhost:3000 is up and running before it runs our tests.
You can find the documentation for this action here.

How can I automate a script in Google Sheets?

I found a script about summarizing cells’ value based on their colors, but it has an error.

The mentioned script is here in the answers:
Get the sum of values based on their background color – Google Sheets how can I automate this functions?

It works and very useful. But if I change the color of the cell to the proper one, the total value doesn’t change.

I added this function to Macros, but when I Run it, an error message comes up:
Exception: Argument cannot be null: a1Notation

How can I fix it?

I would like automate it. For example: I would like to summerize all of the green cells. I have now 10 green cells and the function is in the Total cells, it shows the result perfectly. But when I make another cell to green, the Total number doesnt change.

Function: =totalColor(“A1:A20”, “green”)
The cells from A1 to A10 are green. But when I make the cell A11 to green, the Total number doesnt change. Thats why I want to automate it.

How to get selected value from select list by javascript in asp.net c#

As per my question, I didn’t get selected value (it showing null value only) when select the list from select dropdownlist.

Following is the .aspx code

<select id="cmb_year" runat="server" onselect="loadCounties()"></select>
<script>
    $('#<%=cmb_year.ClientID%>').editableSelect()
</script>
 <asp:Label ID="lbl_id" runat="server" Text="demo"  ></asp:Label>

 <script>
    function loadCounties() {
        selectElement = document.querySelector('#cmb_year');
        output = selectElement.value;
        document.querySelector('#lbl_id').textContent = output;
        alert(output);
    }
</script>

Here is the aspx.cs code

service.BindHTMLDropdownList(cmb_year, "tbl_year", "year", "Id", "order by Id desc");

I tried many things but didn’t work correctly. Above code is my latest try.

Using node-webkit “npm start” is not calling the script from my package.json manifest file

When executing npm start in the terminal I am greeted with this error message:

PS C:UsersfinsaOneDriveDocumentsUNIWeb DevelopmentNS_Music_App> npm start

> [email protected] start
> nw src/

(node:6380) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Error: spawn C:UsersfinsaOneDrive`your text`DocumentsUNIWeb DevelopmentNS_Music_Appnwjs-sdk-v0.86.0-win-x64nw.exe ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn C:\Users\finsa\OneDrive\Documents\UNI\Web Development\NS_Music_App\nwjs-sdk-v0.86.0-win-x64\nw.exe',
  path: 'C:\Users\finsa\OneDrive\Documents\UNI\Web Development\NS_Music_App\nwjs-sdk-v0.86.0-win-x64\nw.exe',
  spawnargs: [ 'src/' ]
}
node:internal/process/esm_loader:34
      internalBinding('errors').triggerUncaughtException(
                                ^

Error: spawn C:UsersfinsaOneDriveDocumentsUNIWeb DevelopmentNS_Music_Appnwjs-sdk-v0.86.0-win-x64nw.exe ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn C:\Users\finsa\OneDrive\Documents\UNI\Web Development\NS_Music_App\nwjs-sdk-v0.86.0-win-x64\nw.exe',
  path: 'C:\Users\finsa\OneDrive\Documents\UNI\Web Development\NS_Music_App\nwjs-sdk-v0.86.0-win-x64\nw.exe',
  spawnargs: [ 'src/' ]
}

Node.js v20.12.2

Here is how my project is formatted

./package.json:

{
    "name": "ns_music_app",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
        "start": "nw src/",
        "prod": "nwbuild --platforms win32,win64,osx64,linux32,linux64 --buildDir dist/ src/"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "devDependencies": {
        "nw": "^0.86.0-sdk",
        "nw-builder": "^4.7.1"
    }
}

./src/package.json:

{
    "name": "src",
    "version": "1.0.0",
    "description": "",
    "main": "views/main.html",
    "scripts": {
        "test": "echo "Error: no test specified" && exit 1"
    },
    "window": {
        "title": "NS-Music-App"
    },
    "keywords": [],
    "author": "",
    "license": "ISC"
}

I have tried uninstalling and reinstalling Node.js, node-webkit, and reinitialising package.json files. I have also ensured that ignore-script is configured to false.

I suspect that it has something tp do with the path used to fetch nw.exe as in the error message it returns Web Development\NS_Music_App\nwjs-sdk-v0.86.0-win-x64\nw.exe when the actual file path should be Web Development\NS_Music_App\node_modules\nw\nwjs-sdk-v0.86.0-win-x64\nw.exe. But I’m not sure how to fix this.

Tone.js pattern “Progress” value not progressing from 0 to 1 properly

I’d like to adapt this official example on the Tone.js website to include a vertical line that indicates the current progress of the loop, as opposed to just highlighting the current note. (Think of it like the time indicator, in Audacity, for example).

The Pattern has a property called progress which I wanted to use. I thought that calling loop.progress would effectively give me the percentage (number between 0 and 1) of the loop that was complete at that moment.

I’m calling setInterval(function(){console.log(loop.progress)}, 200) every 200 ms, but the progress that is logged to the console bears no resemblance to the current progress. If anything, it seems to be cycling from 0 to 1 much faster than the true progress of the loop.

Here is the JS Fiddle example: https://jsfiddle.net/0og17qnw/9/
Can anyone identify what’s going wrong with this approach and how to get it to log the actual progress of the loop?

Thank you

Emmet functionality Not working In VS Code using .Jsx file

I tried searching and going through some issues opened by others on GitHub but none worked for me.

So what’s the problem:

I am attaching ss :
Text Image

wrap extension

After that when I hit enter nothing happened before a space was generated where I write the tag name: div, p, span

this is the configuration of emmet in my VS
emmet setting

I also tried the same method in which we save the file and then try. No result.

So, after trying different methods nothing works now.. though it was working before and I don’t remember when.

EDIT: it’s not working in Home.jsx but working fine in other components

How do I play audio on JavaScript?

I made a NodeJS application that scrubs a URL and notifies me about any changes. I need it to play an audio file but I don’t know how to do that.
I’ve watched a lot of videos and read a lot of forums, they all talk about how to play an audio on an HTML webpage but I’ve found nothing about playing audio on a standalone JS application.
Any ideas would be much appreciated, thanks.

I have tried the npm, Howler, and Audic, none worked. the play-sound keeps returning error 1 and I’m not sure how to fix that. the Audic package doesn’t let me import the module itself into my file, and Howler just doesn’t play any audio, doesn’t even return an error code.

Unable to run yarn clasp login

Unable to run yarn clasp login

I am not good at English.
Please understand.

8> yarn clasp login        
yarn run v1.22.22
$ C:UsersmynameDesktop個人開発プロジェクトclasp-240418node_modules.binclasp login

Error retrieving access token: FetchError: request to https://oauth2.googleapis.com/token failed, reason: unable to verify the first certificate
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

**I thought node.js does not recognize self certificates such as SSL/TLS communication. So I used openssl to generate the key. I made node.js recognize it as an environment variable, but it didn’t solve the problem. In addition, I have installed an anti-virus software “ESET”, which may be the reason.
**

・Yarn is 1.2 series or higher
・node v20.11.1

Could someone please answer this question?

JavaScript event doesn’t get attached

I have downloaded a bootstrap theme from https://startbootstrap.com/ and integrated it into ASP.NET MVC web project. The dropdown event doesn’t get attached in the following HTML code:

    <li class="nav-item">
            <a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#collapsePages"
               aria-expanded="true" aria-controls="collapsePages">
                <i class="fas fa-fw fa-chart-area"></i>
                <span>Trades</span>
            </a>
            <div id="collapsePages" class="collapse" aria-labelledby="headingPages" data-parent="#accordionSidebar">
                <div class="bg-white py-2 collapse-inner rounded">
                    <a class="collapse-item" href="#">Trades</a>
                    <a class="collapse-item" asp-controller="PaperTrades" asp-action="Index">Paper Trades</a>
                    <a class="collapse-item" href="#">Research</a>
                    <a class="collapse-item" href="#">Journal</a>
                </div>
            </div>
     </li>

And I have included the necessary scripts:

    <!-- Bootstrap core JavaScript-->
        <script src="vendor/jquery/jquery.min.js"></script>
        <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
    
        <!-- Core plugin JavaScript-->
        <script src="vendor/jquery-easing/jquery.easing.min.js"></script>
    
        <!-- Custom scripts for all pages-->
        <script src="js/sb-admin-2.min.js"></script>
    
        <!-- Page level plugins -->
        <script src="vendor/chart.js/Chart.min.js"></script>
    
        <!-- Page level custom scripts -->
        <script src="js/demo/chart-area-demo.js"></script>
        <script src="js/demo/chart-pie-demo.js"></script>

The same HTML structure and scripts are used in the default theme and it works there. The scripts are successfully loaded. Where could the problem be?