GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   javascript question, textbox space and carriage return added (https://gfy.com/showthread.php?t=1304855)

lezinterracial 10-19-2018 05:23 AM

javascript question, textbox space and carriage return added
 
javascript question, space and carriage return added to the output text.

I am working on a chrome extension that encodes text. But a space and carriage return are being added to the output. Anybody know why?

example
http://nicecamgirls.com/popup.htm

lezinterracial 10-19-2018 05:23 AM

my code
Code:

<body>
<script>

function encodeFunction() {
 var x;
 x = document.getElementById("inputtext").value;       
 if(document.getElementById('urlEncodecheck').checked){ 
    var encodex;
    encodex = encodeURIComponent(x);
 }
 if(document.getElementById('HTMLEncodecheck').checked){ 
    var encodex;
    encodex =  x.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
 }                                                         
 if(document.getElementById('hexencodecheck').checked){
    var s = unescape(encodeURIComponent(x))
    var encodex = ''
    for (var i = 0; i < s.length; i++) {
        encodex += "%" + s.charCodeAt(i).toString(16)
    }}
 if(document.getElementById('base64Encodecheck').checked){
    var encodex = '';
    encodex = window.btoa(x);
  }

  document.getElementById("outputttext").value = encodex;
 }
</script>

<h1>Encode</h1>

<form action="">
  <input type="radio" name="encodetype" id="urlEncodecheck" checked="checked" oninput="encodeFunction()">Url<br>
  <input type="radio" name="encodetype" id="base64Encodecheck" oninput="encodeFunction()">Base64<br>
  <input type="radio" name="encodetype" id="HTMLEncodecheck" oninput="encodeFunction()">HTML<br>
  <input type="radio" name="encodetype" id="hexencodecheck" oninput="encodeFunction()">Hex
<h2>Input</h2>
<textarea id="inputtext" rows="4" cols="50" oninput="encodeFunction()" autofocus>
 
</textarea>
<h2>Output</h2>
<textarea id="outputttext" rows="4" cols="50" readonly>
</textarea>
</body>


sarettah 10-19-2018 07:35 AM

The extra shit is coming from your textarea. The way you coded the textarea puts spaces and the line feed in there. Just put the textarea close right up against the open and the extra shit should go away.


<textarea id="inputtext" rows="4" cols="50" oninput="encodeFunction()" autofocus></textarea>


.

CurrentlySober 10-19-2018 07:41 AM

i%20like%20poo%20%0A

aSBsaWtlIHBvbyAK

i like poo

%69%20%6c%69%6b%65%20%70%6f%6f%20%a

sarettah 10-19-2018 08:26 AM

Quote:

Originally Posted by sarettah (Post 22352281)
The extra shit is coming from your textarea. The way you coded the textarea puts spaces and the line feed in there. Just put the textarea close right up against the open and the extra shit should go away.


<textarea id="inputtext" rows="4" cols="50" oninput="encodeFunction()" autofocus></textarea>


BTW, if any one cares. "extra shit" is the technical term for that extra shit :thumbsup

.

lezinterracial 10-19-2018 08:41 AM

Quote:

Originally Posted by sarettah (Post 22352281)
The extra shit is coming from your textarea. The way you coded the textarea puts spaces and the line feed in there. Just put the textarea close right up against the open and the extra shit should go away.


<textarea id="inputtext" rows="4" cols="50" oninput="encodeFunction()" autofocus></textarea>


.

You are awesome sarettah. I really should have seen that.

sarettah 10-19-2018 08:48 PM

Quote:

Originally Posted by lezinterracial (Post 22352310)
You are awesome sarettah. I really should have seen that.

One of those dumb mistakes that we all make.

I spent a couple of hours the other day tracking down an issue. Turned out to be an errant semi colon.

File it under things that make me go: "Duh".

;p

.


All times are GMT -7. The time now is 12:32 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123