There are many bzip2 decompress, but is there one that compresses in javascript and is MIT?
Category: javascript
Category Added in a WPeMatico Campaign
How to return function-generated variable
I have created a function that does this:
var getMostRecent = function (dir: string, cb: any) {
var dir = homedir
var files = fs.readdir(dir, function (err, files) {
var sorted = files.map(function(v) {
var filepath = path.resolve(dir, v);
return {
name:v,
time:fs.statSync(filepath).mtime.getTime()
};
})
.sort(function(a, b) { return b.time - a.time; })
.map(function(v) { return v.name; });
if (sorted.length > 0) {
cb(null, sorted[0]);
} else {
cb('Roblox appears to not be installed. Why do you plan to restore the old Roblox cursor, when Roblox doesn't even exist?', null);
}
})
}
Then I call the function like this:
var recent = getMostRecent('./', function (err: any, recent: any) {
if (err) console.error(err);
return {
recent: recent
}
});
console.log(recent);
But then I get undefined. When I run this:
getMostRecent('./', function (err: any, recent: any) {
if (err) console.error(err);
console.log(recent);
});
It gives the folder. I can’t figure out a way to return this value.
Maybe I’m too used to Lua.
Shuffle multiple option value with one click generate button #2
How if i’ve 8 dropdown list when clicked only 1 button the shuffle values will pick random value , but in every dropdown value won’t be the same and the choices of value will be spread over each dropdown?
cshtml option value code :
<div class="col-xs-8">
<div class="form-group">
<select id="txtCupA" class="form-control">
<option value="SWEET">SWEET</option>
<option value="SOUR">SOUR</option>
<option value="SALTY">SALTY</option>
<option value="BITTER">BITTER</option>
<option value="UMAMI">UMAMI</option>
<option value="WATER">WATER</option>
<option value="WATER">WATER</option>
<option value="WATER">WATER</option>
</select>
</div>
<div class="form-group">
<select id="txtCupB" class="form-control">
<option value="SWEET">SWEET</option>
<option value="SOUR">SOUR</option>
<option value="SALTY">SALTY</option>
<option value="BITTER">BITTER</option>
<option value="UMAMI">UMAMI</option>
<option value="WATER">WATER</option>
<option value="WATER">WATER</option>
<option value="WATER">WATER</option>
</select>
</div>
<div class="form-group">
<select id="txtCupC" class="form-control">
<option value="SWEET">SWEET</option>
<option value="SOUR">SOUR</option>
<option value="SALTY">SALTY</option>
<option value="BITTER">BITTER</option>
<option value="UMAMI">UMAMI</option>
<option value="WATER">WATER</option>
<option value="WATER">WATER</option>
<option value="WATER">WATER</option>
</select>
</div>
<div class="form-group">
<select id="txtCupD" class="form-control">
<option value="SWEET">SWEET</option>
<option value="SOUR">SOUR</option>
<option value="SALTY">SALTY</option>
<option value="BITTER">BITTER</option>
<option value="UMAMI">UMAMI</option>
<option value="WATER">WATER</option>
<option value="WATER">WATER</option>
<option value="WATER">WATER</option>
</select>
</div>
<div class="form-group">
<select id="txtCupE" class="form-control">
<option value="SWEET">SWEET</option>
<option value="SOUR">SOUR</option>
<option value="SALTY">SALTY</option>
<option value="BITTER">BITTER</option>
<option value="UMAMI">UMAMI</option>
<option value="WATER">WATER</option>
<option value="WATER">WATER</option>
<option value="WATER">WATER</option>
</select>
</div>
<div class="form-group">
<select id="txtCupF" class="form-control">
<option value="SWEET">SWEET</option>
<option value="SOUR">SOUR</option>
<option value="SALTY">SALTY</option>
<option value="BITTER">BITTER</option>
<option value="UMAMI">UMAMI</option>
<option value="WATER">WATER</option>
<option value="WATER">WATER</option>
<option value="WATER">WATER</option>
</select>
</div>
<div class="form-group">
<select id="txtCupG" class="form-control">
<option value="SWEET">SWEET</option>
<option value="SOUR">SOUR</option>
<option value="SALTY">SALTY</option>
<option value="BITTER">BITTER</option>
<option value="UMAMI">UMAMI</option>
<option value="WATER">WATER</option>
<option value="WATER">WATER</option>
<option value="WATER">WATER</option>
</select>
</div>
<div class="form-group">
<select id="txtCupH" class="form-control">
<option value="SWEET">SWEET</option>
<option value="SOUR">SOUR</option>
<option value="SALTY">SALTY</option>
<option value="BITTER">BITTER</option>
<option value="UMAMI">UMAMI</option>
<option value="WATER">WATER</option>
<option value="WATER">WATER</option>
<option value="WATER">WATER</option>
</select>
</div>
<input type="submit" id="shuffleDropDown" value="Suffle Value" class="btn btn-primary" />
Script :
function funcArrayShuffle(array) {
var currentIndex = array.length,
temporaryValue, randomIndex;
while (0 !== currentIndex) {
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;}
$("#shuffleDropDown").click(function () {
//Getting the current dropdown List
var options = $('#txtCupA option');
var values = $.map(options, e => $(e).val())
//Make It random
var shuffleddItemList = funcArrayShuffle(values);
//Made the older drowdownList empty
var dropdown = $('#txtCupA');
dropdown.empty();
var dropdown1 = $('#txtCupB');
dropdown1.empty();
var dropdown2 = $('#txtCupC');
dropdown2.empty();
var dropdown3 = $('#txtCupD');
dropdown3.empty();
var dropdown4 = $('#txtCupE');
dropdown4.empty();
var dropdown5 = $('#txtCupF');
dropdown5.empty();
var dropdown6 = $('#txtCupG');
dropdown6.empty();
var dropdown7 = $('#txtCupH');
dropdown7.empty();
//Loop through the Shaffle array item and made the New Random Dropdown List
$.each(shuffleddItemList, function (index, item) {
console.log(index, item);
dropdown.append(
$('<option>', {
value: item,
text: item
}, '</option>'))
dropdown1.append(
$('<option>', {
value: item,
text: item
}, '</option>'))
dropdown2.append(
$('<option>', {
value: item,
text: item
}, '</option>'))
dropdown3.append(
$('<option>', {
value: item,
text: item
}, '</option>'))
dropdown4.append(
$('<option>', {
value: item,
text: item
}, '</option>'))
dropdown5.append(
$('<option>', {
value: item,
text: item
}, '</option>'))
dropdown6.append(
$('<option>', {
value: item,
text: item
}, '</option>'))
dropdown7.append(
$('<option>', {
value: item,
text: item
}, '</option>'))
});
});
my current issue :
the choices of value won’t spread over each dropdown
my expectation :
when i click generate button, every option value will shuffled value and every dropdown value won’t be the same then the choices of value will be spread over each dropdown looks like this
Linked list with javascript shows [Object] as value instead of serialized object [duplicate]
I am trying to construct a linked list using a Class
with JS. Inside my Class
I have a function called checkForEmptyNext()
which traverses the list and searches for the node with a next:
property of null
The function should recursively call itself until it finds the correct node
LinkedList
// 10 --> 15 --> 16
class LinkedList {
constructor(value){
this.head = {
value: value,
next: null
}
this.tail = this.head;
this.length = 1;
}
append(value){
if(this.head.next === null){
this.head.next = {
value,
next: null
}
this.tail = this.head.next;
this.length++
}else{
this.checkForEmptyNext(value, this.head.next)
}
}
checkForEmptyNext(value, node){
if(node.next === null){
node.next = {
value,
next: null
}
this.tail = node.next;
this.length++
}else{
this.checkForEmptyNext(value, node.next)
}
}
}
const linked = new LinkedList(10);
linked.append(5)
linked.append(16)
console.log(linked)
The console.log is showing:
LinkedList {
head: { value: 10, next: { value: 5, next: [Object] } },
tail: { value: 16, next: null },
length: 3 }
Why am I seeing [Object]
instead of the actual serialized value?
Can’t deploy firestore cloud functions
I am trying to integrate Elastic Search in my Flutter app. I am trying to deploy a few functions but nothing seems to work.
here is my index.js code:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const { Client } = require('@elastic/elasticsearch')
admin.initializeApp(functions.config().firebase);
const env = functions.config();
const auth = {
username: env.elasticsearch.username,
password: env.elasticsearch.password,
};
const client = new Client({
node: env.elasticsearch.url,
auth: auth
})
exports.createPost = functions.firestore
.document('bookings/{BookingId}')
.onCreate( async (snap, context) => {
await client.index({
index: 'bookings',
type: '_doc',
id: snap.id,
body: snap.data()
})
});
exports.updatePost = functions.firestore
.document('bookings/{BookingId}')
.onUpdate( async (snap, context) => {
await client.update({
index: 'bookings',
type: '_doc',
id: context.params.BookingId,
body: snap.after.data()
})
});
exports.deletePost = functions.firestore
.document('bookings/{BookingId}')
.onDelete( snap => {
client.delete({
index: 'bookings',
type: '_doc',
id: snap.id,
})
});
Here is the packages.json:
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint",
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "16"
},
"main": "index.js",
"dependencies": {
"firebase-admin": "^10.0.2",
"firebase-functions": "^3.18.0"
},
"devDependencies": {
"eslint": "^8.9.0",
"eslint-config-google": "^0.14.0",
"firebase-functions-test": "^0.2.0"
},
"private": true
}
I installed elasticsearch using npm:
npm install @elastic/elasticsearch
Everytime I deploy, I get the following output:
deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> lint
> eslint
+ functions: Finished running predeploy script.
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
+ functions: required API cloudfunctions.googleapis.com is enabled
+ functions: required API cloudbuild.googleapis.com is enabled
i functions: preparing codebase default for deployment
i functions: preparing functions directory for uploading...
i functions: packaged C:UsersDanisDesktopspace-shuttle-functionsfunctions (68.46 KB) for uploading
+ functions: functions folder uploaded successfully
i functions: updating Node.js 16 function createPost(us-central1)...
i functions: updating Node.js 16 function updatePost(us-central1)...
i functions: updating Node.js 16 function deletePost(us-central1)...
Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.
Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.
Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.
Functions deploy had errors with the following functions:
createPost(us-central1)
deletePost(us-central1)
updatePost(us-central1)
i functions: cleaning up build files...
Error: There was an error deploying functions:
- Error Failed to update function createPost in region us-central1
- Error Failed to update function deletePost in region us-central1
- Error Failed to update function updatePost in region us-central1
functions:log
shows me the following:
PS C:UsersDanisDesktopspace-shuttle-functions> firebase functions:log
2022-05-25T02:35:40.303705Z ? deletePost: - /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/loader.js
2022-05-25T02:35:40.303713Z ? deletePost: - /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/main.js
2022-05-25T02:35:40.303723Z ? deletePost: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
2022-05-25T02:35:40.303730Z ? deletePost: at Function.Module._load (node:internal/modules/cjs/loader:778:27)
2022-05-25T02:35:40.303737Z ? deletePost: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-05-25T02:35:40.303744Z ? deletePost: at require (node:internal/modules/cjs/helpers:102:18)
2022-05-25T02:35:40.303751Z ? deletePost: at Object.<anonymous> (/workspace/index.js:3:20)
2022-05-25T02:35:40.303757Z ? deletePost: at Module._compile (node:internal/modules/cjs/loader:1101:14)
2022-05-25T02:35:40.303764Z ? deletePost: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
2022-05-25T02:35:40.303771Z ? deletePost: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-05-25T02:35:40.303777Z ? deletePost: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-05-25T02:35:40.303784Z ? deletePost: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-05-25T02:35:40.304148Z ? deletePost: Could not load the function, shutting down.
2022-05-25T02:35:40.720348431Z E deletePost: Function cannot be initialized. Error: function terminated. Recommended action: inspect logs for termination reason. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging
2022-05-25T02:35:40.921043Z E deletePost: {"@type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{"code":3,"message":"Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation."},"authenticationInfo":{"principalEmail":"[email protected]"},"serviceName":"cloudfunctions.googleapis.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction","resourceName":"projects/space-shuttle-b0738/locations/us-central1/functions/deletePost"}
2022-05-25T02:35:41.776Z ? updatePost: Provided module can't be loaded.
2022-05-25T02:35:41.776039Z ? updatePost: Did you list all required modules in the package.json dependencies?
2022-05-25T02:35:41.776055Z ? updatePost: Detailed stack trace: Error: Cannot find module '@elastic/elasticsearch'
2022-05-25T02:35:41.776063Z ? updatePost: Require stack:
2022-05-25T02:35:41.776077Z ? updatePost: - /workspace/index.js
2022-05-25T02:35:41.776089Z ? updatePost: - /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/loader.js
2022-05-25T02:35:41.776098Z ? updatePost: - /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/main.js
2022-05-25T02:35:41.776109Z ? updatePost: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
2022-05-25T02:35:41.776116Z ? updatePost: at Function.Module._load (node:internal/modules/cjs/loader:778:27)
2022-05-25T02:35:41.776124Z ? updatePost: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-05-25T02:35:41.776132Z ? updatePost: at require (node:internal/modules/cjs/helpers:102:18)
2022-05-25T02:35:41.776139Z ? updatePost: at Object.<anonymous> (/workspace/index.js:3:20)
2022-05-25T02:35:41.776147Z ? updatePost: at Module._compile (node:internal/modules/cjs/loader:1101:14)
2022-05-25T02:35:41.776155Z ? updatePost: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
2022-05-25T02:35:41.776162Z ? updatePost: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-05-25T02:35:41.776170Z ? updatePost: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-05-25T02:35:41.776178Z ? updatePost: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-05-25T02:35:41.776649Z ? updatePost: Could not load the function, shutting down.
2022-05-25T02:35:42.152840030Z E updatePost: Function cannot be initialized. Error: function terminated. Recommended action: inspect logs for termination reason. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging
2022-05-25T02:35:42.370105Z E updatePost: {"@type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{"code":3,"message":"Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation."},"authenticationInfo":{"principalEmail":"[email protected]"},"serviceName":"cloudfunctions.googleapis.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction","resourceName":"projects/space-shuttle-b0738/locations/us-central1/functions/updatePost"}
The error seems to indicate that the elasticsearch module cannot be found which I do not know why.
P.S : I am super new to Javascript, Firebase Cloud Functions and Elastic Search.
How to get value from async function in javascript [duplicate]
I am trying to get response status from an async function after fetching from a url, but I can’t. The responseStatus always 0 in the console log
let responseStatus = 0;
const makeRequest = async () => {
const response = await fetch(url);
responseStatus = response.status;
// console.log(response);
}
makeRequest();
console.log("responseStatus: " + responseStatus)
Expected result:
responseStatus: 200
Actual result:
responseStatus: 0
how to give yeoman all argument at one go?
i wanted to give all argument of yeoman at one go in CI, i am using this yoeman
https://github.com/microsoft/generator-azuresfguest
something like this :
yeoman cmd : yo azuresfguest --serviceName "x".......
https://github.com/yeoman/yo/issues/480?
idea is, i will run the yeoman in CI/CD tool where user wont write anything or input anything in cmd – it’s just hardcoded values as argument.
argument details as per this document :
https://github.com/microsoft/generator-azuresfguest/blob/master/generators/guestbinary/index.js
How to use URL redirect in Google Chrome Extension in Manfest V3
I am new to developing Google Chrome Extensions. After extensive research, I cannot find really any useful Tips. Basically, what I want is after successfully logging in; the user is presented with a popup box (at this moment, options.html); where a user can check a checkbox (which if checked), does this change on this file. I do not have the function for the checkbox yet but I am needing to do the redirect first I think to make sure my extension would work for what I need it for but..
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="./CSS/selection.css">
<style>
body, html {
padding: 0;
margin: 0;
}
.container {
box-shadow: inset 0px 0px 8px 8px #181818;
width: 400px;
height: 300px;
background: url("./Images/ShadowGhosts.png");
background-repeat: no-repeat;
background-size: auto;
background-size: 400px 300px;
display: flex;
align-items: left;
justify-content: left;
flex-direction: column;
font-family: 'Source Sans Pro';
user-select: none;
color: goldenrod;
}
.black-input {
color: red
}
</style>
</head>
<body>
<div class="container">
<fieldset>
<legend>Select Which one you Want:</legend>
<div>
<input type="checkbox" class="black-input" id="scales" name="scales">
<!-- checked> -->
<label for="scales">Ears</label>
</div>
<div>
<input type="checkbox" id="horns" name="horns">
<label for="horns">Horns</label>
</div>
</fieldset>
</div>
</body>
and this is my manifest file:
{
"name": "Shadow Ghosts",
"description": "Some Cool Description",
"version": "1.1",
"manifest_version": 3,
"background": {
"service_worker": "./JS/background.js"
},
"action": {
"default_popup": "popup.html",
"default_icon": {
"16": "./Images/SG.png",
"32": "./Images/SG.png",
"48": "./Images/SG.png",
"128": "./Images/SG.png"
}
},
"icons": {
"16": "./Images/SG.png",
"32": "./Images/SG.png",
"48": "./Images/SG.png",
"128": "./Images/SG.png"
},
"content_scripts": [{
"all_frames": true,
"matches": ["<all_urls>"],
"js": ["JS/content-script.js"]
},
{
"run_at": "document_start",
"matches": ["*://localhost/tulc/public/exemple/wc*"],
"js": ["JS/cookie-fix.js"]
}
],
"permissions": ["storage", "activeTab", "scripting", "webRequest", "declarativeNetRequest"]
}
And lastly, this is my background script:
let color = "#3AA757";
chrome.runtime.onInstalled.addListener(() => {
chrome.storage.sync.set({ color });
console.log('Default background color set to ,color');
});
// chrome.webRequest.onSendHeaders.addListener(function (e){
// chrome.tabs.query({
// active:true,
// currentWindow:true
// },
// function (tabs){
// });},
// {
// urls:["<all_urls>"],
// types: ["xmlhttprequest"]
// },["requestHeaders"]);
In my background script, I used an older example to try to create my own code but it did not work as I had to comment it out. Can someone please point me in the right direction on:
1.) How to do a URL Redirect (From: Yahoo.com To: Google.com)
2.) How to add data to each checkbox if checked
and Lastly:
3.) How to use the data from the checkbox to modify data on the redirected page?
Displaying warning message if user is not on chrome
I am currently building a website, and I do not have the skills to make the website work on all on all browsers. So I have written a quick bit of JavaScript to detect the browser. I do not know JavaScript very well so the code does not work.
Here is the code
if(userAgent.not(/chrome/i)){
alert("Warning.n " +
"You are not on a recomended browser, n ciertain features might not work " +
"try using chrome");
}
can you please just make the warning only appear if you are not using chrome.
thank you very much
Identify money sending transaction and contract creation transaction
I’m using web3 version ^1.0.0-beta.46.
below is an example transaction of Ethereum block
accessList: []
blockHash: "0x0b82cf9ba5232f3e6432f99bed4e850f984d9b05ee64c8b4d42a826a1e68588e"
blockNumber: 14839057
chainId: "0x1"
from: "0xeB2629a2734e272Bcc07BDA959863f316F4bD4Cf"
gas: 21000
gasPrice: "21325281910"
hash: "0xc6d172d47a2dc6bc407b35d871b63dbf34a5a10c1a23f393543da20936519c9f"
input: "0x"
maxFeePerGas: "47000000000"
maxPriorityFeePerGas: "2000000000"
nonce: 5775540
r: "0xb7dd45d91b2585b8c4fe31ef722f97e477446d6dd412963782209f76608c89a"
s: "0x6bd92fd926f7e2d2626bdda85c99aa4bdb8ece805fc31b6008a734c05319d78e"
to: "0x55E19b1Eb57bfd3118cA4A986992526aA8d70887"
transactionIndex: 104
type: 2
v: "0x0"
value: "40535780000000000"
Can we identify eth transaction here?
Note: to
value is always present in each transaction of this block
css count-increment on every page-break
i have created a header and footer that will only show when the user exports the page, I am trying to add a custom pagination when printing but it does not seem to increment and is stuck with “Page 1”, is there a way for the CSS to detect page break? i have a page-break-after: always in one of the components since it usually has more than 1 page when exported. or is it because my footer is in a separate div from the components?
here is my partial code
my css:
body {
counter-reset: page 1;
}
@media print {
.pagebreak-after {
padding-top: 1rem;
page-break-after: always;
}
.print_footer {
visibility: visible;
position: fixed;
display: flex;
bottom: 2%;
padding: 1rem;
width: 100%;
border-top: 1px solid black;
}
.counter::after {
counter-increment: page;
content: " | Page " counter(page);
}
.adjust_on_print {
margin-top: 3rem !important;
}
.no-print {
display: none;
visibility: hidden;
}
.print_header {
visibility: visible;
position: fixed;
top: 2%;
width: 100%;
border-bottom: 1px solid gray;
}
}
my code:
<div class="content">
<div class="row d-flex no-print">
<div v-if="false" class="col d-flex align-items-center">
<a class="nav-link" :href="json_data" :download="file_name">
<button
class="btn btn-sm btn-outline-secondary d-flex align-items-center"
>
<i class="mdi mdi-printer mr-1" /><small>Export</small>
</button>
</a>
</div>
<div class="col d-flex align-items-center">
<button
class="btn btn-sm btn-outline-secondary ml-auto d-flex align-items-center"
@click.prevent="print_full"
>
<i class="mdi mdi-printer mr-1" /><small>{{btn_labels.print}}</small>
</button>
</div>
</div>
<ErmittlungDerHochstgrenzen ref="ermit" />
<WeitereBerechnungsgrundlagen class="my-3 pagebreak-after" ref="weitere" />
<ErmittlungAnerkannterHilfebedarf
class="adjust_on_print"
ref="ermit_annerkanter"
/>
</div>
<div :class="{'no-print':this.print}">
<div class="print_header">
<p>{{claim_info.Insurance_number}}</p>
<p>{{claim_info.First_name}} {{claim_info.Last_name}}</p>
</div>
<div class="print_footer">
<span class="mr-auto">Footer here</span>
<span class="mx-auto"
>{{claim_info.First_name}} {{claim_info.Last_name}}</span
>
<span class="ml-auto counter">{{claim_info.Date | moment('L')}}</span>
</div>
</div>
How to increase height as I move cursor up and decrease as I move cursor down which is opposite to what the code below does
const handleMouseMove = useCallback((e) => {
const newHeight = e.clientY -document.body.offsetTop ;
if (newHeight > minDrawerHeight && newHeight < maxDrawerHeight) {
setDrawerHeight(newHeight);
}
}, []);
Java encountered a problem reading the first line of the TXT file
Java read TXT file encountered a problem in the first line, the program will add a space in front of the string in the first line, how should we deal with it
Nesting multiple [Op.not] queries in a single where clause
I’ve got a filter that allows users to indicate themes and genres they would like removed from the search results. This is an OR, not AND situation, so if either a theme or a genre is matched, it should be removed from the pool.
If I run the query below with a single [Op.not] clause, the themes and genres filter correctly. When I attempt to combine them as show in the example, only the genres [Op.not] executes. I assume I’ve chained them incorrectly in the where clause?
Code Example
//Variables to store filters from JSON body
let sortBy = [req.body.galleryFilters.sortBy, 'ASC']
let hiddenThemes = [];
let hiddenGenres = [];
//Parse the body for activeFilters create and array of Active Filters
req.body.galleryFilters.themes.forEach(theme => {
if(theme.hidden === true) {
hiddenThemes.push(theme.name)
}
})
req.body.galleryFilters.genres.forEach(genre => {
if(genre.hidden === true) {
hiddenGenres.push(genre.name)
}
})
//use variables above to create new playlist obje
const playlists = await db.playlists.findAll({
where: {
[Op.not]: {
themes: {
[Op.overlap]: hiddenThemes
},
},
[Op.not]: {
genres: {
[Op.overlap]: hiddenGenres
},
},
},
order: [[req.body.galleryFilters.sortBy, 'ASC']]
});
return res.send(playlists);
}
});
Trying to pass value/variable/params to url and new window
I’m trying to pass some values to a new window URL:
function sendInfo() {
var params = new URLSearchParams();
params.append("ozip", publicOzip);
params.append("dzip", publicDzip);
params.append("ocity",ocitystatetext);
params.append("dcity", dcitystatetext);
var url = "/critracker.html?" + params.toString();
location.href = "/critracker.html?";
}
however i am getting a “Uncaught SyntaxError: Unexpected token ‘var’ ” on the second window which contains the code:
function get ()
{
var params = new URLSearchParams(window.location.search),
var ozip = params.get("ozip");
var dzip = params.get("dzip");
var ocity = params.get("ocity");
var dcity = params.get("dcity");
}
The new window does not open with the variables as parameters , does anyone have any tips for sending variables and their values to a new window?