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

This commit is contained in:
Project Nayuki 2017-07-26 20:38:34 +00:00
parent d785ecb598
commit ac10dc21ce
1 changed files with 7 additions and 7 deletions

View File

@ -208,11 +208,11 @@ var qrcodegen = new function() {
this.toSvgString = function(border) {
if (border < 0)
throw "Border must be non-negative";
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 += "<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<path d=\"";
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 += '<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<path d="';
var head = true;
for (var y = -border; y < size + border; y++) {
for (var x = -border; x < size + border; x++) {
@ -225,8 +225,8 @@ var qrcodegen = new function() {
}
}
}
result += "\" fill=\"#000000\"/>\n";
result += "</svg>\n";
result += '" fill="#000000"/>\n';
result += '</svg>\n';
return result;
};