I have created a role and want to give it to the bot. How can I do this? I have the role as var ‘role’. I can’t figure out how to give the bot itself a role, just other members.
Category: javascript
Category Added in a WPeMatico Campaign
Oxford Dictionary API Fetch Request ERROR: Authentication parameters missing
I am trying to access dictionary api from chrome console, but constantly getting this error: Authentication parameters missing status code: 403
My credentials have no issue, coz it works fine in postman.
Documentation for oxford dictionary api : https://developer.oxforddictionaries.com/documentation#!/Entries/get_entries_source_lang_word_id
Following is my fetch request:
var myHeaders = new Headers();
myHeaders.append("app_id", app_id);
myHeaders.append("app_key", app_key);
var requestOptions = {
method: 'GET',
headers: myHeaders,
mode : "no-cors",
redirect: 'follow'
};
fetch("https://od-api.oxforddictionaries.com/api/v2/entries/en-us/persistent?strictMatch=false", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
How to access a property of a Web Component from the DOM?
I’m trying to create a Web Component, and want to be be able to access a property from the DOM.
<!doctype html>
<html lang="en-GB">
<head>
<script type="module">
class TestComponent extends HTMLElement {
constructor() {
super()
.attachShadow({mode: 'open'})
.innerHTML = '<div id="root">Test Component</div>';
}
connectedCallback() {
console.log('super');
this.value = 10;
this.setAttribute('value', '10');
}
set value (newValue) {
console.log('setValue');
this.setAttribute('value', newValue);
}
get value () {
this.getAttribute('value');
}
}
customElements.define('test-component', TestComponent);
</script>
</head>
<body>
<select id="html-select">
<option value="75">HTML Option</option>
</select>
<test-component id="test-component"></test-component>
</body>
<script>
console.log(document.getElementById('html-select').value); // outputs 75
console.log(document.getElementById('test-component').value); // outputs undefined
console.log(document.getElementById('test-component').id); // outputs 'test-component'
setTimeout(() => {
console.log(document.getElementById('test-component').value); // still outputs undefined
}, 1000);
</script>
</html>
The console log for this is:
75
test-component
undefined
super
setValue
undefined
The element attribute is correctly set on inspection, though:
<test-component id="test-component" value="10">
How to split measures into beats and subdivide them, respecting the old notes, in a musical notation app
I have 4 * 8 dots. I want to logs this like this:
// empty() // ................................
I want to divide this into 4 parts and show an “4” every eight dot.
// init() // 4.......4......4.......4.......
I want to divide the first part into two and place a “2” every fourth dot.
// add(0, 2) // 2...2...4......4.......4.......
In other words I placed a “2” at 0th dot which was “4” previously. This lasts for only 4 dots, so the
remaining 4 dots are left with another “2”.
How I think of this is more like placing an “8” at place 4:
// add(4, 8) // 2...8..............2...4.......
So the number at the beginning of dots is measure of how long a dot lasts, and I can place a number anywhere I feel like. But I need to respect the old dots, and put new dots to keep them numbered.
In the last example I had to place an “8” at place 4 so I removed “2” “4” and “4” and replaced it with an “8” and also added a “2” to make up for the remaining space.
Final example we place a “6” at the 6th place.
// add(6, 6) // 2...116..........112...4.......
This overrode “8” and replaced it with “6” and a “2” and a bunch of “1”‘s.
Overall what I want:
/*
// time signature 4/4
// method call // logs
init() // 4.......4......4.......4.......
add(0, 2) // 2...2...4......4.......4.......
add(4, 8) // 2...8..............2...4.......
add(6, 6) // 2...116..........112...4.......
*/
Basically I want an abstraction for putting musical notes and querying them.
I’ve tried two approaches but they are just hardcore messy calculations that didn’t work. I need some neat functional
approach easy to grok and handle.
How do i make a scrolldown to a specific tab content when using javascript:document.querySelector(‘#’).click() after the specific tab is opened
How do i make below hyperlink scroll over to that tab’s content..i’ve used “javascript:document.querySelector(‘#tb’).click()” and tab is opened but u it doenst scroll down over
Here is my source code
This is the css for the tabs and page
body {font-family: Arial;}
.tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
}
.tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
font-size: 17px;
}
.tab button:hover {
background-color: #ddd;
}
.tab button.active {
background-color: #ccc;
}
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
}
Below (3rd line)i used “javascript:document.querySelector(‘#tb’).click()” to open the hyperlinked tab..but how do make it scroll over to that tab’s content
<h2>Tabs</h2>
<p>How do i make a scrolldown to a specific tab content when the hyperlink below is clicked?</p>
<a href="javascript:document.querySelector('#tb').click()">This link will open the tokyo tab..but how do i implement a scroll over?</a>
<br>
<br>
<br>
<img src="D:DocumentsTCOR22000652travel.jpg" alt="Girl in a jacket" width="600" height="500">
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<div class="tab">
<button class="tablinks" onclick="openCity(event, 'London')">London</button>
<button class="tablinks" onclick="openCity(event, 'Paris')">Paris</button>
<button class="tablinks" id="tb" onclick="openCity(event, 'Tokyo')">Tokyo</button>
</div>
<div id="London" class="tabcontent">
<h3>London</h3>
<p>London is the capital city of England.</p>
</div>
<div id="Paris" class="tabcontent">
<h3>Paris</h3>
<p>Paris is the capital of France.</p>
</div>
<div id="Tokyo" class="tabcontent">
<h3>Tokyo</h3>
<p>Tokyo is the capital of Japan.</p>
<img src="D:DocumentsTCOR22000656tokyo.jpg" alt="Girl in a jacket" width="500" height="600">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam rhoncus auctor commodo. Duis condimentum massa mi, vitae finibus nisl cursus ac. Interdum et malesuada fames ac ante ipsum primis in faucibus. In quis ante tortor. Donec quis ornare turpis.
Aliquam dignissim sem diam, at tristique leo blandit non. Vivamus neque nisl, dictum sit amet vulputate ac, congue et massa. Aenean a faucibus tellus, a interdum nisi. Aliquam non nisl sed metus pharetra facilisis. Maecenas eu dictum urna, ornare
pharetra felis. Nunc maximus mauris in sem cursus vehicula.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam rhoncus auctor commodo. Duis condimentum massa mi, vitae finibus nisl cursus ac. Interdum et malesuada fames ac ante ipsum primis in faucibus. In quis ante tortor. Donec quis ornare turpis.
Aliquam dignissim sem diam, at tristique leo blandit non. Vivamus neque nisl, dictum sit amet vulputate ac, congue et massa. Aenean a faucibus tellus, a interdum nisi. Aliquam non nisl sed metus pharetra facilisis. Maecenas eu dictum urna, ornare
pharetra felis. Nunc maximus mauris in sem cursus vehicula.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam rhoncus auctor commodo. Duis condimentum massa mi, vitae finibus nisl cursus ac. Interdum et malesuada fames ac ante ipsum primis in faucibus. In quis ante tortor. Donec quis ornare turpis.
Aliquam dignissim sem diam, at tristique leo blandit non. Vivamus neque nisl, dictum sit amet vulputate ac, congue et massa. Aenean a faucibus tellus, a interdum nisi. Aliquam non nisl sed metus pharetra facilisis. Maecenas eu dictum urna, ornare
pharetra felis. Nunc maximus mauris in sem cursus vehicula.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam rhoncus auctor commodo. Duis condimentum massa mi, vitae finibus nisl cursus ac. Interdum et malesuada fames ac ante ipsum primis in faucibus. In quis ante tortor. Donec quis ornare turpis.
Aliquam dignissim sem diam, at tristique leo blandit non. Vivamus neque nisl, dictum sit amet vulputate ac, congue et massa. Aenean a faucibus tellus, a interdum nisi. Aliquam non nisl sed metus pharetra facilisis. Maecenas eu dictum urna, ornare
pharetra felis. Nunc maximus mauris in sem cursus vehicula.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam rhoncus auctor commodo. Duis condimentum massa mi, vitae finibus nisl cursus ac. Interdum et malesuada fames ac ante ipsum primis in faucibus. In quis ante tortor. Donec quis ornare turpis.
Aliquam dignissim sem diam, at tristique leo blandit non. Vivamus neque nisl, dictum sit amet vulputate ac, congue et massa. Aenean a faucibus tellus, a interdum nisi. Aliquam non nisl sed metus pharetra facilisis. Maecenas eu dictum urna, ornare
pharetra felis. Nunc maximus mauris in sem cursus vehicula.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam rhoncus auctor commodo. Duis condimentum massa mi, vitae finibus nisl cursus ac. Interdum et malesuada fames ac ante ipsum primis in faucibus. In quis ante tortor. Donec quis ornare turpis.
Aliquam dignissim sem diam, at tristique leo blandit non. Vivamus neque nisl, dictum sit amet vulputate ac, congue et massa. Aenean a faucibus tellus, a interdum nisi. Aliquam non nisl sed metus pharetra facilisis. Maecenas eu dictum urna, ornare
pharetra felis. Nunc maximus mauris in sem cursus vehicula.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam rhoncus auctor commodo. Duis condimentum massa mi, vitae finibus nisl cursus ac. Interdum et malesuada fames ac ante ipsum primis in faucibus. In quis ante tortor. Donec quis ornare turpis.
Aliquam dignissim sem diam, at tristique leo blandit non. Vivamus neque nisl, dictum sit amet vulputate ac, congue et massa. Aenean a faucibus tellus, a interdum nisi. Aliquam non nisl sed metus pharetra facilisis. Maecenas eu dictum urna, ornare
pharetra felis. Nunc maximus mauris in sem cursus vehicula.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam rhoncus auctor commodo. Duis condimentum massa mi, vitae finibus nisl cursus ac. Interdum et malesuada fames ac ante ipsum primis in faucibus. In quis ante tortor. Donec quis ornare turpis.
Aliquam dignissim sem diam, at tristique leo blandit non. Vivamus neque nisl, dictum sit amet vulputate ac, congue et massa. Aenean a faucibus tellus, a interdum nisi. Aliquam non nisl sed metus pharetra facilisis. Maecenas eu dictum urna, ornare
pharetra felis. Nunc maximus mauris in sem cursus vehicula.</p>
Here is the javascript for the tabs
function openCity(evt, cityName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(cityName).style.display = "block";
evt.currentTarget.className += " active";
}
how can i remove elements from an ejs.HTML pages on the server before serving the pages?
Environment:HTML, JAVASCRIPT, Express.
there is empty script tags to get Prettier to format server-side JavaScript code in a few .ejs.html files but i want to remove them so they don’t be served to the client.
Get image local link from XML and load it on html file
I have a json link that contains various information and a path to an image on the computer and I wanted to load that image into a div in html.
I already have code to fetch text from the json and put it in the html, but I can’t put the image in the html
json link:
http://192.168.1.67:1312/results.json
json info:
{“CasaFaltas”:”5″,”CasaFaltas.Source”:”C:UserspedroDesktopCarrega PlayScoreboardFaltasFalta0.png”,”CasaGolos”:”10″,”Tempo”:”2:56″,”VisitanteFaltas”:”3″,”VisitanteGolos”:”11″}
To go get the text, I have the code below.
However I don’t know how to get the image to make it available in html
(however, if you have suggestions for improving my code, I’ll gladly accept)
<body>
<table class="TabelaTempo">
<tr style="height:20px">
<td style="width:340px"> </td>
<td id="Tempo" style="width:85px; font-size:18px">20:00</td>
<td style="width:44px"> </td>
<td style="width:45px; font-size:18px">1ª P</td>
</tr>
</table>
<script>
function $(a){
return document.getElementById(a)
}
function ajax(a,b,c){
c=new XMLHttpRequest;
c.open('GET',a);
c.onload=b;
c.send()
}
function reloadData(){
ajax('http://192.168.1.67:1312/results.json',updateText)
};
function updateText(){
var db=JSON.parse(this.response);
$("Tempo").innerHTML=db.Tempo;
$("CasaGolos").innerHTML=db.CasaGolos;
$("VisitanteGolos").innerHTML=db.VisitanteGolos;
$("CasaFaltas").innerHTML=db.CasaFaltas;
$("VisitanteFaltas").innerHTML=db.VisitanteFaltas;
$("CasaFaltas.Source").innerHTML=db.CasaFaltas.Source;
}
window.setInterval(reloadData,100);
$('#i_file').change( function(event) {
$("img").fadeIn("fast").attr('src',URL.createObjectURL(event.target.files[0]));
});
</script>
</body>
Ternary with three conditions Javascript
I have this structure
const name = user.name;
const email = user.email;
const doc = user.doc;
const paramsSearch = req?.params?.search;
const search = …;
I want to transform search in a ternary like:
const search = paramsSearch === user.name ? …
if its equal to name, email and doc then search will be one of them, else return an empty string
I have tried the if else condition but i need it in ternary
Missing Semicolon in Main.jsx React. Using component and Props [duplicate]
I am trying to convert class component to fucntion component in React. But i stuck in this error Parsing error: Missing semicolon. Main.jsx
import React,{useState} from 'react'
import Header from './Header'
import Photowall from './Photowall'
// const posts =
function Main() {
const [posts, setPost] = useState([
{
id:"0",
description:"Konoha green beast",
imageLink:"https://www.giantbomb.com/a/uploads/scale_small/1/14242/322895-might_guy.jpg"
},
{
id:"1",
description:"again Uchiha",
imageLink:"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAo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Jrr/EG/wA6VKlVw6/sRPsa26vbegEzNgYSzFjlGpJJ48TXKVZ/UdI0w9s0tDMd/Mi8T+YpUq5Ubsh6QfQ+98qDUqVUSxUqVKmMVYbHHTaXvxDy5UqVIDKUqVKmAqVKlQBw07De0nvr/qFKlQB9JSeyfA/lUOI/lN7n/jSpVAGVrtKlVgKlSpUgFSpUqYCpUqVIDH/tDxDrEuV2W4F7Ei/jbfXnS12lWkDOZ2lSpVoQdpUqVAH/2Q=="
},
{
id:"2",
description:"rasenshuriken",
imageLink:"https://media.comicbook.com/2020/12/naruto-1249229.jpeg?auto=webp&width=1200&height=628&crop=1200:628,smart"}
]);
removePhoto(postRemoved){
console.log(postRemoved.description)
}
return (
<>
<Header title={"Photowall"} />
<Photowall posts = {posts} onRemove={removePhoto}/>
</>
)
}
export default Main;
in removePhoto function i am facing this error. Help me to solve this error .
I am taking this array of all items to another componenets name Photowall. Then again using another component where i pass all this component individually using {props.posts.map((post,index) => <Photo key={index} post={post} onRemovePhoto={props.onRemovePhoto}/>)}
Then in main Photo.jsx i am calling this function to give me the post.description using a button onClick() property
<button className='remove-button' onClick={()=>{
props.onRemovephoto(post)
}}>
Remove
</button>
but this is giving me parsing error on Main.jsx line:26
ajv addSchema and validate the data doesn’t fail with intentional test to fail
I am using https://ajv.js.org/ to validate schemas and the configuration.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"things": {
"type": "array",
"minItems": 0,
"uniqueItems": true,
"items": {
"$ref": "#/definitions/thing"
}
}
},
"definitions": {
"thing": {
"type": "object",
"required": [
"name",
"type",
"label"
],
"properties": {
"name": {
"type": "string",
"description": "Thing name"
},
"type": {
"enum": [
"THING1",
"THING2",
"THING3",
"THING4"
],
"description": "Thing type"
},
"label": {
"type": "string",
"description": "label to display for the thing"
}
}
}
}
}
The data to test is:
let data = {
"things": [
{
"type": "THING1",
"label": "Context navigate test"
}
]
}
when running validate(data) it fails which is expected
[
{
instancePath: '/things/0',
schemaPath: '#/definitions/thing/required',
keyword: 'required',
params: { missingProperty: 'name' },
message: "must have required property 'name'"
}
]
When I move the definitions to a file it doesn’t fail anymore.
Definition now in a file
directory /definitions/thing_schema.json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "definitions/thing_schema.json#/thing",
"definitions": {
"thing": {
"description": "A representation of a thing",
"type": "object",
"required": [
"name",
"type",
"label"
],
"properties": {
"name": {
"type": "string",
"description": "Thing name"
},
"type": {
"enum": [
"THING1",
"THING2",
"THING3",
"THING4"
],
"description": "Thing type"
},
"label": {
"type": "string",
"description": "label to display for the thing"
}
}
}
}
}
The schema is now referencing the file instead of referencing the definition in its own file.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"things": {
"type": "array",
"minItems": 0,
"uniqueItems": true,
"items": {
"$ref": "definitions/thing_schema.json#/thing"
}
}
}
}
This time the validation doesn’t fail.
ajv.addSchema(thingDefintionFile)
const validate = ajv.compile(schemaFile)
if(!validate(data)) {
console.log(validate.errors)
}
stop child’s click event when dragging parent element
I have a horizontal scrolling feature. In my program, there is a parent element that contains multiple children. When you drag the child elements, it starts scrolling horizontally. Each child has a click event, so when you stop dragging the parent element, the click event is executed on the child on which the mouse cursed.
I do not like this. I want to trigger the click events only when you click on one of the children.
here is an example below (forked from another pen)
const slider = document.querySelector(".items");
let isDown = false;
let startX;
let scrollLeft;
slider.addEventListener("mousedown", (e) => {
isDown = true;
startX = e.pageX - slider.offsetLeft;
scrollLeft = slider.scrollLeft;
});
slider.addEventListener("mouseleave", () => {
isDown = false;
});
slider.addEventListener("mouseup", () => {
isDown = false;
});
slider.addEventListener("mousemove", (e) => {
if (!isDown) return;
e.preventDefault();
const x = e.pageX - slider.offsetLeft;
const walk = (x - startX) * 1; //scroll-fast
slider.scrollLeft = scrollLeft - walk;
console.log(walk);
});
@import url(https://fonts.googleapis.com/css?family=Rubik);
body,
html {
color: #fff;
text-align: center;
background: #efefef;
font-family: Helvetica, sans-serif;
margin: 0;
}
.grid-container {
background: #efefef;
font-family: "Rubik", sans-serif;
}
@supports (display: grid) {
.grid-container {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: auto 1fr auto;
grid-template-areas: "header header header" "title title footer" "main main main";
}
@media screen and (max-width: 500px) {
.grid-container {
grid-template-columns: 1fr;
grid-template-rows: 0.3fr 1fr auto 1fr;
grid-template-areas: "header" "title" "main" "footer";
}
}
.grid-item {
color: #fff;
background: skyblue;
padding: 3.5em 1em;
font-size: 1em;
font-weight: 700;
}
.header {
background-color: #092a37;
grid-area: header;
padding: 1em;
}
.title {
color: #555;
background-color: #f4fbfd;
grid-area: title;
}
.main {
color: #959595;
background-color: white;
grid-area: main;
padding: 0;
overflow-x: scroll;
overflow-y: hidden;
}
.footer {
background-color: #5bbce4;
grid-area: footer;
padding: 0.6em;
}
.items {
position: relative;
width: 100%;
overflow-x: scroll;
overflow-y: hidden;
white-space: nowrap;
transition: all 0.2s;
transform: scale(0.98);
will-change: transform;
user-select: none;
cursor: pointer;
}
.item {
display: inline-block;
background: skyblue;
min-height: 250px;
min-width: 400px;
margin: 0;
}
@media screen and (max-width: 500px) {
.item {
min-height: 200px;
min-width: 200px;
}
}
}
a {
text-decoration: underline;
margin: 1em auto;
}
a:hover {
cursor: pointer;
}
p {
text-align: left;
text-indent: 20px;
font-weight: 100;
}
i {
color: skyblue;
}
h1 {
color: black;
font-size: 12pt;
}
<h1> <a href="https://codepen.io/thenutz/pen/VwYeYEE" target="_blank">forked from this pen</a> (simplified + click events added)</h1>
<div class="grid-container">
<main class="grid-item main">
<div class="items">
<div onclick="alert('hey')" class="item item1"></div>
<div onclick="alert('hey')" class="item item3"></div>
<div onclick="alert('hey')" class="item item4"></div>
<div onclick="alert('hey')" class="item item2"></div>
<div onclick="alert('hey')" class="item item5"></div>
<div onclick="alert('hey')" class="item item6"></div>
<div onclick="alert('hey')" class="item item7"></div>
<div onclick="alert('hey')" class="item item8"></div>
<div onclick="alert('hey')" class="item item9"></div>
<div onclick="alert('hey')" class="item item10"></div>
</div>
</main>
</div>
What I tried (check them here):
As you see, we have four event listeners:
- mousedown
- mouseleave
- mouseup
- mousemove
I put e.preventDefault() and e.stopPropagation() inside each of them also i tried to use both e.preventDefault() and e.stopPropagation() inside children click handlers before alerting “hey”. But these solutions weren’t work
Intercept outgoing HXR requests and their content
I am looking to monitor all outgoing HXR requests on the page in order to intercept a specific one that I wish to extract its data to log.
Here’s the specific request I am trying to intercept:
Request header from the console
Request body I want to extract
Here’s what I tried so far:
(function(send) {
XMLHttpRequest.prototype.send = function(body) {
var info="send datarn"+body;
console.log(info);
send.call(this, body);
};
})(XMLHttpRequest.prototype.send);
This seems to be somehow working because I get some requests logged in the console but not the ones I am looking for.
I also get some send data [object FormData] logged.
I am probably missing something about which HXR requests I am intercepting with my script and would love some help!
Thanks for your time!
How to pass a 2d array of numbers to my .Net controller?
I have a 2d javascript array like this
[[2,3],[13,4],[1,19]]
and I want to pass it to my .Net controller
My controller header looks like this
public async Task<ActionResult> UpdateOrder(int[,] order)
My put call looks like this
updateOrder(order: number[][]): Observable<any> {
return this.http.put(this.baseUrl + 'members/edit/set-order/' + order, {});
}
but I’m getting an error when I hit the controller saying:
‘Cannot deserialize the current JSON object (e.g. {“name”:”value”}) into type ‘System.Int32[,]’ because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.nTo fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.nPath ”, line 1, position 2.’
script tag doesnt work inside body and partially works in head? [closed]
I am trying to use bootstrap 5 and using their template:
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<h1>Hello, world!</h1>
<!-- Optional JavaScript; choose one of the two! -->
<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<!-- Option 2: Separate Popper and Bootstrap JS -->
<!--
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
-->
</body>
</html>
but the js doesn’t seem to be working as when I try to use modals, or navbars, nothing works. its only the css.
my file is saved as a .PHP file. any ideas on what’s going wrong? I haven’t been able to find a solution that works after browsing this site and others for a few hours
Understanding Trie Tree Implementation in JavaScript
Please I don’t understand the logic in the add and search method here, can someone help me explain what’s going on in these methods, especially in the two while loops inside add(). I encountered this in the book Hands-On Data Structures and Algorithms with JavaScript by Kashyap Mukkamala. Also I want to understand how this implementation is related to a trie tree, possibly suggest a more simpler implementation of this same logic.
export class Trie {
tree: any = {};
constructor() {}
add(input) {
// set to root of tree
var currentNode = this.tree;
// init value
var nextNode = null;
// take 1st char and trim input
var curChar = input.slice(0,1);
input = input.slice(1);
// find first new character, until then keep triming input
while(currentNode[curChar] && curChar){
currentNode = currentNode[curChar];
// update remainder array, this will exist as we added the node earlier
currentNode.remainder.push(input);
// trim input
curChar = input.slice(0,1);
input = input.slice(1);
}
// while next character is available keep adding new branches and prune till end
while(curChar) {
// new reference in each loop
// create remainder array starting with current input
// so when adding the node `a` we add to the remainder `dam` and so on
nextNode = {
remainder: [input]
};
// assign to current tree node
currentNode[curChar] = nextNode;
// hold reference for next loop
currentNode = nextNode;
// prepare for next iteration
curChar = input.slice(0,1);
input = input.slice(1);
}
}
search(input) {
// get the whole tree
var currentNode = this.tree;
var curChar = input.slice(0,1);
// take first character
input = input.slice(1);
// keep extracting the subtree based on the current character
while(currentNode[curChar] && curChar){
currentNode = currentNode[curChar];
curChar = input.slice(0,1);
input = input.slice(1);
}
// reached the end and no subtree found
// i.e. no data found
if (curChar && !currentNode[curChar]) {
return {
remainder: []
};
}
// return the node found
return currentNode;
}
}