r/JavaScriptHelp • • Dec 05 '20

❔ Unanswered ❔ Tabbing to next input in a form where there are extra buttons in the <form>

1 Upvotes

I have a form that, give or take, looks like this

<form>

<input type="password" />

<button>Show</button>

<input type="password" />

</form>

Basically, there are two password inputs and a button (which in reality is positioned absolute inside of the input). The button can toggle (show/hide) the password.

When using tab to jump from input #1 to input #2, the first time you hit tab it focuses on the button rather than going to input.

Is there a property on the button I'm missing that will "take it out of the form", so that it doesn't recognize the button as a form input that can be tabbed to?


r/JavaScriptHelp • • Dec 02 '20

❔ Unanswered ❔ Javascript code for button to remove content from html as it loads?

1 Upvotes

There's a website that I want to google translate using Chrome, but the creator has added <meta name="google" content="notranslate"/> to the html. This prevents Chrome from popping up asking if it can autotranslate the page. I can inspect the element and remove it, but Chrome won't pop up because it only does so when the page loads. Can I get around this with javascript? I've seen it done for other purposes with a bookmark saved on the bookmarks bar, but I can't figure out how to adapt it here. Thanks.


r/JavaScriptHelp • • Nov 30 '20

❔ Unanswered ❔ I am getting node:17200 error when I am trying to place market order using node-binance-api?

1 Upvotes

I am getting mysterious error when I try to place a market order using node-binance-api by using the following function, any suggestion is greatly appreciated!

const Binance = require(’…/node-binance-api’);const binance = new Binance().options({APIKEY: ‘------’,APISECRET: ‘----------’,useServerTime: true

});binance.buy(“BNBUSDT”, 0.3, 0, “MARKET”)

the error I am getting is:(node:17200) UnhandledPromiseRejectionWarning: #(node:17200) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)(node:17200) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


r/JavaScriptHelp • • Nov 20 '20

❔ Unanswered ❔ Why does my code not execute?

1 Upvotes

Hello!

I tried to implement a code with Webflow. This added a <script> tag to my webpage with the following code, but it doesn't execute anything at all. I also dont get any error messages. I would appreciate some help.

<script rel="preload" type="text/javascript" src="https://code.jquery.com/jquery-1.10.0.min.js">

  $(function(){
    console.log("hello");
    var userLang = navigator.language || navigator.userLanguage;
  alert(userLang);
  alert('Hello');
    if (userLang == "en") {
        window.location.ref = "https://www.XXX.ch/en";
    }
  else if (userLang == "fr") {
        window.location.ref = "https://www.XXX.ch/fr";
    }
  else if (userLang == "it") {
        window.location.ref = "https://www.XXX.ch/it";
    }
    else {
        window.location.href = "https://www.XXX.ch";
    }

  });
</script>

r/JavaScriptHelp • • Nov 20 '20

❔ Unanswered ❔ Is there a free video surveillance web server with API for js applications?

1 Upvotes

I would like to buy a computer and cameras, and install a ready-made server on it. I'll write the client myself.

It is necessary to have recognition of movement and faces

I will also consider paid options, but I wonder if there are free and good ones or maybe there are cameras that are sold with a ready-made web server? Even a complete video set, but for everything to work offline.

The server distributes its wifi, and the client connects from a mobile browser


r/JavaScriptHelp • • Nov 08 '20

❔ Unanswered ❔ I need help combining Math.random()

1 Upvotes
package lotterynumbergenerator;

/**
 *
 * @author ismai
 */
public class NumberGenerator {
    
