Author

Topic: [DONE] Paying .1 BTC for simple Javascript fix (Read 798 times)

newbie
Activity: 14
Merit: 0
cool glad you got it fixed!
member
Activity: 119
Merit: 100
BitcoinMoxy.com
Streamlined our QR Code generator some more by replacing the textarea input field with a proper input field and ensured cross-browser compatibility.

Figured this one out all by myself (I'm so proud...)


The input field is autofocused, so loading the page and hitting CTRL-V and ENTER will now generate the QR-code just like snapping your fingers.

Note: This works for any altcoins, too!


BitcoinMoxy.com

member
Activity: 119
Merit: 100
BitcoinMoxy.com
So your problems completly fixed? Dont need any more help?

I'll keep you updated soon. (I take it that's an offer for help.)




newbie
Activity: 42
Merit: 0
So your problems completly fixed? Dont need any more help?
legendary
Activity: 1876
Merit: 1295
DiceSites.com owner
Got the payment, thanks. Good luck with your website Smiley
member
Activity: 119
Merit: 100
BitcoinMoxy.com
Thank you very much.

Your input has been invaluable! Payment sent using your code.

 Cool

BitcoinMoxy.com


newbie
Activity: 6
Merit: 0
Gotta love QR!
member
Activity: 119
Merit: 100
BitcoinMoxy.com
Hold on. Let me have a look at this.



legendary
Activity: 1876
Merit: 1295
DiceSites.com owner
Yeh I forget there was an "else". The problem: first it checks for length, if it's only 15 characters it will show error, but then it will go to the next "if" and if it has correct characters it will go to the "else" and show the QR code even though it's less than 25 characters.


You could combine this:
Code:
if (text.length < 25) {
document.getElementById('qr').innerHTML = create_qrcode(error);
}

if(text.match(/[^123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+/g)) {
document.getElementById('qr').innerHTML = create_qrcode(error);
}
to:
Code:
if (text.length < 25 || text.match(/[^123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+/g)) {
document.getElementById('qr').innerHTML = create_qrcode(error);
}

This should work, you can test it also here: http://jsfiddle.net/J325A/ (you can modify the "text" to invalid address then run again.)

member
Activity: 119
Merit: 100
BitcoinMoxy.com
Thanks for the contribution, solution #1 looks perfectly good to me but it doesn't work the way I want it to work.
I've been trying the code, rewriting it a little, etc. but it keeps doing what it wants.
Sometimes it works, sometimes it doesn't. (Programming languages just don't come natural to me).

What I want it to do is this:

- create a QR code with a default error message in the QR as defined in var error whenever the input
      -is less than 25 characters in length
      -has any non-BASE58 characters in it

else, create the QR for a valid Bitcoin (or any altcoin address) using create_qrcode(text).

Make me a quote for payment along with the solution (but stay within reason, please).


Here's the code in qrconf.js after trying out different things (the original one is still up on the site):

Code:
var draw_qrcode = function(text, typeNumber, errorCorrectLevel) {
document.write(create_qrcode(text, typeNumber, errorCorrectLevel) );
};

var error = "Try Again!";
var text = document.forms[0].elements['msg'].value;

var create_qrcode = function(text, typeNumber, errorCorrectLevel, table) {

var qr = qrcode(typeNumber || 4, errorCorrectLevel || 'H');
qr.addData(text);
qr.make();

// return qr.createTableTag();
return qr.createImgTag();
};


var update_qrcode = function() {
var text = document.forms[0].elements['msg'].value;

if (text.length < 25) {
document.getElementById('qr').innerHTML = create_qrcode(error);
}

if(text.match(/[^123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+/g)) {
document.getElementById('qr').innerHTML = create_qrcode(error);
}

else {
document.getElementById('qr').innerHTML = create_qrcode(text);

};


};



I don't get why it doesn't work.. what am I doing wrong?

Thanks in advance

legendary
Activity: 1876
Merit: 1295
DiceSites.com owner
In qrconf.jf

Add the following:
Code:
if(text.match(/[^123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+/g)) {
document.getElementById('qr').innerHTML = create_qrcode('Error!');
}
after:
Code:
replace(/^[\s\u3000]+|[\s\u3000]+$/g, '');
on a new line.

OR

I would personally prefer to just remove all the non bitcoin address characters from the input instead of showing an error. For that, replace:
Code:
replace(/^[\s\u3000]+|[\s\u3000]+$/g, '');
with:
Code:
replace(/[^123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+/g, '');


Bitcoin address for tip is in signature Wink
member
Activity: 119
Merit: 100
BitcoinMoxy.com
Looking for a small enhancement to our QR code generator (Javascript) on BitcoinMoxy.com

I invite you to have a look at the related code in the .js scripts and the form at the beginning of the document body (index.html).

The generator works great so far and upon entering any value deviating from the valid character count in a Bitcoin address (25-34 chars), it defaults to a generic error msg in the QR code.

I want to extend this to show the same error qr-code whenever the user enters any non-alphanumeric characters (i.e. spaces, punctuation, etc.; valid input doesn't HAVE to be limited to BASE58, but would be really cool. [BTC addresses use BASE58 characters only]).

If there's anybody with some spare minutes to spend on this, you'll make my day!

Reply in the comments or PM me.

Payment: .1 BTC.

Jump to: