As you can see from the picture below, after clicking on imbed button on the parent window, the popup window for OAuth will show up and then the control will be handed over back to parent window with the content picker at the top for selecting the content to be imported. In this state, the other area of parent window is greyed out and non-clickable. I wonder how is this achieved with JavaScript? I already use Window.opener for popup window to OAuth the user(The redirect URL should be set up for post-authentication) but have no clue on the content picker part.

Category: javascript
Category Added in a WPeMatico Campaign
How can you make a screen with a flatlist scrollable in React Native?
One of my screens has a FlatList, but it also features a TextInput that must remain at the top of the page. The TextInput determines which other component is rendered, if it’s empty it is a category page but if it’s filled with any text it is the search results. My problem right now is that I have the TextInput outside of the main FlatList, and this causes it to be at the top of the screen even when scrolling the list. I’d like for it to remain at the top of the page and not follow the scroll.
If I put the TextInput inside one of the FlatLists it causes the other to not have it due to rendering separate components. But if I place it in both FlatLists it creates a bug where after typing the first character the TextInput will exit the editing mode since a completely new component is being rendered.
Here’s the structure I have right now:
<View>
<TextInput />
<View>
{conditional check ? (
<FlatList /> :
(<View>
<FlatList />
</View>
}
How to use onclick popup for Postman to run a post request to an API from an HTML page (using a button on my webpage)
The API requires authentication to generate a new reservation ID on every “send” command.
I need to have the Ppost request “send” to generate the url link in the response window. Then I need the url in the response window to activate. How can I do this using onclick?
Salesforce API Auth 400 in Axios, 200 OK in Postman
Relatively new to Axios and have run into an issue integrating an app into the Salesforce API.
My authentication request looks like this in postman.
POST
https://test.salesforce.com/services/oauth2/token?grant_type=password&client_id=ID&client_secret=secret&username=username&password=password
This is fine and succeeds, in Axios I run it like so
const response = await this._axios.post(`https://test.salesforce.com/services/oauth2/token`, {}, {
params: {
client_id,
client_secret,
grant_type: "password",
username,
password,
}
}
I’ve also just tried executing it with the manual URL with query strings in it and that still didn’t work. I’m guessing this is probably a serialisation issue or something, but I’m new to Axios so not sure. The error is just 400 Bad Request.
Any help would be appreciated.
Show Hide Input element on Reapeater based on selection
I want to create show input element using jquery after selected dropdown and show the input element in repeater but the problem I only show the input element in one input element, Thanks for your help.
This is html code form repeater
<tbody>
@foreach($siswas as $key => $nilai)
<tr>
<td><input type="text" class="form-control" id="nilai_sikap" name="nilai_sikap[]"></td>
</tr>
@endforeach
</tbody>
This is script to show and hide input element in id=”nilai_sikap”
$('#mapel_id').on('change', function() {
if ( this.value == 17 || this.value == 18)
$("#nilai_sikap")[$i].show();
else
$("#nilai_sikap").hide();
}).trigger("change")
From this I only get one input element like this
enter image description here
but I want show input element in every row like this
enter image description here
What do I have to add to my JS driven game to interact With an external game joystick/controller?
What do I have to add to my JS driven game to interact With an external game joystick/controller?
What I have is a JS-driven game with buttons to control movement of a Paddle so it can “hit” a game piece.
I only have <button>s to click. What do I have to add to my JS driven game to interact with an external game joystick/controller to click on.
I do nothing with mouseX or mouseY, just these clickable buttons.
The game piece bounces off 4 walls. It is the job of the user to steer the Paddle so it “hits” the game piece.
javascript button is not working based on code
below is html
<head>
<script src="js/login.js"></script>
</head>
<body>
<div class = wrapper>
<input id = "input" class = "id-bar" type = "text" placeholder = "email">
<input id = "input" class = "password-bar" type = "password" placeholder = "password">
<button id = "button">login</button>
</div>
</body>
below is javascript code in js file
const button = document.getElementById('button');
const idbar = document.getElementsByClassName('id-bar')[0];
const pwbar = document.getElementsByClassName('password-bar')[0];
const bar = document.getElementById('input')
bar.addEventListener("keyup", () =>{
const id = idbar.value;
const pw = pwbar.value;
if (id.length > 0 && pw.length > 0) {
button.style.backgroundColor = "#0095F6"
} else {
button.style.backgroundColor = "#C0DFFD"
}
});
I am trying to make login button enabled and color change to darker blue when there is at least one input for both id and password. (I have not implemented enabling portion yet.) Yet, above code does not seem to work. Could anyone help? Thanks!
what is difference between useCallback and useMemo in react hooks?
can you tell me. what is difference between useCallback() and useMemo() in react hooks and when is the function used or what are the examples?
Can i access Loader data in Action function in remix.run?
Can I access the loader function data in remix inside action Function without passing it from the form or submit function.
something like using useLoaderData inside action Function.
How to check for multiple values in a jquery IF statement
I have the below code which shows/hides a div based on an option in a dropdown, however it only toggles when a user selects 1. There are a few items in my dropdown that I’d like to show the DIV for. For example, let’s say I have values 1 through 8 in my dropdown, and I want to show a DIV when a user has selected 4, 6, and 7. I don’t want the DIV to toggle off and hide if a user changes selection from 4 to 6 either.
$(document).ready(function(){
$('#TypeofAction').on('change', function() {
if ( this.value == '1')
//.....................^.......
{
$("#business").show();
}
else
{
$("#business").hide();
}
});
});
webpacker 5 complains “Failed to mount component: template or render function not defined”
I am using @rails/webpacker of version 5.4.3 with webpacker gems of version ‘~> 5.0’. Previously I was using webpacker 4 and it was working. However, switching to webpacker 5 is creating multiple issues and not sure if it’s due to extract_css. If extract_css is false in webpacker.yml I get below issue where it says “Failed to mount component: template or render function not defined”
This is how I have my webpack setup
config/webpack/loaders/vue.js
const { dev_server: devServer } = require('@rails/webpacker').config;
const isProduction = process.env.NODE_ENV === 'production';
const inDevServer = process.argv.find((v) => v.includes('webpack-dev-server'));
const extractCSS = !(inDevServer && devServer && devServer.hmr) || isProduction;
module.exports = {
test: /.vue(.erb)?$/,
use: [
{
loader: 'vue-loader',
options: { extractCSS, compilerOptions: { whitespace: 'condense' } },
},
],
};
webpacker.yml
default: &default
public_root_path: public
check_yarn_integrity: false
source_path: app/javascript
source_entry_path: packs
public_output_path: packs
cache_path: tmp/cache/webpacker
extract_css: false
webpack_compile_output: true
# Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets']
resolved_paths: []
# Reload manifest.json on all requests so we reload latest compiled packs
cache_manifest: false
static_assets_extensions:
- .jpg
- .jpeg
- .png
- .gif
- .tiff
- .ico
- .svg
- .eot
- .otf
- .ttf
- .woff
- .woff2
extensions:
- .vue
- .js
- .sass
- .scss
- .css
- .png
- .svg
- .gif
- .jpeg
- .jpg
development:
<<: *default
compile: true
# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:
https: false
host: localhost
port: 3035
public: localhost:3035
hmr: true
# Inline should be set to true if using HMR
inline: true
overlay: true
compress: true
disable_host_check: true
use_local_ip: false
quiet: false
pretty: false
headers:
"Access-Control-Allow-Origin": "*"
watch_options:
ignored: "**/node_modules/**"
test:
<<: *default
compile: true
# Compile test packs to a separate directory
public_output_path: packs-test
staging:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
compile: false
# Cache manifest.json for performance
cache_manifest: true
webpack_compile_output: false
production:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
compile: false
# Cache manifest.json for performance
cache_manifest: true
# Extract and emit a css file
extract_css: true
webpack_compile_output: false
config/webpack/environment.js
const { environment } = require('@rails/webpacker');
const vue = require('./loaders/vue');
const webpack = require('webpack');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const TerserPlugin = require('terser-webpack-plugin');
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
// const { sass } = require('@rails/webpacker/package/rules');
const isEnvProduction = environment.config.mode === 'production';
const isEnvDevelopment = environment.config.mode === 'development';
const cssRegex = /.css$/;
const cssModuleRegex = /.module.css$/;
const customConfig = {
resolve: {
fallback: {
dgram: false,
fs: false,
net: false,
tls: false,
child_process: false,
},
},
entry: {
vendor: ['babel-polyfill', 'vue', 'moment', 'axios'],
},
};
const getStyleLoaders = (cssOptions) => {
const loaders = [
isEnvDevelopment && require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: cssOptions,
},
].filter(Boolean);
return loaders;
};
const customCssLoaderOptions = {
localIdentName: '[name]__[local]--[hash:base64:5]',
// minimize: environment.NODE_ENV === 'production',
modules: true,
};
environment.splitChunks((config) => {
return {
...config,
...{
optimization: {
splitChunks: { chunks: 'all', name: '~' },
runtimeChunk: true,
},
},
};
});
environment.config.delete('node.dgram');
environment.config.delete('node.fs');
environment.config.delete('node.net');
environment.config.delete('node.tls');
environment.config.delete('node.child_process');
environment.loaders.delete('css');
environment.config.merge(customConfig);
environment.plugins.append('VueLoaderPlugin', new VueLoaderPlugin());
environment.loaders.append('vue', {
test: /.vue$/,
loader: 'vue-loader',
});
// Comment this if you need case-sensitive-paths-plugin in local development.
if (process.env.RAILS_ENV === 'development') {
environment.plugins.delete('CaseSensitivePaths');
// Only add en.js locale for local development.
environment.plugins.append('moment', new webpack.ContextReplacementPlugin(/moment[/\]locale/, /(en).js/));
}
environment.plugins.prepend('Environment', new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(process.env))));
environment.plugins.prepend(
'Provide',
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
jquery: 'jquery',
})
);
const config = environment.toWebpackConfig();
config.resolve.alias = {
jquery: 'jquery/src/jquery',
};
let sassLoader = environment.loaders.get('sass').use.find((item) => item.loader === 'sass-loader');
sassLoader = {
...sassLoader,
options: {
...sassLoader.options,
sassOptions: {
...sassLoader.options.sassOptions,
includePaths: ['./node_modules'],
},
},
};
// const CSSLoader = environment.loaders.get('sass').use.find(el => el.loader === 'css-loader')
// CSSLoader.options = {...CSSLoader.options, customCssLoaderOptions}
// let miniCssExtractPlugin = environment.plugins.get('MiniCssExtract');
// console.log('miniCssExtractPlugin', miniCssExtractPlugin)
environment.loaders.append('vue', vue);
environment.config.merge({
optimization: {
minimize: false, // should be isProduction
minimizer: [
new TerserPlugin({
test: /.js(?.*)?$/i,
}),
],
},
resolve: {
alias: {
app: path.resolve(__dirname, '../../app/'),
},
},
module: {
rules: [
{
oneOf: [
{
test: cssRegex,
exclude: cssModuleRegex,
use: getStyleLoaders({
importLoaders: 1,
sourceMap: false,
modules: {
mode: 'icss',
},
}),
sideEffects: true,
},
],
},
].filter(Boolean),
},
});
module.exports = environment;
If I turn extract_css to true in default section and recompile I get this issue
Webpacker can’t find construction_project_home_module.css in
‘public/packs/manifest.json. Possible causes:’
- You want to set webpacker.yml value of compile to true for your environment unless you are using the
webpack -wor the
webpack-dev-server.- webpack has not yet re-run to reflect updates.
- You have misconfigured Webpacker’s config/webpacker.yml file.
- Your webpack configuration is not creating a manifest.
I am not sure what’s causing such issue and what’s the recommended approach for handling extract_css. Could anyone please check my webpack config and help me solve my issue? Since extract_css gave multiple type of issue so I presented both of them so that it will be easier for the one who wants to help me solve this issue.
These are the version of the package used;
webpacker ~> 5.0
@rails/webpacker 5.4.3
webpack 5.4.3
webpack-dev-server 4.9.0
vue 2.5.13
rails 5.2.7
axios.get not passing params from client side to the server
As the title, axios.get not passing params from client side to the server.
My server is currently on localhost:3001, and my client side is on http://127.0.0.1:5555. Client side is not React, so it’s currently on http://127.0.0.1:5555/WeatherApp/index.html (I opened the index.html file, the “entry point of the app,” on chrome from vscode by using FiveServer, and it is the port the client is being hosted)
Client side code:
export async function fetchData() {
const { data } =
await axios.get('http://localhost:3001/api', {
params: {q: 'Paris'}
})
return data
}
Server side code:
app.get("/api", async (req, res) => {
console.log(req.query)
const response = await axios.get('http://api.weatherapi.com/v1/current.json', {
params: {
key: process.env.KEY,
q: 'Paris'
}
})
const { data } = response
res.send(data)
})
The console.log(req.query) in server code printed an empty object. I also tried req.params, but it also printed an empty object (while i want to see “Paris”). Tried console.log(req) to see where the word “Paris” might be nested, but nowhere to be found.
Why is the view counter showing undefined?
I’m completely lost, I’ve been trying to figure this out for almost 2 days now.
Here is my code, if you need any more information please let me know. I need a break, so I’m not at my best. I made an account for this so I do not have enough status to post embedded pictures.
Two state variables change but only want to re-render once
https://codesandbox.io/s/ancient-rain-19d4rb?file=/src/App.js
I created a sandbox above to demonstrate the problem that I am having. Please play with it and look at the code to see what it’s doing.

The left side has selections for the ‘gamemode’ and for each gamemode there exists options ‘options’ on the right side.
The API call requires both of these values to be inputted.
Whenever I change the option on the right, it should do an API call in Game.js
If I change the gamemode on the left, it should also automatically change the option on the right to be the 0th index. With my current logic, it does two API calls whenever I change the gamemode since it’s also changing the option. (Look at the console when changing modes)
How can I change the design or how can I adjust things to get the result I’m looking for?
Let me know if further clarification is needed.
Why does object.key return undefined in JavaScript? [duplicate]
Why does object[key] return a value but object.key returns undefined in the following code?
const object = {
a: 1,
b: 2,
c: 3
};
let key = 'a';
console.log(object.key);
console.log(object[key]);