    public int winningNumbers(int min, int max) {
        double rand = Math.random();
        double rand1 = Math.random();
        double rand2 = Math.random();
        double rand3 = Math.random();
        double rand4 = Math.random();
        double rand5 = Math.random();
    
        
        int randomNum = (int) (rand * (max - min + 1)) + min;
        int randomNum1 = (int) (rand1 * (max - min + 1)) + min;
        int randomNum2 = (int) (rand2 * (max - min + 1)) + min;
        int randomNum3 = (int) (rand3 * (max - min + 1)) + min;
        int randomNum4 = (int) (rand4 * (max - min + 1)) + min;
        int randomNum5 = (int) (rand5 * (max - min + 1)) + min;
    
return randomNum;
    }

In an instant Instead of only returning the one randomNum, I want to return all 6 random's. Can someone help me do this!


r/JavaScriptHelp • • Nov 06 '20

❔ Unanswered ❔ I want to code my table top game

1 Upvotes

I’ve learned a lot of the basics for JavaScript but still don’t know really where to begin. I want to practice things that will be relevant to my goal: a turn based strategy game.

I already have the game designed as a dice and paper game, but now that I know how variables, objects, functions etc... work, what do I do?


r/JavaScriptHelp • • Oct 22 '20

❔ Unanswered ❔ Help writing working backend Code

1 Upvotes

Hi, I'd say I'm an intermediate level coder at best. To be more specific, I'd like to know if anyone is interested in helping me with my code via Zoom calls where I can screen share problem code. I'm not always the best at explaining my issues and having someone to actively talk through my problems with would tremendously help me.

A little background info is that I'm writing a program in a swift environment using Firebase for my backend and database. I'm having difficulty writing my backend functions in Javascript and debugging them. Ideally, some background with swift would probably benefit but I can provide much more details to anyone interested in helping me with my learning curve.


r/JavaScriptHelp • • Oct 21 '20

❔ Unanswered ❔ What is this code doing exactly?

1 Upvotes

Hello all, so this code is actually in TypeScript, but I’m having trouble understanding exactly what its doing. I understand that the output works nicely and that you can drag and drop elements by the mouse in the list. That's all what it looks like it’s doing. However maybe it’s because I mainly code in Python and haven’t touched JavaScript in a long while that I’m not fully understanding this like I should. Any help/advice is greatly appreciated!

https://imgur.com/a/51Rn3FW

Here’s all the code in JSFiddle so that it’s easier to see: https://jsfiddle.net/AriannaC/x71f0srn/2/ However I get an error when running it here when I shouldn’t


r/JavaScriptHelp • • Oct 18 '20

⚠️ Moderator ⚠️ Post flair clarification

1 Upvotes

Hey all, just to quickly clarify something the advice flair is when you are offering advice to people and unanswered is when you're asking something.

Please remember to set the flair as answered when you get answers.


r/JavaScriptHelp • • Dec 14 '18

Jquery string filter help

1 Upvotes
<div class='myDiv'>
    <table summary='Bulk Tracking'>
      <span title='Bulk Tracking'>Bulk Tracking</span>
      
      <tr>
        <td>IL</td>
        <td>NR</td>
        <td><span class='ms-nowrap'>12/1/2018</span></td>
        <td>65</td>
        <td class='lastCell'>Waiting For</td>
      </tr>
      <tr>
        <td>TX</td>
        <td>FT</td>
        <td><span class='ms-nowrap'>12/9/2018</span></td>
        <td>22</td>
        <td class='lastCell'>Waiting For</td>
      </tr>
      <tr>
        <td>WY</td>
        <td>ND</td>
        <td><span class='ms-nowrap'>12/25/2018</span></td>
        <td>721</td>
        <td class='lastCell'>Waiting For</td>
      </tr>
      <tr>
        <td>MT</td>
        <td>NR</td>
        <td><span class='ms-nowrap'>12/7/2018</span></td>
        <td>33</td>
        <td class='lastCell'>Waiting For</td>
      </tr>
      <tr>
        <td>AK</td>
        <td>LR</td>
        <td><span class='ms-nowrap'>12/7/2018</span></td>
        <td>222</td>
        <td class='lastCell'>Waiting For</td>
      </tr>
      <tr>
        <td>VA</td>
        <td>ARR</td>
        <td><span class='ms-nowrap'>12/8/2018</span></td>
        <td>15</td>
        <td class='lastCell'>Received</td>
      </tr>
    </table>
    </div>

HTML

$(document).ready(function() {
    addTargetClasses();
    checkReceived();
});
(function($) {
    $(function() {
        var orgDates = $('table tr td span');

        var message = '';
        orgDates.each(function(i, elem) {

            parts = $(this).text().split('/');
            dt = new Date(parts[2], parts[0] - 1, parts[1])
                .getTime();
            diffdate = Math.floor((dt - new Date().getTime()) /
                (86400 * 1000));

            if (diffdate === 0 || diffdate === -1) {
                return;
            }
            if (diffdate > 0 || $(this).parents(
                    'tr.targetRow').find('lastCell').hasClass(
                    'crossout')) {
                return;
            }

            if ((diffdate + 2) < 1) {
                if (diffdate.length == 1) {
                    console.log(diffdate);
                }
                if ((diffdate + 2) == 0) {
                    diffdate = (diffdate + 1) + ' day ago';
                } else {
                    diffdate = (diffdate + 1) + ' days ago';
                }
            }

            diffdate = diffdate.toString().slice(1);



            state = $(elem).parents(
                '.targetTable tr.targetRow').find(
                "td:nth-child(2)").text();
            mailType = $(elem).parents(
                '.targetTable tr.targetRow').find(
                " td:nth-child(4)").text();

            message += state + ' ' + mailType + ' was due ' +
                diffdate + '<br/>';
        });

        $.alert({
            theme: "my-theme",

            title: "<span style='font-size:25px;'>" +
                "</span>",
            content: "The following bulk is past the expected received date:" +
                "<br/>" + "<br/>" + message,
            draggable: true,
            animationBounce: 1.5,
            buttons: {
                Dismiss: function() {}
            }
        });

        $('span[title*="Bulk Tracking"]').after(
            "<button id='alert_btn' type='button'>See Alerts</button>"
        );
        $('#alert_btn').after(
            '<div id="emmacontainer" class="emmacontainer"><div class="container__inner"><div class="subDiv"></div> </div></div>'
        );

        $('.subDiv').append(message);

        $('#emmacontainer').hide();
        $('#alert_btn').click(function() {
            $('#emmacontainer').slideToggle(400);
        });


    })
})
(jQuery);

function addTargetClasses() {
    $("table[summary*='Bulk'] ").addClass("targetTable");
    $(".targetTable tr").addClass("targetRow");
}

function checkReceived() {
    $('.targetTable td.lastCell:contains("Received")').addClass('crossout');
};

JS

Currently when I run this code I get this output:

IL NR was due 13 days ago
TX FT was due 5 days ago
MT NR was due 7 days ago
AK LR was due 7 days ago
VA ARR was due 6 days ago

This is correct but I'm looking for a way to combine lines that have the same number of 'days ago'.

So I want something like this:

IL NR was due 13 days ago
TX FT was due 5 days ago
MT NR and AK LR were due 7 days ago
VA ARR was due 6 days ago

Does anyone have any ideas or can point me in the right direction?


r/JavaScriptHelp • • Dec 06 '18

Importing JSON object variables into SCSS

1 Upvotes

I have a JSON with all my colors for my app in it (like a theme), these can be changed depending on the user outside of the app. I know I can get the JSON and store it in a variable and use this inline styled in the html, but I think a better way would have it imported and used in my scss files. Any ideas on how this could be done?

Example of the JSON:

{

"colors":{

"primary":"#4286f4",

"secondary":"#ffffff",

"accent":"#ef0000"

},

"graphics":{

"login-bg":"/img/login.png",

"logo":"/img/logo.png"

}

}

Example of how I have it working now:

<button class="primary-btn" [style]="background-color: theme['colors']['primary'] ? theme['colors']['primary'] : ''">I'm a button</button>

Example of where I'd want it in my styles.scss:

.primary-btn {

background-color: theme['colors']['primary']

}


r/JavaScriptHelp • • Nov 29 '18

Setting up environment for javascript

1 Upvotes

Setting up environment with the right tools is the very first step towards great development, which i am trying to explain in this video -

https://www.youtube.com/watch?v=c_bdXjLOwL0

https://medium.com/…/environment-setup-for-javascript-62a03…

Please suggest me your thoughts, hope you will learn something new 😃.


r/JavaScriptHelp • • Nov 21 '18

Help finding max of arrays

1 Upvotes

Hello, for some reason this might be super simple (and I'm sure it is) but I can't seem to have something that actually works as I want it to : Here's what I wan't to do :

let T = [[-5,8,-4],[5,-3,15],[1,11,-4]]; //random numbers for example
let tabPG=[];
tabPG.push(Math.max.apply(Math, T.map((i)=>i[0])));
console.log(tabPG);

This outputs me [5] as you would expect. Here's the thing, I would like to get rid of that '0' for something that would output me [5,8,15]. Been struggling for some hours somehow so I'd like to know how to do it, or at least get some hints.

Thank you for your time ! :)


r/JavaScriptHelp • • Nov 16 '18

It’s super simple but I need help

1 Upvotes

<!doctype html>

<!-- lab8.html by Mei —> <!-- Lab8.html displays a countdown from a specified number -->

<html><head> <title> Lab8 </title>

<script type "text/javascript"> Function countdown() // Assumes: countBox contains a non-negative integer // Results: displays a countdown from that number in outputDiv {//start function block var count; count=parseFloat(document.getElementById(('countBox').value); var result: '' ; while (count > 0) { //start while loop result = result + count + '<BR>'; count = count -1; } //close while loop document.getElementByld('outputDiv').innerHTML =result + 'BLASTOFF!’; } //close function block </script>

</head>

<body bgcclor: “#FFF0F5”> <h2> Lab8 displays a countdown from a specified number </h2>

<p> Start of the countdown: <input type=“text” id=“countBox” size=4 value=""> </p> <input type="button" value="Begin Countdown" onclick="countdown();" /> <hr /> <div id="outputDiv"></div> </body> </html>


r/JavaScriptHelp • • Nov 15 '18

Can you help me with my javascript issue

1 Upvotes

I want a javascript injection for swagbucks.com Home page where you check your sb I want to locally manipulate the website and increase my swagpoints if you have ever used this website before you will know what I am talking about

This is an amazing website for earning a bit more here is the link you will enjoy it

http://www.swagbucks.com/p/register?rb=48607558


r/JavaScriptHelp • • Nov 07 '18

Using a variable for multidimensional arrays

1 Upvotes

Please keep in mind I am NOT a javascripter. Javascript is difficult for me to understand, but I am trying.

I have this webform that HR uses on our intranet server.

I made it so HR can quickly add in new hires. The submissions are fed into a sql database, where I have an automated script take care of all the repetitive tasks (ie. add to Active Directory, assign licenses, phone numbers, etc)

HR asked me to add in a field for distribution groups. Some new hires need to be put into select email lists and it's not always consistent, so scripting it would be difficult.

The site can add more than one row of all these fields (First name, last name, title, department, notes, etc) in the event there is more than one hire. Clicking submit sends all that stuff into my sql server. This is done by javascript. For brevity, the html variable is cut down to what i need fixed:

$(document).ready(function() {


var html = '<div class="cell" align="justify"><select name="emaillist[???][]" id="emaillist" style="width:200px; padding: 5px; vertical-align: -38px;" size="3" 
multiple><option value="b792a010-f6d1-47ff-a43b-775e71220142">A&A Managers</option><option value="85d59de6-2924-4741-ac70-7b0a9894ba32">A&A 
Partners</option><option value="dd177d82-6d5c-4279-820f-4ca0b0309b1d">A&A Staff</option><option value="b91d4aba-7fe4-4d6d-96b5- 
fc539c1216d1">BEST</option></select></div><div class="cell" align="center"><input type="text" name=notes[]" size="20" id="notes" 
style="width:350px"></div><div class="cell" align="center" style="width:39px"><input class="redbutton" type="button" id="remove" value=" - "></div> 
 </div></div>';


$("#add").click(function(e) {
    $("#added_fields").append(html);
});

$("#added_fields").on("click","#remove",function(e) {
    $(this).parent().parent().parent().remove();
});
});

The html field is this:

<select name="emaillist[0][]" id="emaillist" style="width:200px; padding: 5px" size="1" multiple>
            <option value="b792a010-f6d1-47ff-a43b-775e712">A&A Managers</option>
            <option value="85d59de6-2924-4741-ac70-7b0a989">A&A Partners</option>
            <option value="dd177d82-6d5c-4279-820f-4ca0b03">A&A Staff</option>
            <option value="b91d4aba-7fe4-4d6d-96b5-fc539c12">BEST</option>
        </select></div>

The results get fed into sql. This all works fine and dandy if manually declare the array with numbers eg: emaillist[0][]; emaillist[1][], etc

but since HR can dynamically add or remove rows; is there a way I can input a variable when I add another column?

so it can be something like this:

var html = '<div class="cell" align="justify"><select name="emaillist[$X+1][]" id="emaillist" style="width:200px; padding: 5 etc...

where $x is a variable that starts at 0 and keeps a counter? I can do something like this in bash or powershell but javascript has me at so many losses.


r/JavaScriptHelp • • Oct 31 '18

localStorage JavaScript

1 Upvotes

I am trying to create a quiz using localStorage and let the user be able to retrieve the quiz made so that they will be able to take the quiz. I am stuck on how to show the results of the quiz which must include the grade earned on the quiz, the answers entered by the user and whether the question answered was correct or incorrect and the correct answers. I am stuck on how to retrieve the answers.

Here's a link to my github.

function nextQue(){

if (getQuestion[i] == null) {

//get answers and scores

}

else {

queNo.innerText="Question No "+ getQuestion[i].qId;

question.innerText=getQuestion[i].quest;

if(getQuestion[i].qType==="multi"){

forMulti.style.display="block";

forRad.style.display="none";

forShort.style.display="none";

lblCheckBox1.innerHTML=" "+getQuestion[i].choice1;

lblCheckBox2.innerHTML=" "+getQuestion[i].choice2;

lblCheckBox3.innerHTML=" "+getQuestion[i].choice3;

lblCheckBox4.innerHTML=" "+getQuestion[i].correctAnswer;

chkBox1.value=getQuestion[i].choice1;

chkBox2.value=getQuestion[i].choice2;

chkBox3.value=getQuestion[i].choice3;

chkBox4.value=getQuestion[i].correctAnswer;

i++;

}

else if(getQuestion[i].qType==="radio"){

forMulti.style.display="none";

forRad.style.display="block";

forShort.style.display="none";

i++;

}

else if(getQuestion[i].qType==="short"){

forMulti.style.display="none";

forRad.style.display="none";

forShort.style.display="block";

i++;

}

}

}


r/JavaScriptHelp • • Oct 22 '18

JavaScript not running right?

1 Upvotes

HTML file:

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title></title>

<link rel="stylesheet" href="styles.css">

<script src="script.js"></script>

</head>

<body>

<canvas id="mainCanvas" style="border:1px solid #d3d3d3">nope...</canvas>

</body>

</html>

JavaScript file:

document.write("Hello world.");

var mainCanvas = document.getElementById("mainCanvas");

var c = mainCanvas.getContext("2d");

c.width = 800;

c.height = 900;

c.beginPath();

c.lineWidth = "1";

c.strokeStyle = "red";

c.rect(10, 10, 110, 100);

c.stroke();

Problem:

I see the canvas. I see the &quot;Hello world.&quot; But I don&#39;t see the red box (this box is just for testing right now). BUT!!! If I put my JavaScript code in the HTML file insice a &lt;script&gt;&lt;/script&gt; then I get the red box. So what am I doing wrong?


r/JavaScriptHelp • • Aug 23 '18

While loop freezes browser

1 Upvotes

Hey all. Fairly simple problem for you here. I just want to know any alternatives to the while loop with this code:

// This document has been nominated for the "Least Efficent Javascript of The Year" award

$(document).ready(function(){
  while (true) {
    $("#s1").delay("slow").fadeIn();
      setTimeout(function(){
        $("#s1").delay("slow").fadeOut();
      }, 3000);

      setTimeout(function() {
        $("#s2").delay("slow").fadeIn();
          setTimeout(function(){
            $("#s2").delay("slow").fadeOut();
          }, 3000);
      }, 4000);

      setTimeout(function() {
        $("#s3").delay("slow").fadeIn();
          setTimeout(function(){
            $("#s3").delay("slow").fadeOut();
          }, 3000);
      }, 8000);

      setTimeout(function() {
        $("#s4").delay("slow").fadeIn();
          setTimeout(function(){
            $("#s4").delay("slow").fadeOut();
          }, 3000);
      }, 12000);

      setTimeout(function() {
        $("#s5").delay("slow").fadeIn();
          setTimeout(function(){
            $("#s5").delay("slow").fadeOut();
          }, 3000);
      }, 16000);

      setTimeout(function() {
        $("#s6").delay("slow").fadeIn();
          setTimeout(function(){
            $("#s6").delay("slow").fadeOut();
          }, 3000);
      }, 20000);

      setTimeout(function() {
        $("#s7").delay("slow").fadeIn();
          setTimeout(function(){
            $("#s7").delay("slow").fadeOut();
          }, 3000);
      }, 24000);
    }
});

I know it's pretty ineffecient right now. Sorry for the mess.


r/JavaScriptHelp • • Jul 28 '18

Need help figuring out wheres waldo

1 Upvotes

Waldo is hiding in some strings.

You've been given a string named waldoString. Waldo will be hiding in it somewhere. Return the index of where in the string 'Waldo' starts.

function findWaldo(str) {

var waldoPosition;

// Code below here

return waldoPosition; }

I've been stuck on here for about an hour and I've tried many inputs. I feel like I'm missing something very simple but I can't get my head straight on this problem.


r/JavaScriptHelp • • Jun 14 '18

javascript API response problem

1 Upvotes
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
//create API REQUEST
var xhr = new XMLHttpRequest();

xhr.onreadystatechange = function(){

//CHECKING STATUS CODE
if(this.readyState == 4 && this.status == 200){

//PARSING JSON DATA
var data = JSON.parse(this.responseText);

//LOOPING THROUGH DATA
for(var key in data){

//add the looped items to variable
var items = data[key];

var tablerow = document.createElement("tr");
var tabledetail1 = document.createElement("td");
var tabledetail2 = document.createElement("td");
var tabledetail3 = document.createElement("td");

// add CSS id to tabe row
tablerow.id = 'tablerow';

// add CSS id to tabledetail
tabledetail1.id='tabledetail1';

//get image url from object
var imgurl = items.image.small;

//create image element
var img = document.createElement('img');

//inject url into img src
img.src = imgurl;

//add id for styling
img.id ='img';

//add detail to row
tablerow.appendChild(tabledetail1);
tablerow.appendChild(tabledetail2);
tablerow.appendChild(tabledetail3);

//add img to table detail
tabledetail1.appendChild(img);

//get all coin id's
var id = document.createTextNode(items.id);

//append id to table detail
tabledetail2.appendChild(id);

//get price
var price = document.createTextNode(items.market_data.current_price.btc);

//apply price to tableheading1
tabledetail3.appendChild(price);

//append table row to table in document
document.getElementById('box').appendChild(tablerow);

}

}

}

//DEFINING GET REQUEST WITH URL
xhr.open('GET','https://api.coingecko.com/api/v3/coins?per_page=1977');
//SEND REQUEST
xhr.send();

</script>
<table id='box'></table>
</body>
</html>

/* THIS IS THE CODE THAT IS SUPPOSE TO RETRIEVE ALL 250 IMAGES FROM THE COINS VIA THE XMLHttpRequest but i am only getting from 0-99 images only for some reason all the images seem to be there when i inspect the response in the console but cant seem to access all of the images with the 'for in' loop */


r/JavaScriptHelp • • Jun 13 '18

Converting pure JS to JQuery

1 Upvotes

Here is the Fiddle

Here is what I have already and it’s not working and I’m stuck:

checkboxes = document.getElementsByName('aliases[]');
$(document).ready(function() {
 $("#domain").change(function() {
	$(checkboxes).each( function( index, element ){
       if ($(this).val() == $(sel).value) {
			$(this).prop("disabled", true);
		} else {
			$(this).prop("disabled", false);
		}
   });
 });
});

r/JavaScriptHelp • • Jun 12 '18

Looking for help with Javascript and CSS

1 Upvotes

Just wondering what the basic JS code would be that when you fill out a single field in an online form, the JS would post whatever's in that field on another web page and next to it insert a little NEW icon with a green background.


r/JavaScriptHelp • • Jun 05 '18

Replacing br with newline in this JS

1 Upvotes

https://pastebin.com/SvMRj9cQ

I added line 8 and also tried

aux.setAttribute("value", document.getElementById(elementId).innerHTML.replace(/<br\s*[\/]?>/gi, "\n"));