javascript – How to exchange buttons (with jQuery) according to radio button checked or not

I am working on a user interface that the user will choose a shipping address. The design basically uses a radio button pattern, where the "map" checked would be green and a button would change depending on the map (radio button) checked.

Basically, there is a default button with a primary class and it says "Deliver to this address", but when the card is checked, it should change to "Selected Address". It works now. I first tried to use the "same" button but to change the inner text or html, as well as the classes, but that did not work very well. So, now, I thought about displaying and hiding the buttons depending on the status of the checked radio button.

But I have difficulty with siblings, parents, children, etc. – I cross the DOM to get the effect I want. What I want is that the checked map is green with the "Selected Address" button. This should even be loading the page if one of the cards is checked. And, when I check another card, to "uncheck" all other cards and return this button on the button "Send to this address".

I've created a JS Fiddle to show what I mean entirely: https://jsfiddle.net/gamehendgeVA/b98v65tx/3/

Here is the JS that I was trying:

    jQuery (".selectedAddressButton"). hide ();

jQuery (function () {
jQuery (".addressRadio"). change (function () {
if (jQuery (this) .is (": checked")) {
jQuery (this) .siblings (). find (".selectedAddressButton"). show ();
jQuery (this) .siblings (). find (". deliverButton"). hide ();
} other {
jQuery (this) .siblings (). find (".selectedAddressButton"). hide ();
jQuery (this) .parents (). find (". deliverButton"). show ();
}
});

});

(I had to use "jQuery" instead of $ for things to work, because of strange working files, without really knowing why.)

And, an excerpt from one of the radio buttons "cards":

    

I've thought of turning to the experts to see if I'm on the right track – there may be a simpler way to accomplish what I'm trying to do.

Any help is greatly appreciated!

Thank you!

javascript – Find all start indexes in a string that are anagrams of a word

Task:

Given a W word and an S string, find all the starting cues in S that
are anagrams of W.

For example, since W is "ab" and S is "abxaba", return 0, 3, and
4

My solution:

