Simplified JavaScript code to use single quotes for XML code generation, so that double quotes within text don't need escape.

pull/16/head
Project Nayuki 7 years ago
parent d785ecb598
commit ac10dc21ce

@ -208,11 +208,11 @@ var qrcodegen = new function() {
this.toSvgString = function(border) { this.toSvgString = function(border) {
if (border < 0) if (border < 0)
throw "Border must be non-negative"; throw "Border must be non-negative";
var result = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; var result = '<?xml version="1.0" encoding="UTF-8"?>\n';
result += "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"; result += '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n';
result += "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 " + (size + border * 2) + " " + (size + border * 2) + "\" stroke=\"none\">\n"; result += '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 ' + (size + border * 2) + ' ' + (size + border * 2) + '" stroke="none">\n';
result += "\t<rect width=\"100%\" height=\"100%\" fill=\"#FFFFFF\"/>\n"; result += '\t<rect width="100%" height="100%" fill="#FFFFFF"/>\n';
result += "\t<path d=\""; result += '\t<path d="';
var head = true; var head = true;
for (var y = -border; y < size + border; y++) { for (var y = -border; y < size + border; y++) {
for (var x = -border; x < size + border; x++) { for (var x = -border; x < size + border; x++) {
@ -225,8 +225,8 @@ var qrcodegen = new function() {
} }
} }
} }
result += "\" fill=\"#000000\"/>\n"; result += '" fill="#000000"/>\n';
result += "</svg>\n"; result += '</svg>\n';
return result; return result;
}; };

Loading…
Cancel
Save