When I upload my html file to my website and open the source code using inspect in browser, it appear like this:
%3Cdiv%2Fid%3D'pnz'%2Fclass%3D
where is the problem?
Thank you.
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
When I upload my html file to my website and open the source code using inspect in browser, it appear like this:
%3Cdiv%2Fid%3D'pnz'%2Fclass%3D
where is the problem?
Thank you.
for (var g = 0; g < cArray.length - 1; g++) {
if (h !== g) {
if (
cArray[h].x + cArray[h].size > cArray[g].x - cArray[g].size &&
cArray[h].x - cArray[h].size < cArray[g].x + cArray[g].size &&
cArray[h].y + cArray[h].size > cArray[g].y - cArray[g].size &&
cArray[h].y - cArray[h].size < cArray[g].y + cArray[g].size
) {
cArray[h].dirX = cArray[g].dirX;
cArray[g].dirX = cArray[h].dirX;
cArray[h].dirY = cArray[g].dirY;
cArray[g].dirY = cArray[h].dirY;
}
}
}
Instead of bouncing off, they no-clip to each other, causing their directions to combine.
Specifically, I’m looking to create a common Component that with in a shared package based on vuejs-quill.
However because I’m writing the components using typescript and the npm is JavaScript and doesn’t include type definitions I’m having some trouble.
I’ve tried to create my own .d.ts file for the module but how am I to know what to include in the definition? If I’m just re-defining the entire module what’s the point of importing the module at all?
I’m making a frameless window, since I think my app will look horrible with the standard windows 10 title bar. I still want the user to be able to minimize and close the window, so I figured I’d just make my own buttons to minimize and exit the Window. I looked up quite a few solutions and ended up with this:
const { remote } = require('electron').remote;
var window = remote.getCurrentWindow();
function MinimizeWindow(){
window.minimize();
}
function ExitWindow(){
window.close();
}
All I found is that this completely bricks the script, proven by this:
document.getElementById('TestDiv').innerHTML = 'you like men';
where nothing changed until I commented out everything except for that line. Anything after and including const { remote }... doesn’t work. I looked it up again and found one answer, saying it was because I was in the main process and not the render process. I have no clue what that is even after looking at multiple stackoverflow and reddit posts. Is there any way to actually make my own title bar buttons or do I need to keep the standard W10 title bar?
I am new to web development and trying to create a portfolio website. I am trying to create a full-page nav bar. I am using bootstrap 5 and the navbar works when I click the button on the right, but I want to auto close the navbar when a menu item is selected. I am creating everything in one body with different sections.
HTML
<nav class="navbar fixed-top navbar-expand-lg">
<div class="container">
<a onclick="openMenu();" title="" class="btn">
<span></span>
<span></span>
</a>
<div class="menu">
<ul class="menu_list">
<li class="menu_list">
<a href="#home" title="" onclick="closeMenu();" class="menu_link">Home</a>
</li>
<li class="menu_list">
<a href="#about-me" title="" onclick="closeMenu();" class="menu_link">About</a>
</li>
<li class="menu_list">
<a href="#projects" title="" onclick="closeMenu();" class="menu_link">Projects</a>
</li>
<li class="menu_list">
<a href="#contact" title="" onclick="closeMenu();" class="menu_link">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
CSS
.btn{
position: absolute;
top: 21px;
right: 25px;
z-index: 3;
display: flex;
width: 20px;
height: 20px;
}
/*size of the button lines*/
.btn span{
position: absolute;
display: flex;
width: 20px;
height: 2px;
background: rgba(247,72,78,255);
transition: .5s;
}
/*position of each line within the button space*/
.btn span:nth-child(1){
top: 25%;
}
.btn span:nth-child(2){
top: 75%;
}
.btn.is-active span{
background: rgba(247,72,78,255);
}
/*transformation to X*/
.btn.is-active span:nth-child(1){
top: 50%;
transform: rotate(-45deg);
}
.btn.is-active span:nth-child(2){
top: 50%;
transform: rotate(45deg);
}
/*menu details*/
.menu {
background: rgb(0, 0, 0,0.60);
display: flex;
align-items: center;
position: fixed;
top: 0;
bottom: 0;
right: 0;
left: 0;
padding: 100px;
z-index: 1;
transform: .5s;
opacity: 0;
visibility: hidden;
}
/*when active (clicked)*/
.menu.is-active{
transition: .5s;
opacity: 1;
visibility: visible;
}
javascript: open menu() works fine, it’s used when the menu is open or closed using btn. The closeMenu() is what I am having difficulty with. I try to make the selection and toggle back to .menu from is-active but it does not work.
function openMenu(e){
let menu = document.querySelector('.menu');
let btn = document.querySelector('.btn');
menu.classList.toggle('is-active');
btn.classList.toggle('is-active');
e.preventDefault();
}
function closeMenu(){
let menu = document.querySelector('.menu.is-active');
let btn = document.querySelector('.btn.is-active');
menu.classList.toggle('.menu');
btn.classList.toggle('.btn');
e.preventDefault();
}
Any help is appreciated.
My aim is to display data table from Google sheet on my web app in a table.
Script is only displaying last data column from dataArray.
Could anyone please help, why this code is only able to append last data column and not all.
Code.gs
function getTableDataTV(){
const ws = SpreadsheetApp.openById("").getSheetByName("Sheet2");
const data = ws.getRange (1,1,ws.getLastRow(), 9).getDisplayValues();
return data
HTML
<html>
<head>
<script>
document.addEventListener("DOMContentLoaded",function(){
google.script.run.withSuccessHandler(generateTable).getTableDataTV();
});
function generateTable(dataArray){
var tabledb = document.getElementById("ptable");
console.log(dataArray);
dataArray.forEach(function(item, index){
if(index == 0){
var theaddb = document.createElement("thead");
var rhead = document.createElement("tr");
var th = document.createElement("th");
console.log(dataArray[0].length);
for(var i=0;i<(dataArray[0].length);i++){
th.textContent = item[i];
rhead.appendChild(th);
}
theaddb.appendChild(rhead);
tabledb.appendChild(theaddb);
}
else if(index > 0)
{
var tbody = document.createElement("tbody");
var rbody = document.createElement("tr");
var td = document.createElement("td");
for(var i=0;i<(dataArray[0].length);i++){
td.textContent = item[i];
rbody.appendChild(td);
}
tbody.appendChild(rbody);
tabledb.appendChild(tbody);
}
});
}
</script>
</head>
<body>
<div class="col s12">
<table id = "ptable">
</table>
</div>
</body>
</html>
console.log(dataArray);
0: Array(9) [ "DATE", "TITLE 1", "TITLE 2", … ]
1: Array(9) [ "2021-11-01", "3094392", "6338933", … ]
2: Array(9) [ "2021-11-02", "3841183", "6731805", … ]
3: Array(9) [ "2021-11-03", "5267740", "7713644", … ]
4: Array(9) [ "2021-11-04", "3144660", "6177727", … ]
5: Array(9) [ "2021-11-05", "3677444", "8649906", … ]
I am sending requests to the youtube v3 api with the following url:
const url = `https://www.googleapis.com/youtube/v3/search?key=${process.env.YOUTUBE_API_KEY}&part=snippet&q=foo`;
I am going to change this to use channelId to specify channel as foo is the channel name. I want to also use youtube apis search:list functionality to search for videos within a specific channel that have titles containing key words that, as i understand need to be specified via the q parameter.
Is there a way to provide multiple values for q as I need to search video titles on multiple criteria?
After the upgrade to Angular 13, when I try to add NgRx to the project with schematics (ng add @ngrx/store) I get this error:
An unhandled exception occurred: NOT SUPPORTED: keyword "id", use "$id" for schema ID
I want to change the script so that it will automatically load after the page is fully loaded, but it does not work for me.
I tried like this
<script type='text/javascript'>
//<![CDATA[
var la=!1;window.addEventListener("load",function(){(0!=document.documentElement.loadTop&&!1===la||0!=document.body.loadTop&&!1===la)&&(!function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-ххххххх";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(e,a)}(),la=!0)},!0);
//]]>
</script>
But this way it opens immediately, not after the page is fully loaded.
This is how the rules work, but it is shown after scrolling, how to make it appear itself after the page is fully loaded?
<script type='text/javascript'>
//<![CDATA[
var la=!1;window.addEventListener("scroll",function(){(0!=document.documentElement.scrollTop&&!1===la||0!=document.body.scrollTop&&!1===la)&&(!function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-хххх";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(e,a)}(),la=!0)},!0);
//]]>
</script>
I have a function to help the user scroll up to the top of the page like this:
function toTheTop(){
document.getElementByID('topUpBtn').addEventListener('click', ()=>{
scrollTo( { top: document.querySelector('h1').getBoundingClientRect().top,
behavior: 'smooth'})
});
}
export {
toTheTop
}
I am using webpack for code organisation. I called toTheTop function in an entry point as below:
import { toTheTop } from './js/TopUpButton.js';
if(document.readyState !== 'loading') {
console.log('document is already ready');
toTheTop();
}
else{
document.addEventListener('DOMContentLoaded', ()=>{
console.log('document was not ready'),
toTheTop();
});
}
export {
toTheTop
}
I have tested this function without webpack and it worked. However, when using with webpack, it didn’t. Inspect the console for the button I only see:
DOMContentloaded
click
But with webpack setup, I see a weird line named “beforeunload” in order like this:
beforunload
click
open this line I saw:
self.addEventListener("beforeunload", function () {
status.isUnloading = true;
});
I did not implement this code at all. I look for the use of beforeunload, this only uses if we want to prompt something for user before leaving a page.
My questions are: Why do I have the beforeunload function in my code? Does this relate to my webpack setup? And How can I solve my problem?
I tried to figure it out for several days, but still can’t handle it. Really need your help!
I wanted to interpolate variables in strings in JS so I used “(backticks) as shown here –
How To Interpolate Variables In String in JS
Then, I Wanted To put IF-Statements in jQuery Append So I got this –
IF Statements In jQuery Append
But When I use Both Together , Backticks Don’t Output Text As Usual-
$("main").append(`Hello ${my_var}`+(second_var>1?"hi ":"bye")+`Bye ${my_var}`
This Results Only In “hi” , The Backticks Before And After The Ternary Operator Don’t Output Anything.
HELP ??
Do anyone know how to create this types of search bar ? i have been searching all over the internet but I could not found any codes and articles related to this. if you know please help me. i want to create a similar search function in my website. I am providing the URL of this search box demo;
demo image1
Here is the URL of the search box: https://www.diffen.com/
So, been working on this for about 2 weeks now on JUST the navbar itself. I have tried so many things that i don’t recall what i have used to try to fix it.
It works on my old navbar (but it’s boostrap 3 and this project is on 5). The text overflows my navbar and causes the text/website to get extra space then what it’s supposed to be showing. I need a genius to resolve this for me as i have been stumped on this for a long time.
Issue (images)
https://gyazo.com/c212a931d6770b77998cb3fea3ae87d1 i’m highlighting it as the text can’t be seen due to white backround.
Trying to get working (old navbar) https://gyazo.com/66c482022e325cd9bd335ff666377474
Here is a JSfiddle to give an example plus the code i’m using. https://jsfiddle.net/yf90uxhc/2/
HTML navbar code
<div class="container-fluid">
<a class="navbar-brand" href="/">Home</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<!-- -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Amarr Empire
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"> Frigate Class</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#">Frigate</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#"> </a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<!-- -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Caldari State
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"> Frigate Class</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#">Frigate</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#"> </a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<!-- -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Minmatar Republic
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"> Frigate Class</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#">Frigate</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#"> </a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<!-- -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Gallente Federation
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"> Frigate Class</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#">Frigate</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#"> </a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<!-- -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Guristas Pirates
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"> Frigate Class</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#">Frigate</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#"> </a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<!-- -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Angel Cartel
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"> Frigate Class</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#">Frigate</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#"> </a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<!-- -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Blood Raider Covenant
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"> Frigate Class</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#">Frigate</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#"> </a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<!-- -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
ORE
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"> Frigate Class</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#">Frigate</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#"> </a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<!-- -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Servant Sisters of Eve
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"> Frigate Class</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#">Frigate</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#"> </a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<!-- -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Mordu's Legion Command
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"> Frigate Class</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#">Frigate</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#"> </a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<!-- -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Sansha's Nation
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"> Frigate Class</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#">Frigate</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#"> </a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<!-- -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Serpentis
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"> Frigate Class</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#">Frigate</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#"> </a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<!-- -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Triglavian Collective
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"> Frigate Class</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#">Frigate</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#"> </a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<!-- -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
EDENCOM
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#"> Frigate Class</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#">Frigate</a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#"> </a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<!-- -->
</ul>
</div>
</div>
</nav>```
Javascript
```document.addEventListener("DOMContentLoaded", function(){
// make it as accordion for smaller screens
if (window.innerWidth < 992) {
// close all inner dropdowns when parent is closed
document.querySelectorAll('.navbar .dropdown').forEach(function(everydropdown){
everydropdown.addEventListener('hidden.bs.dropdown', function () {
// after dropdown is hidden, then find all submenus
this.querySelectorAll('.submenu').forEach(function(everysubmenu){
// hide every submenu as well
everysubmenu.style.display = 'none';
});
})
});
document.querySelectorAll('.dropdown-menu a').forEach(function(element){
element.addEventListener('click', function (e) {
let nextEl = this.nextElementSibling;
if(nextEl && nextEl.classList.contains('submenu')) {
// prevent opening link if link needs to open dropdown
e.preventDefault();
if(nextEl.style.display == 'block'){
nextEl.style.display = 'none';
} else {
nextEl.style.display = 'block';
}
}
});
})
}
// end if innerWidth
});
// DOMContentLoaded end```
I am trying to understand the flow of execution in this code. As you can see in the snippet, there is a function slow and a cachingDecorator function which takes a function as its parameter. Here we are passing function slow in it. After passing the function slow, the slow equals
slow = function(x) {
if (cache.has(x)) { // if there's such key in cache
return cache.get(x); // read the result from it
}
let result = func(x); // otherwise call func
cache.set(x, result); // and cache (remember) the result
return result;
};
Now what I don’t understand is that when we call slow(1) are we passing the 1 to this slow function
function slow(x) {
// there can be a heavy CPU-intensive job here
console.log(`Called with ${x}`);
return x;
}
or in this
slow = function(x) {
if (cache.has(x)) { // if there's such key in cache
return cache.get(x); // read the result from it
}
let result = func(x); // otherwise call func
cache.set(x, result); // and cache (remember) the result
return result;
};
function slow(x) {
// there can be a heavy CPU-intensive job here
console.log(`Called with ${x}`);
return x;
}
function cachingDecorator(func) {
let cache = new Map();
return function(x) {
if (cache.has(x)) { // if there's such key in cache
return cache.get(x); // read the result from it
}
let result = func(x); // otherwise call func
cache.set(x, result); // and cache (remember) the result
return result;
};
}
slow = cachingDecorator(slow);
console.log(slow);
console.log(slow(1));
Recently I am trying to write element-plus casually, so I did not configure the Node environment and build the vue scaffolding. It was referenced locally through the way of cdn file download. All aspects of the components can be used normally, but I am trying to write the message prompt box js The components don’t seem to work. I don’t know how to introduce the components of the prompt box. The official ones are all used in the scaffolding npm way. I don’t know how to use these js components like cdn or local? I urge everyone to answer! Grateful!
The following is a code snippet:
<script src="/static/js/vue.global.js"></script>
<script src="/static/js/index.full.js"></script>
<script src="/static/js/axios.min.js"></script>
<script src="/static/js/qs.min.js"></script>
.then(function (response) {
console.log(response);
if (response.data == "error") {
ElMessage('this is a message.')
}
})
But the browser console reports an error:
ElMessage is not defined