const anagramOccurrencesOf = (w, s) => {
const occurrencesCopy = [];
leave sCopy = s.slice (0);

leave index = 0;
while (sCopy.length && index! == -1) {
index = sCopy.indexOf (w);
if (index === -1) {break; }
occurrencesCopy.push ((occurrencesCopy[occurrencesCopy.length - 1] + index + 1 || 0));
sCopy = sCopy.slice (index + 1);
}
const occurrencesReverse = [];
Let sReverse = s.split (& # 39;). reverse (). join (& # 39;);

index = 0;
while (sReverse.length && index! == -1) {
index = sReverse.indexOf (w);
if (index === -1) {break; }
occurrencesReverse.push ((occurrencesReverse[occurrencesReverse.length - 1] - w.length - index + 1) || length s - length);
sReverse = sReverse.slice (index + 1);
}

return [...occurrencesCopy, ...occurrencesReverse].sort ((a, b) => a -b);
};

console.log (anagramOccurrenciesOf ("ab", "abxaba"));

javascript – Converts loops to recursive function

I've done a function for calculate all combinations of one board. The problem with my approach is that it only "generates" three-digit combinations (length of the past value table ** 3), since I have 3 of them curls nested. If I want, however, that this generates values ​​with 4 digits, I should nest a more loop.

Is there a way to create this same function, but recursively, so that I can pass an argument specifying the number of characters?

The expected result is a board lengthways last table length ** number of characters per combination.

const data ['a', 'b', 'c']

operate everything (data) {
final const = []
  
  for (const c1 of data) {
for (const c2 of data) {
for (const c3 of data) {
final.push (c1 + c2 + c3)
}
}
}

final declaration
}

const x = all (date)
console.log (x.length, & # 39;, x)

javascript – Node.js: "TypeError: Can not read property" get "from undefined"

I have 3 errors, or more, I do not know, here they are (I'm going to put the code that makes the mistake):

TypeError: Unable to read property 'get & # 39; undefined

				let data = ops.active.get (message.guild.id) || {};

if (! data.connection) data.connection = wait message.member.voiceChannel.join ()
if (! data.queue) data.queue = [];
data.guildID = message.guild.id;

UnhandledPromiseRejectionWarning: Rejection of an unmanaged promise. This error is due either to the launch of an asynchronous function without a catch block, or to the rejection of a promise that has not been handled with .catch (). (ID of rejection: 1)

(node: 10648) [DEP0018] DeprecationWarning: unmanaged promises are obsolete. In the future, discards of unmanaged promises will terminate the Node.js process with a non-zero exit code.

(The last 2 do not have an exact code, here is my complete code:

const ytdl = require (& # 39; ytdl-core & # 39;);
const streamOptions = {search: 0, volume: 1};

exports.run = async (client, message, arguments, ops) => {

if (! message.member.voiceChannel) returns message.channel.send (& # 39; Please connect to a voice channel to read tutorials on how to earn more from PeterGriffinCoins! & # 39;);

// if (message.guild.me.voiceChannel) returns message.channel.send (Sorry, I am already logged in to this guild.);

if (! args[0]) return message.channel.send (Sorry, please enter the URL of the video so that I can steal it and put it on voice chat.);

let validate = wait ytdl.validateURL (args[0])

if (! validate) return message.channel.send (Sorry, please enter a valid ** URL ** after the order. & # 39;);

leave info = wait ytdl.getInfo (args[0])


let data = ops.active.get (message.guild.id) || {};

if (! data.connection) data.connection = wait message.member.voiceChannel.join ()
if (! data.queue) data.queue = [];
data.guildID = message.guild.id;

data.queue.push ({
songTitle: info.title,
requestor: message.author.tag,
url: args[0],
advertChannel: message.channel.id
});

if (! data.dispatcher) playstream (client, ops, data);
other {

message.channel.send (`Added to queue: $ {info.title} | Requested by: $ {message.author.id}`);

}

ops.active.set (message.guild.id, data);

}

asynchronous function playstream (client, ops, data) {

client.channels.get (data.queue[0].announceChannel) .send (`Currently playing: $ {data.queue[0].songTitle} | Required by: $ {data.queue[0].requester} `);

data.dispatcher = wait data.connection.playstream (ytdl (data.queue[0].url, {filter: uniquement only}));
data.dispatcher.guildID = data.guildID;

data.dispatcher.once (& # 39; finish & # 39; function () {

finish (client, ops, this);
});
}
finish function (client, ops, dispatcher) {

let fetched = ops.active.get (dispatcher.guildID);

fetched.queue.shift ();

if (fetched.queue.length> 0) {

ops.active.set (dispatcher.guildID, retrieved);

playstream (client, ops, recovered);
} other {

ops.active.delete (dispatcher.guildID);

let vc = client.get (dispatcher.guildID) .me.voiceChannel;
if (vc) vc.leave ();
}

}

javascript – Infinite scrolling fires multiple times

I have been looking for other answers on the same subject, but I still can not find a solution explaining why the event is triggered several times in my code:

        (function ($, Drupal, drupalSettings) {
Drupal.behaviors.news = {
& # 39; attach: function (context) {

$ (". loader"). hide ();
var loadIndex = 0;
var isLoading = false;

$ (window) .scroll (function () {
if (! isLoading) {
var footerHight = $ (document) .height () - $ (window) .height () - $ ("# myFooter"). height ();
if ($ (window) .scrollTop ()> footerHight) {

isLoading = true;
loadIndex = loadIndex + 1;

$ (". loader"). show ();
$ .ajax ({
method: "GET",
url: & # 39; / load-news? startIndex = & # 39; + loadIndex,
success: function (result) {
console.log ("More loaded");
setTimeout (function () {
$ (". loader"). hide ();
onSuccess (result);
isLoading = false;
}, 1000);

}
});
}
}
})
}
};

var onSuccess = function (data) {
console.log (& # 39; SUCCESS & # 39;);
$ ("news-list-wrapper"). append (data);
};

}) (jQuery, Drupal, drupalSettings);

javascript – View regions with Google Geochart

Is it possible to display the grouped states according to their regions and a tooltip according to the region and not the state?
For example:

  • North Region -> Acre, Amapá, Amazonas, Pará, Rondônia, Roraima, Tocantins
  • South Region -> Paraná, Rio Grande do Sul, Santa Catarina

The northern region, once selected, would cover all the states listed and a unique description.

I used this code for states, however, I could not remove something about my doubt from API.

google.load ('visualization', '1', {
"Packages": ['geochart']
    });

google.charts.setOnLoadCallback (drawRegionsMap);

drawRegionsMap () {function
var data = google.visualization.arrayToDataTable ([
            ['Region','Views'],
            ['Acre', 0],
            ['Alagoas', 1],
            ['Amapá', 2],
            ['Amazonas', 3],
            ['Bahia', 4],
            ['Ceará', 1],
            ['Distrito Federal', 2],
            ['Espírito Santo', 3],
            ['Goiás', 0],
            ['Maranhão', 5],
            ['Mato Grosso', 0],
            ['Mato Grosso do Sul', 1],
            ['Minas Gerais', 2],
            ['Pará', 3],
            ['Paraíba', 4],
            ['Paraná', 3],
            ['Pernambuco', 2],
            ['Piauí', 4],
            ['Rio de Janeiro', 1],
            ['Rio Grande do Norte', 0],
            ['Rio Grande do Sul', 1],
            ['Rondônia', 5],
            ['Roraima', 2],
            ['Santa Catarina', 4],
            ['São Paulo', 3],
            ['Sergipe', 2],
            ['Tocantins', 0]
        ])

var options = {
region: & # 39;;
resolution: "provinces",
colorAxis: {
values: [0, 1, 2, 3, 4, 5],
colors ['red', 'black', 'purple', 'yellow', 'green', 'blue']
            }
datalessRegionColor: & # 39; transparent & # 39;
caption: "no & # 39;
};

var chart = new google.visualization.GeoChart (document.getElementById (& # 39; chart_div & # 39;));

chart.draw (data, options);
}

javascript – Open the document link in a new tab with another variable code

I have a document configured to display thank you code for 10 seconds, after which a document is attached to the Pardot download form.

The Pardot form is iFrame, which means that the document does not display in full screen. This document must be displayed in full screen while keeping my other time code.

Where do I put the code to open a new tab?

Here is the code involved.


iMacros / Javascript – How to expose the text box of recaptcha V2 in iframe?

I have a situation where I need to use 2Captcha to resolve recaptcha for the site, but recaptcha is exceptionally in its own setting. My normal .js that I use in imacros for firefox fails to expose the "text box" in which to paste the token result. I guess I just have to reference the frame, but I do not know how to do it because I'm just starting out with javascript and using a script for which I paid an encoder. I asked him but I do not think he's safe, or too busy maybe! The…

iMacros / Javascript – How to expose the text box of recaptcha V2 in iframe?

JavaScript – Video só tocar when football chegar em determinada Div

Estou desenvolvendo page shadow that em Apenas determinados texts times that I hear this complaint Fazer Com that o text does audio so come a tocar when the football chegar no text, and to make but or menos that football, to ensure não Tenha muito conhecimento em JavaScript for puderem give um Help piece CSSA Questão


Lorem ipsum dolor sit amet, consectetur adipiscing elit. The pleasure of consideration prevents annoying rejections. Unless it is a great pleasure, the needs of these symptoms, and they may have, there is to open the pleasures of this at another time, she is aware.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. The pleasure of consideration prevents annoying rejections. Unless it is a great pleasure, the needs of these symptoms, and they may have, there is to open the pleasures of this at another time, she is aware.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. The pleasure of consideration prevents annoying rejections. Unless it is a great pleasure, the needs of these symptoms, and they may have, there is to open the pleasures of this at another time, she is aware.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. The pleasure of consideration prevents annoying rejections. Unless it is a great pleasure, the needs of these symptoms, and they may have, there is to open the pleasures of this at another time, she is aware.

How to automatically click on the button of the page with a unique tag and a class name via Javascript

I'm currently trying to find a way to automatically click a button on a web page with a specific tag and class. I'm using Tampermonkey (Javascript user scripts) to achieve this. Here's an image of the CSS / HTML elements I need to interact with:

enter the description of the image here

The item and button I want to interact with are highlighted in the image above and contain the following HTML code:

  • I used the following items to try to click the console button, but to no avail:

    document.querySelector (& # 39; li data-v-29761082.list-item & # 39;)[0].Click on();
    

    The "data-v-29761082" section rejects me and I do not know how to embed these characters in the query selector. I tried to treat the whole name as a single label, but it did not work. I'm just trying to click on the button highlighted in the screen capture, but I'm still looking for a solution.

    Realistically, I'll probably need to use waitForkeyElements for the code to work automatically on the Tampermonkey page, but for now, I'm just looking for a way to click on the highlighted button here. above with the help of specific tag and class information. If there is another way to solve the problem (maybe different elements, etc.), that would be enough. Thank you in advance.