canvasTest.js 623 B

123456789101112131415161718192021222324252627282930
  1. var parent;
  2. function doTests(p){
  3. parent = p;
  4. createTests(newTest);
  5. }
  6. function newTest(text, options){
  7. var testbox = document.createElement("div");
  8. testbox.className = "testbox";
  9. var format = (typeof options !== "undefined" && options.format) || "auto";
  10. testbox.innerHTML = '\
  11. <b>Format:</b> ' + format + '<br>\
  12. <b>Input:</b> ' + text + '<br>\
  13. <br>\
  14. <img class="barcode"/>';
  15. try{
  16. JsBarcode(testbox.querySelector('.barcode'), text, options);
  17. }
  18. catch(e){
  19. testbox.className = "errorbox";
  20. testbox.onclick = function(){
  21. throw e;
  22. }
  23. }
  24. parent.appendChild(testbox);
  25. }