I am getting 2022-02-08T09:34:35.000Z this response from an API.
I am trying to convert it into a simple format like- 08-02-2022 09:34:35
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
I am getting 2022-02-08T09:34:35.000Z this response from an API.
I am trying to convert it into a simple format like- 08-02-2022 09:34:35
const box = document.getElementsByClassName('box');
let colorAsString = '#FEC6F0';
let colorAsNumber = #FEC6F0;
Array.from(box).forEach((element) =>{
element.style.backgroundColor = colorAsString;
element.style.backgroundColor = colorAsNumber;
});
I stored a hex-color value in string as well as a number and pass the variable as a value for css property.
Why this code not work can you explain me…!
I’m currently setting a background transparent mask with an onclick event-listener that will launch a delete modal function.
the drawback is the hindering of other event-listener elements in the page, since the modal and its mask have the highest z-index, i could give all clickable elements a high index, but then i will have to call a delete model function each time an element gets triggered whether the modal exists or not.
i’m contemplating creating a function that will add a delete modal event-listener on every element in the page with each creation of a modal, then remove all them when said modal is delete.
so how should i go about this?
I created this method to encryped string with a key:
public static string EncryptString(string key, string plainText)
{
byte[] iv = new byte[16];
byte[] array;
using (Aes aes = Aes.Create())
{
aes.Key = Encoding.UTF8.GetBytes(key);
aes.IV = iv;
ICryptoTransform encryptor = aes.CreateEncryptor(aes.Key, aes.IV);
using (MemoryStream memoryStream = new MemoryStream())
{
using (CryptoStream cryptoStream = new CryptoStream((Stream)memoryStream, encryptor, CryptoStreamMode.Write))
{
using (StreamWriter streamWriter = new StreamWriter((Stream)cryptoStream))
{
streamWriter.Write(plainText);
}
array = memoryStream.ToArray();
}
}
}
return Convert.ToBase64String(array);
}
But I also need this method in JS, to also decrypt the same string.
I am wondering about
AES, Encoding.UTF8.GetBytes, ICryptoTransform, Cryptostreammode, and MemoryStream.
Do these exist in JS?
IS this method even usable in JS?
I have the following code for rendering my checkboxes:
<ion-list-header>
<ion-label>Reason</ion-label>
</ion-list-header>
<ion-item v-for="entry in form" :key="entry.val">
<ion-label class="ion-text-wrap">{{ entry.text }}</ion-label>
<ion-checkbox
slot="end"
v-model="entry.isChecked"
@update:modelValue="entry.isChecked = $event"
:modelValue="entry.isChecked">
>
</ion-checkbox>
</ion-item>
Now I have in the data a form object which fills the checkboxes, and also a empty array where I want the values to be stored:
return {
settings: {
checkboxes: [],
},
form: [
{ val: "valone", text:"Text 1", isChecked: false },
{ val: "valtwo", text:"Text 2", isChecked: false },
{ val: "valthree", text:"Text 3", isChecked: false },
{ val: "valfour", text:"Text 3", isChecked: false },
{ val: "valfive", text:"Text 3", isChecked: false },
]
};
But I don’t know how to get the values of the checked checkboxes to the data array. Maybe I should not save in the array. Anyone know how to save these values?
we can assign the input value to a variable and then we’re assingning that variable to an element’s innerHTML, likewise why can’t I insert text object into an element’s innerHTML??
eg code:
x=document.getElementById("my_input"). value;
y=document.createElement("p");
y.innerHTML=x;
This code works but the below code isn’t, why?
eg code:
x=document.getElementById("my_input"). value;
y=document.createElement("p");
z=document.createTextNode("value");
y.innerHTML=z;
Don’t
mistake me ..I’m a beginner in js.. Correct me if I’m wrong..thanks!!
I am going to use async await instead of AJAX in jsp file. How can I use async/await? This is my code:
function setAcc(){
var acc_ = getDOM("acc_").value
AJAX.load({POST: {request: 'set_acc', async: false, acc_: acc_},
onSuccess: function (result) {
var objJSON = eval("(function(){return " + result + ";})()");
go({});
},
onError: function (d) {
alert_g(eval(d));
}
});
}
So, swiperjs, from docs:
“By default Swiper exports only core version without additional modules (like Navigation, Pagination, etc.). So you need to import and configure them too:”
// core version + navigation, pagination modules:
import Swiper, { Navigation, Pagination } from 'swiper';
Well, I did. This is my index.js test file:
import Swiper, { Navigation, Pagination } from 'swiper';
console.log(Swiper);
And this is my webpack config:
const path = require('path');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = {
//mode: 'development',
mode: 'production',
watch: true,
entry: {
index: './src/index.js',
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
clean: true,
},
plugins: [
new BundleAnalyzerPlugin()
],
module: {
rules: [
{
test: /.m?js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: { presets: ['@babel/preset-env'] }
}
} // babel
] // rules
} // module
};
Well, the BundleAnalyzer graph shows that ALL the swiper modules are bundled. Why? How can I avoid that?
All is well in the development, the console prints contextBridge normally
enter image description here
After packing into a desktop application using electron-builder, the console prints contextBridge undefined
enter image description here
I try to console electron object in preload.js, it contains contextBridge in development but there is no contextBridge in package application, did I make a mistake when packing?
main.js
const {app, BrowserWindow, Menu, MenuItem, ipcMain} = require('electron');
const path = require("path");
const low = require('lowdb');
const FileSync = require('lowdb/adapters/FileSync');
const adapter = new FileSync('./FSconfig.json', {
serialize: (data) => JSON.stringify(data),
deserialize: (data) => JSON.parse(data)
})
const db = low(adapter);
let win;
let windowConfig = {
icon: './img/icon.png',
width: 1000,
height: 800,
webPreferences: {
contextIsolation: true,
nodeIntegration: false,
preload: path.join(__dirname, 'preload.js')
}
};
function createWindow() {
win = new BrowserWindow(windowConfig);
win.loadURL(`${__dirname}/index.html`);
win.on('close', () => {
win = null;
});
win.on('resize', () => {
win.reload();
})
}
ipcMain.on('modifyJson', (event, args) => {
for (let item in args) {
if (args.hasOwnProperty(item)) {
db.set(item, args[item]).write()
}
}
})
app.on('ready', createWindow);
app.on('window-all-closed', () => {
app.quit();
});
app.on('activate', () => {
if (win == null) {
createWindow();
}
});
preload.js
const {contextBridge, ipcRenderer} = require('electron');
cconsole.log(contextBridge, 'contextBridge');
console.log(ipcRenderer, 'ipcRenderer');
contextBridge.exposeInMainWorld('modify', {
write: (modifyValue) => ipcRenderer.send('modifyJson', modifyValue)
})
package.json
{
"name": "appelectron",
"version": "1.0.0",
"description": "a Application",
"main": "main.js",
"scripts": {
"start": "electron .",
"pack": "electron-builder --win --x64",
"dist": "electron-builder",
"postinstall": "install-app-deps"
},
"author": "",
"license": "ISC",
"devDependencies": {
"electron": "^16.0.7",
"electron-builder": "^22.14.5"
},
"build": {
"appId": "修改配置",
"copyright": "Copyright © 2021-forever zjing",
"artifactName": "修改配置-${version}-${arch}.${ext}",
"win": {
"requestedExecutionLevel": "highestAvailable",
"target": [
{
"target": "nsis",
"arch": [
"x64"
]
}
]
},
"electronVersion": "1.0.0",
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": true,
"createDesktopShortcut": true,
"artifactName": "修改配置-${version}-${arch}.${ext}"
},
"extraResources": [
{
"from": "./static/img/",
"to": "app-server",
"filter": [
"**/*"
]
},
{
"from": "./FSconfig.json",
"to": "../FSconfig.json"
}
]
},
"dependencies": {
"lowdb": "^1.0.0"
}
}
I’m trying to have live-server auto reload the code once I save my change.
I’ve installed live-server globally and created a folder test and put 3 files in there
mkdir test
cd test
touch index.html main.js .live-server.json
live-server
Here’s the contents of index.html
<script src='main.js'></script>
Here’s the contents of main.js
console.log('hi');
and I got ‘hi’ in my chrome dev console.
When I changed the code, I got
Change detected /Users/ubuntu/dev/test/main.js
However, my chrome dev console didn’t yield that change. I have to refresh the page manually. How do I make my change auto loaded?
im new on stackoverflow, so don’t be harsh xD
Im still learning and there is so much that i dont know yet
Im currently developing a website and got stuck with a question:
how to make a website perform differently if it was accessed via a QR code?
For example if a person gets to a website through QR code they can see a button, but if a person gets to a website through copying url or searching through the web, then there is no button.
I have looked through the web, W3 and stackoverflow, but couldn’t find anything that could be similar, hence thats the reason why im here =)
The only thing that i found was (see below), however im not sure it has any use for my idea
var referrer = document.referrer
I dont use php and have no idea of how to use it, hence no php please =)
I’m having an antd rangepicker problem with keyboard popping up when using it on my phone.
working flow
You will see that the first time you press to select Start time no keyboard pop up.

Used onFocudFunc function.

But when I press OK after selecting start time finished A keyboard will pop up.

If selection rangepicker is done the first time and click to clear the data value in the rangepicker input box. Doing workflow again the next time, neither keyboard will appear.
I wish the keyboard didn’t come up the first time. What can I do?
Thank you.
Demo Code
https://codesandbox.io/s/rangepicker-stackoverflow-fix-vc15x
I can’t figure out how to make a slider out of rows, instead of modules in Divi (with Ken Wheeler slick slider). I am a beginner in coding, so for me it’s all I can find on the internet, and some basic codes, that I work with.
My main issue right now is that the things I want to slide are not the width of the parent section, because of that they are horizontally filling the whole section. See: Screenshot of page.
There is one solution I know of, that is making my Section to 1180px (for example), the rows aswell, and adding the slider css class to the section. However this means that the background (body) color need to be the same as the section background color(grey). And since I need this to be another color(orange) regarding a ugly flash of website when loading, this is no solution for me.
This is the script I use for this slider: <script> jQuery(function($){ $('.slide-stuff').slick({ slidesToShow: 1, slidesToScroll: 3 }); }); </script>
When making a ”regular” slider, with modules instead of rows, everything works fine, so I don’t think there is a problem with my slick js files?
I would really appreciate some help, or an explanation of where to search to fix this.
Please I want to make my own page if the connection is lost in flutter and I don’t know how to do it please can someone help me this is my code I tried many ways and it doesn’t work.
I need to remove the page of WebPage doesn’t work and design my own one please I’m working on a project
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> with TickerProviderStateMixin{
final Completer<WebViewController> _controller =
Completer<WebViewController>();
late WebViewController _webViewController;
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Welcome to Flutter',
home: SafeArea(
child : Scaffold(
body: WebView(
initialUrl: "https://wikoget.com",
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_webViewController = webViewController;
_controller.complete(webViewController);
},
onPageFinished: (String url) {
_webViewController
.evaluateJavascript("javascript:(function() { " +
"var head = document.getElementsByClassName('main-header-bar-wrap')[0];" +
"head.parentNode.style.cssText = ' position: sticky;position: -webkit-sticky; top : 0 ';" +
"var footer = document.getElementsByTagName('footer')[0];" +
"footer.parentNode.removeChild(footer);" +
"})()")
.then((value) => debugPrint('Page finished loading Javascript'))
.catchError((onError) => debugPrint('$onError'));
},
gestureNavigationEnabled: true,
),
),
),
);
}
JavascriptChannel _toasterJavascriptChannel(BuildContext context) {
return JavascriptChannel(
name: 'Toaster',
onMessageReceived: (JavascriptMessage message) {
// ignore: deprecated_member_use
Scaffold.of(context).showSnackBar(
SnackBar(content: Text(message.message)),
);
});
}
}
I’m trying to shuffle some cards from my memory game and I can’t figure out why the shuffleCards function won’t work:
const cards = document.querySelectorAll('.card');
function shuffleCards() {
cards.forEach(card => {
let randomPos = Math.floor(Math.random() * 12);
card.style.order = randomPos;
});
};