Bootstrap 5 – Carousel is not working correctly please suggest me some reason [closed]

https://test.opendata-oepnv.de/ht/de/willkommen
the carousel is not working as expected hier please can someone tell me some reason can cause this issue
i checked the bootstrap classes and they are all up to date

https://test.opendata-oepnv.de/ht/de/willkommen
the carousel is not working as expected hier please can someone tell me some reason can cause this issue
i checked the bootstrap classes and they are all up to date

How I can change object by Id in nested array with childrens, and update state in React

How can i toggle isExpanded property on onClick by Id. I’m using React for this project.
Here is my json data structure.

const handleExpandOutlineItem = (id: string) => {}

here is my json data structure.

  {
    id: '1',
    title: 'Introduction to Programming',
    isExpanded: true,
    children: [
      {
        id: '1.1',
        title: 'What is programming?',
        isExpanded: false,
        children: [
          {
            id: '1.1.1',
            title: 'What is programming?',
            isExpanded: false,
            children: [],
          },
          {
            id: '1.1.2',
            title: 'What is programming?',
            isExpanded: false,
            children: [],
          },
        ],
      },
      {
        id: '1.2',
        title: 'Programming languages',
        isExpanded: false,
        children: [
          {
            id: '1.2.1',
            title: 'Programming languages',
            isExpanded: false,
            children: [],
          },
          {
            id: '1.2.2',
            title: 'Programming languages',
            isExpanded: false,
            children: [],
          },
        ],
      },
    ],
  },
]```

I trie to use recursion, but I should also update state

How to mock module which got through webpack

I am trying to mock module using JASMINE in angular but we are unable to mock it.

Below is code we are using use the module in MainComponent.ts

“””
const authAppService = () => import(“authApp/auth”).then((m) => m.authService);const storeAppService = () => import(“storeApp/store”).then((m) => m.storeService);
“””

“””
import * as authAppService from ‘authApp/auth’;

beforeAll(() => {    mockParseString = spyOn(authAppService, ‘isAuthenticated’).and.callThrough();  });

“””

Getting the error ” Error: Module not found: Error: Can’t resolve ‘authApp/auth’ ” 

When the unit test cases are executed using the command “npm test”

ProseMirror: How to add an attribute to pasted content?

I want to add an attribute which will be rendered as an HTML attribute to content that was pasted.

I have been trying to implement this using something like the following function:

transformPasted: (slice) => {
    let fragment = slice.content
    fragment.forEach((node, _, index) => {
        fragment = fragment.replaceChild(
            index,
            schema.node(
                node.type,
                {
                    ...node.attrs,
                    pasted: true,
                },
                node.content,
                node.marks,
            ),
        )
    })
    return new Slice(fragment, slice.openStart, slice.openEnd)
},

This does seem to be setting the attribute correctly however it still always displays pasted="false" in the HTML. I haven’t managed to successfully change the HTML attribute to pasted="true".

Any guidance would be appreciated.

window onload not invoking when the page gets loaded [closed]

Not seeing al alert of “let’s go!”

<html>

<head>
  <script type="text/javascript">
    function simple() {
      alert("let's go!");
    }
    window.onload = simple;
    async function getPlatforms() {
      alert "hello"
      const response = await fetch(
        'http://10.64.127.94:5000/api/get_platforms', {
          method: 'GET',
        }
      );
      const data = await response.json();
      alert data
    }

    function selects() {
      var ele = document.getElementsByName('chk');
      for (var i = 0; i < ele.length; i++) {
        if (ele[i].type == 'checkbox')
          ele[i].checked = true;
      }
    }

    function deSelect() {
      var ele = document.getElementsByName('chk');
      for (var i = 0; i < ele.length; i++) {
        if (ele[i].type == 'checkbox')
          ele[i].checked = false;
      }
    }
    <!--        function SubmitForm(formId) {-->
    <!--            var oForm = document.getElementById(formId);-->
    <!--            if (oForm) {-->
    <!--                oForm.submit();-->
    <!--            }-->
    <!--            else {-->
    <!--                alert("DEBUG - could not find element " + formId);-->
    <!--            }-->
    <!--        }-->
  </script>
  <style>
    table,
    th,
    td {
      border: 1px solid black;
      border-collapse: collapse;
    }
  </style>
  <title>Unified Performance Heat Map</title>
</head>

<body>
  <h1 style="text-align: center;">Unified Performance Heat Map</h1>
  <hr>
  <form name="device_form" id="device_form">
    <label>Choose a device:</label>
    <select name="device_select" id="device_select">
    </select>
  </form>
  <br>
  <br>
  <label>Select the label:</label>
  <select name="label_select" id="label_select">
  </select>
  <br>
  <br>
  <label>Select the baseline:</label>
  <select name="label_baseline" id="label_baseline">
  </select>
  <br>
  <br>
  <label>Select the features:</label>
  <br>

  <br>
  <input type="button" onclick='selects()' value="Select All" />
  <input type="button" onclick='deSelect()' value="Deselect All" />

  <br>
  <br>
  <button type="button">Make Heat Map !</button>
  <hr>
  <table style="width:100%">
    <tr>
      <td>FEATURE</td>
      <td colspan="3" style="text-align: center;">IPSEC</td>
    </tr>
    <tr>
      <td>PACKET</td>
      <td>64</td>
      <td>IMIX</td>
      <td>1400</td>
    </tr>
    <tr>
      <td>BASE</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>LABEL</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>HEATMAP</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</body>

</html>

Can’t select language code in web-scraping script (RSelenium, Chrome)

First of all it’s important to know that I received the script I will be talking about, I did not create it myself. In fact, I am very new to R and don’t have any programming background at all. So very simple explanations or direct changes would be extremely appreciated, thank you in advance for your patience!

The script allows you to scrape Goodreads-reviews with RSelenium. I run in in Rstudio on a Windows-computer (not sure whether this is relevant or not). You put in the url of the book in question, the script then opens the Chrome-browser and navigates the url. The script will then scrape the 300 reviews shown. However, Goodreads allows you to filter the reviews per language. The script has a piece of code so you can select which language you want (e.g. only English reviews). For this, you can either enter the language code (‘en’ for English) or the the number of the position of this language in the drop-down menu. This position of the language varies from book to book, as the languages are ordered alphabetically and different books may have reviews in different languages.

My problem is: the language code part of the selector does not work, it only accepts the numeral order. However, it’s very tiring to have to look up the position of a specific language for every single book and to then fill it in. I just want to be able to give in the language code.

This is the full script (just set the output-directory at the end if you wish to run it):

library(rJava)        # Required to use RSelenium
library(data.table)   # Required for rbindlist
library(dplyr)        # Required to use the pipes %>% and some table manipulation commands
library(magrittr)     # Required to use the pipes %>%
library(rvest)        # Required for read_html
library(RSelenium)    # Required for webscraping with javascript
library(lubridate)    # Required to scrape the correct dates
library(stringr)      # Required to cut off any leading or trailing whitespace from text
library(purrr)


options(stringsAsFactors = F) #needed to prevent errors when merging data frames

#Paste the GoodReads Url
url <- "https://www.goodreads.com/book/show/96290.Die_unendliche_Geschichte"

englishOnly = F #If FALSE, all languages are chosen

#Set your browser settings (if chrome not working, pick closest version)
rD <- rsDriver(port = 9516L, browser = "chrome", chromever = "110.0.5481.30")
remDr <- rD[["client"]]
remDr$setTimeout(type = "implicit", 2000)
remDr$navigate(url)

bookTitle = unlist(remDr$getTitle())
finalData = data.frame()

# Main loop going through the website pages
morePages = T
pageNumber =  1
while(morePages){
  
  #Select reviews in correct language
  #Go to the goodreads page of the book in Chrome and right-click.
  #Click on "View Page Source".
  #Look for the language code, it will look like this:
  #<select name="language_code" id="language_code"><option value="">All Languages</option><option value="de">Deutsch &lrm;(9)</option>
  #<option value="en">English &lrm;(9)</option><option value="es">Español &lrm;(1)</option>
  #The numeral language code is the sequence, so here "All Languages" is 1, "Deutsch" is 2, "English" is 3...
  #This sequence is not the same for every book, so check it each time!
  #It is sufficient if you only fill in the numeral language code.
  selectLanguage = if(englishOnly){
    selectLanguage = remDr$findElement("xpath", "//select[@id='language_code']/option[@value='de']")
  } else {
    selectLanguage = remDr$findElement("xpath", "//select[@id='language_code']/option[4]")
  }
  
  selectLanguage$clickElement()
  Sys.sleep(1)
  
  #Expand all reviews
  expandMore <- remDr$findElements("link text", "...more")
  expandMore = sapply(expandMore, function(x) x$clickElement())
  
  #Extracting the reviews from the page
  reviews <- remDr$findElements("css selector", "#bookReviews .stacked")
  reviews.html <- lapply(reviews, function(x){x$getElementAttribute("outerHTML")[[1]]})
  
  #Remove double text when expanded
  reviews.html <- lapply(reviews.html, function(x){
    if(str_count(x, "span id="freeText") > 1) {
      str_remove(x, "<span id="freeTextContainer.*")
    } else {
      x
    }
  })
  
  reviews.list <- lapply(reviews.html, function(x){read_html(x) %>% html_text()} )
  reviews.text <- unlist(reviews.list)
  
  #Some reviews have only rating and no text, so we process them separately
  onlyRating = unlist(map(1:length(reviews.text), function(i) str_detect(reviews.text[i], "^\n\n")))
  
  #Full reviews
  if(sum(!onlyRating) > 0){
    
    filterData = reviews.text[!onlyRating]
    fullReviews = purrr::map_df(seq(1, length(filterData), by=2), function(i){
      review = unlist(strsplit(filterData[i], "n"))
      
      data.frame(
        date = mdy(review[2]), #date
        username = str_trim(review[5]), #user
        rating = str_trim(review[9]), #overall
        comment = str_trim(review[12]) #comment
      )
    })
    
    #Add review text to full reviews
    fullReviews$review = unlist(purrr::map(seq(2, length(filterData), by=2), function(i){
      str_trim(str_remove(filterData[i], "\s*\n\s*\(less\)"))
    }))
    
  } else {
    fullReviews = data.frame()
  }
  
  #partial reviews (only rating)
  if(sum(onlyRating) > 0){
    
    filterData = reviews.text[onlyRating]
    partialReviews = purrr::map_df(1:length(filterData), function(i){
      review = unlist(strsplit(filterData[i], "n"))
      
      data.frame(
        date = mdy(review[9]), #date
        username = str_trim(review[4]), #user
        rating = str_trim(review[8]), #overall
        comment = "",
        review = ""
      )
    })
    
  } else {
    partialReviews = data.frame()
  }
  
  #Get the review ID's from all the links
  reviewId = reviews.html %>% str_extract("/review/show/\d+")
  partialId = reviewId[(length(reviewId) - nrow(partialReviews) + 1):length(reviewId)] %>% 
    str_extract("\d+")
  if(nrow(fullReviews) > 0){
    reviewId = reviewId[1:(length(reviewId) - nrow(partialReviews))]
    reviewId = reviewId[seq(1, length(reviewId), 2)] %>% str_extract("\d+")
  } else {
    reviewId = NULL
  }
  
  if(nrow(partialReviews) > 0){
    reviewId = c(reviewId, partialId)
  }
  
  finalData = rbind(finalData, cbind(reviewId, rbind(fullReviews, partialReviews)))
  
  #Go to next page if possible
  nextPage = remDr$findElements("xpath", "//a[@class='next_page']")
  if(length(nextPage) > 0){
    message(paste("PAGE", pageNumber, "Processed - Going to next"))
    nextPage[[1]]$clickElement()
    pageNumber = pageNumber + 1
    Sys.sleep(2)
  } else {
    message(paste("PAGE", pageNumber, "Processed - Last page"))
    morePages = FALSE
  }
  
}   
#end of the main loop

#Replace missing ratings by 'not rated'
finalData$rating = ifelse(finalData$rating == "", "not rated", finalData$rating)

#Stop server
remDr$close()
rD$server$stop()
rm(rD, remDr)
gc()
system("taskkill /im java.exe /f", intern=FALSE, ignore.stdout=FALSE)

#set directory to where you wish the file to go
#copy your working directory and exchange all backward slashes for forward slashes
getwd()
setwd("")

#Write results
write.csv(finalData, paste0(bookTitle, ".csv"), row.names = F)
message("FINISHED!")

The part I’m talking about is this:

  selectLanguage = if(englishOnly){
    selectLanguage = remDr$findElement("xpath", "//select[@id='language_code']/option[@value='de']")
  } else {
    selectLanguage = remDr$findElement("xpath", "//select[@id='language_code']/option[4]")
  }
  
  selectLanguage$clickElement()
  Sys.sleep(1)

In this case, it only seems to take the “4” into consideration and will completely ignore the “de”. I don’t really need the numeral version, I just want to be able to enter the language code and get going. Would someone be willing to help me?

Because of my lack of experience, I first tried to use chatGPT to come up with a solution, but that went about as well as you’d expect.

I have two buttons in a row, both containing icons, but if one of the icons is larger, the other button gets pushed down despite same height. Why?

I am using Web Components on Stencil.js. I have an icon component, and a button component. I have nested the icon component inside the button component, but I have noticed that, when I have two buttons aligned next to each other, and one of them has an icon a bit larger than the other one, the other button gets pushed down. This is to be expected if the line-height is larger, but in my case, I don’t think that it is.

Button:

<button >
   {this.icon && this.position === 'left' && <ifx-icon icon={this.icon}></ifx-icon>}
   <slot></slot>
   {this.icon && this.position === 'right' && <ifx-icon icon={this.icon}></ifx-icon>}
</button>

Relevant button css:

.btn {
  display: inline-flex; 
  align-items: center;
  min-width: 80px;
  min-height: 40px;
  padding: 0px 16px;
  gap: 8px;
  color: #FFFFFF;
  flex-direction: row;
  font-weight: 600;
  border-radius: 1px;
  line-height: 24px;
  outline: none;
  font-family: tokens.$font-family-body;
  text-decoration: none;
  user-select: none;
  border: 1px solid rgba(0, 0, 0, 0);
  font-size: 1rem;
  transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

Icon component:

 <Host>
    {this.constructIcon()}
 </Host>

Icon component CSS:

ifx-icon { 
  display: inline-flex;
}

HTML:
my button
my button

Result:
Buttons

If both icons are bell-16, both buttons are perfectly alined.
If I removed the inline-flex from the icon component, I get this:
No flex

..obviously because the icon is not aligned in the center inside the icon component, and has larger line-height than the text.
buttons2

Question: What pushes the left button down when the right one has a larger icon? Is it the line-height of the icon svg? If so, can it be prevented?

How to set padding 0 in .inner-288 class using fluentui React

I am trying to set padding 0 of the .inner-288 class using fluentui React.
By default, it’s proving a padding of 24px on the right, left, and bottom. I want to make the padding value 0,

enter image description here

.inner-288 {
  padding: 0px 24px 24px;
}

I am trying to set the root style padding 0 values, but it does not work.

styles={{ root: { padding: 0 } }}

How can I make padding to 0 values?

Vue 3 resolveComponent returns [object Object]

I’m trying to replace a (WordPress) shortcode string that comes from a REST API.
Now I want to replace ‘[faq]’ with a Vue 3 component called ‘FAqItem’.
For this, I use the function resolveComponent().

This is my code:

const html = ref(props.data.text)
const FaqItem = resolveComponent('FaqItem')
if (html.value.includes('[faq]')) {
    html.value = html.value.replace('[faq]', FaqItem);
}

Then in my template I use:

<div class="block prose xl:mt-12" v-html="html"></div>

Now this seems to work, but the replace function is returning [object Object].
How can I make this show my component itself?
It’s important that only the [faq] is replaced.

Thanks in advance!

How to report all thrown errors/exceptions of a certain class?

I have a specific type of errors, which I always want to report with a track system, such as Sentry, or AppInsight. So I created a class inherited from Error, and now I want to call a function every time this error is thrown. I don’t want to do it manually in each and every try-catch clause, not to mention the fact that it’s easy to forget, and other devs can ignore it. How can I do it? Of course, I can put it into the constructor, but calling the side-effect there isn’t a good idea.

In this case, I’m going to report this issue:

class ExhaustiveCheckError extends Error {}

export function exhaustiveCheck(unreachableValue: never): never {
  throw new ExhaustiveCheckError(
    'Should not have reached here. Not all cases are covered'
  );
}

Here it’s used to handle an error when using a switch case/if with data of an unexpected type from IO, for example, from the backend, or user input. I know it’s better to parse/validate data at boundaries with ZOD/Run-types, etc., but now it’s not possible to implement.

What other options do I have?

How to correctly calculate the length of the text, taking into account hyphens and tabs js?

I have the following piece of text, which is perceived by notepad and the back end as 1026 characters long text (because it has a hyphen in it). But the javascript length property defines it as text 1024 characters long, which allows client validation to pass, how can this be fixed?

Example of the text:

London is the capital and largest city of England and the United Kingdom, with a population of just under 9 million.[1] It stands on the River Thames in south-east England at the head of a 50-mile (80 km) estuary down to the North Sea, and has been a major settlement for two millennia.[9] The City of London, its ancient core and financial centre, was founded by the Romans as Londinium and retains its medieval boundaries.[note 1][10] The City of Westminster, to the west of the City of London, has for centuries hosted the national government and parliament. Since the 19th century,[11] the name "London" has also referred to the metropolis around this core, historically split between the counties of Middlesex, Essex, Surrey, Kent, and Hertfordshire,[12] which since 1965 has largely comprised Greater London,[13] which is governed by 33 local authorities and the Greater London Authority.[note 2][14]

As one of the world’s major global cities,[15] London exerts a strong influence on its arts, entertainment, fashion,

Example saved in js variable:

  const text =
  'London is the capital and largest city of England and the United Kingdom, with a population of just under 9 million.[1] It stands on the River Thames in south-east England at the head of a 50-mile (80 km) estuary down to the North Sea, and has been a major settlement for two millennia.[9] The City of London, its ancient core and financial centre, was founded by the Romans as Londinium and retains its medieval boundaries.[note 1][10] The City of Westminster, to the west of the City of London, has for centuries hosted the national government and parliament. Since the 19th century,[11] the name "London" has also referred to the metropolis around this core, historically split between the counties of Middlesex, Essex, Surrey, Kent, and Hertfordshire,[12] which since 1965 has largely comprised Greater London,[13] which is governed by 33 local authorities and the Greater London Authority.[note 2][14]n' +
  'n' +
  "As one of the world's major global cities,[15] London exerts a strong influence on its arts, entertainment, fashion,"


console.log(String(text).length)

ML5.js wrong predict for a basic linear regression

I am a beginner at the neural network. Trying to recreate some basic predict for the formula y = 2x-1 from the tensorflow.js tutorial using ml5.js but something is getting wrong. Here is my code:

const model = ml5.neuralNetwork({
        task: 'regression',
        inputs: ['x'],
        outputs: ['y'],
        debug: true
    });

    const trainingData = [
        {input: {x: -1}, output: {y: -3}},
        {input: {x: 0}, output: {y: -1}},
        {input: {x: 1}, output: {y: 1}},
        {input: {x: 2}, output: {y: 3}},
        {input: {x: 3}, output: {y: 5}},
        {input: {x: 4}, output: {y: 7}}
    ];

    trainingData.forEach(data => {
        model.addData(data.input, data.output);
    });

    model.normalizeData();
    model.train({epochs: 100}, () => {
        console.log('Model trained');

        const inputData = {x: 20};
        model.predict(inputData, (error, result) => {
            if (error) {
                console.error(error);
            } else {
                console.log(`Prediction: ${result[0].value}`);
            }
        });
    });

Expected: 20 => 39,
Actual result: 20 => 6.999997615814209

What am i doing wrong?

How to search in deep nested array?

I am trying to filter/search in a deeply nested array of subarrays
In order to explain my problem it is better to show the array structure first.

const arr = [
  [
    {
      title: "title 1",
      city: [
        {
          "0": "London"
        },
        {
          "1": "LA"
        }
      ]
    },
    {
      title: "Title 2",
      city: [
        {
          "0": "New York"
        },
        {
          "1": "London"
        }
      ]
    }
  ],
  [
    {
      title: "Title 3",
      city: [
        {
          "0": "Paris"
        }
      ]
    },
    {
      title: "title 4",
      city: [
        {
          "0": "London"
        }
      ]
    }
  ]
];

As you see, in this nested Array there is a city array of of key value pair objects and my task is to search value in this city Array and return only first matching object of every subArray without flattening.

So, let’s say the filter keyword is London, I want to return the first matching object of every subArray which inlcudes that filter keyword.
So here answer would be

const filteredArr = [
  [
    {
      title: "title 1",
      city: [
        {
          "0": "London"
        },
        {
          "1": "LA"
        }
      ]
    }
  ],
  [
    {
      title: "title 4",
      city: [
        {
          "0": "London"
        }
      ]
    }
  ]
];

As you can see from first subArray only first object is returned, even though second object which has a title 2 also includes a value of London in city array.

I know that I can get the first matching object with find method like this:

const filteredCity = city.find((obj) => Object.values(obj)[0] === "London");

But how to combine and get the desired array?

I am sorry if couldn’t explain my Problem properly. Let me know if something is not clear.

Any help will be appreciated.

addthis widget for print page is not working for the first page load

I am using addthis widget from addthis.com.
I am using a script tag inside head tag:

        <script
            type="text/javascript"
            src="//s7.addthis.com/js/300/addthis_widget.js#pubid=your_pubid"
            async="async"
        ></script>

Now I just need to add a html with className :

<div className="addthis_inline_share_toolbox_3xd0" />

to get a Print and More options on the page, like given image below :

enter image description here

But the problem is, these two options are not showing for the first time page visit. If I do refresh the page, then these two options will show.
I am not able to find what the issue here ?

Note:

I have tried to move the script tag at the last of the body tag. But not working.
I have tried to use the defer option instead of async in script tag. But not working.