-
Notifications
You must be signed in to change notification settings - Fork 0
/
testron.min.js
2 lines (2 loc) · 29 KB
/
testron.min.js
1
2
/* 2016 (c) Juajo Guerra <dinertron@gmail.com> */
var testron={};!function(t){"use strict";function e(){return j}function n(t){j.push(t)}function s(t){if(0>t||t>j.length)return j;if(0===t)return j=1===j.length?[]:j.slice(1);var e=j.slice(0,t);return j=e.concat(j.slice(t+1))}function i(e){for(var n=0;n<j.length;n++)if(j[n].id===e.id)return t.removeTestIndex(n);return j}function r(){j=[]}function o(){var t=C[parseInt(Math.random()*C.length,10)].toLowerCase()+C[parseInt(Math.random()*C.length,10)].toUpperCase();return t+1e3*Math.random()+C[parseInt(Math.random()*C.length,10)].toUpperCase()}function a(t,e){return Math.round(t*Math.pow(10,e))/Math.pow(10,e)}function l(t,e){var n=parseFloat(a(t,e)+"");return n=(n+"").split("."),n.length>1&&(n[1]=h(n[1].split("").reverse().join(""),e).split("").reverse().join("")),n.join(".")}function h(t,e,n){if(isNaN(t)||2>e)return t;var s=(0>t?(t+"").substr(1):t)+"",i=0>t?"-":"",r=s.split("."),o=n&&0>t?1:0;e-=r.length>1?r[1].length+o:0;var a=e;do r[0].length<e&&(r[0]="0"+r[0]),a--;while(a>0);return i+r.join(".")}function c(e,n){n=n||{},e&&e.replace&&(e=JSON.parse(e));var s=["Guerratron Analizing with testron.parseTestrons() ... "];if(!e)return s.push("ERROR: 'testrons' object not exists!"),"ERROR::\n"+s.join("\n");if(e.testrons&&(e=e.testrons),!e||e.length<1)return s.push("ERROR: 'testrons' array not exists, or is empty!"),"ERROR::\n"+s.join("\n");t.resetTests();var i=0;for(var r in n)n.hasOwnProperty(r)&&i++;for(var o=0;o<e.length;o++){var a=e[o];(a&&a.conf||(s.push("WARNING: 'testrons.test["+o+"].conf' object not exists!"),i))&&(a.conf=T(a.conf,n),a.conf.container=u(a.conf.container,a.conf.remove),a.conf.markerContainer=u(a.conf.markerContainer,a.conf.markerRemove),a=new t.Test({testron:a}),a.update())}return t.getTests()}function u(t,e){return t?(!t.getAttribute&&t.replace&&(t=document.getElementById(t)),t?e&&(t.innerHTML=""):t=null):t=null,t}function p(){return{VER:"data:image/gif;base64,R0lGODlhCAAIAIABAAAAAP///yH5BAEKAAEALAAAAAAIAAgAAAINjGEZgIqtVjxTOsZqKgA7",GUERRATRON:"data:image/gif;base64,R0lGODlhEAAQAOMMABUQEL4aF38yEmZXVCRmmU9mHf9ERVqrLM2Ue/uUMpSwwvrKgP///////////////yH5BAEKAA8ALAAAAAAQABAAAARY8J1HZb31jIzx+SDQXUg4XuCnnFT6JfCydAdBHIAgxAhmEwpCIAAbLESV34+YAMyQD+VAMNT1oEGbYhAwdFfQKEABEBkezjD6QaYI2OuLaPXYPHqsvP4SAQA7",LOGO:"data:image/gif;base64,R0lGODlhEAAQAKECAAcJBOIeFP///////yH5BAEKAAIALAAAAAAQABAAAAI0lC8RyAeqQHMPAtmuVEIz/11HNHUctEwoWrJcmaQiPIPZ3OEUNqbI24toWMGApgI0JJW+AgA7",ADJUST:N+"njI9pwKDtAlNoyktd3G/1E1EeJoJhuZwlh54q9rKaOEtvtTWPjioFADs=",ADJUST1:N+"ljI9pwLodoItgxVkr0nvew2GWB4akdI5eaHaJmYkaqkBM++BkAQA7",ADJUST2:N+"rjI9pwIztQlQLLGmTy7a9fWFclH0QZZaoqFLQdIxy2MEehylgvpJn/FspCgA7",ADJUST3:N+"pjI9pwIztQlMrTnrBUlruD3ZJJ1JHZD5lSmLn83oyLF+chY64LUGpWQAAOw==",AXES:N+"mjANwy5ja1nvRJIcjvKge7n1QaI2lZp4MKCnTC8cyy4prmrU3GhYAOw==",AXES2:N+"sjAEWuKrITnMQPrcSi4merl1dhnnPiIVfyZIpupbR2W7Vjef6OL8UHKP5DAUAOw==",BROOM:N+"gjI+pywzQ0IMxzGpfnVRyrnxfKGpL2SVoJLKje2GmUgAAOw==",CLOSE:N+"njI9pwLodGEQSPEnrqTbqzGFKOI2cs50o2SVs6YlqXKof2IlmiyoFADs=",COLOR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cqzgFi3W3c94WWeHGparJoK5HemJXmYtsaGyp631AUAAA7",PROPORTION_Y:N+"pjI+pAbDbHIqqpSgZswZLzm2bA1rUmKHpebBtOlaweM3hKz+5Ps38UQAAOw==",REFRESH:N+"kjI+pywEPG5xgPXVRbqdyQzGesyUROZpbqk0fqbJlR80x+yYFADs=",REFRESH2:N+"oRB6gi2e5okKyMihpxLNx/njWJnbeiabNtY5my5DwlGmkW4N16ORJAQA7",ROUNDED:N+"ojB8AyKe/moFQPnSxanlG/m2SR45JJI5iaoUfw3YOe77yTL0wZc5SAQA7",RULER:N+"gjAOpeY2rnITSwFgvy7o2yl2eBoydZy2mGILTiboO2RQAOw==",RULER_WIDTH:N+"qDIIIl2usoomwJVvn1TWz5Shgk23mNKaOerBPu8YwSNf2jef6ztfnHygAADs=",RULER_HEIGHT:N+"rDI4Xa5zpQESsyvUoVibfumXRxDlY+ICX95Usin4gCXWtp8ZaR8+nnbItCgA7",SAVE:N+"aDI6Zpt0Bo4Rr2mql27z7T4GRGHrlh6YoAxYAOw==",SELECT:N+"pjI9pwNEOYHRKzVkPXo9tCiLXQiZjhqZWKZZnG3LXo6ngV81Rt9O2UQAAOw==",SHAPE:N+"mjI8Hm20LnIIM0aga1HrbhD3ZB0aY1zFoGqzWGk5SWEmt6+B5nRQAOw==",SIZE:N+"ljI+pywrfzpsRGutAshhfPWmBuHEg+aFnaX6SGCKhiqbRjedJAQA7",STAR:N+"ejI+pywitHjygTlPlypzHnjGgtnlQd1qhmJDXCzcFADs=",STAR2:N+"pjI+pBrDa2kPRzSCxTdV29h1ddIHalWmbmJrc6lLw+UJORctjC66kUQAAOw==",TEXT:N+"rjAN5y+kMnYJLAlrvxE/Jdhnakx3WhoSiZbLTdqZrm4Udenp4Lrdq+puBCgA7",TOROTRON:N+"pjI9pgKwHonxtUijdDVnTiGXJ1FkLx5Weo4Jhq4ipea7piJ55s7MbVQAAOw==",TRASH:N+"rjA2pxwicWlC0nicbrnyhfEHgg33ihIYnuZqsun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.addEventListener?t.addEventListener(e,n,!1):t.attachEvent?t.attachEvent("on"+e,n):alert("NO PUEDEN ASOCIARSE EVENTOS AL ELEMENTO"),this}function d(t){var e=t.parentNode;if(e.getAttribute("class").indexOf("hidden")>-1){e.setAttribute("class","visible"),e.style.display="table-cell",t.style.display="block",t.focus(),t.select();var n=document.getElementById("testron-download-link");n&&(n.style.display="none")}else e.setAttribute("class","hidden"),e.style.display="none"}function A(t){if(!encodeURIComponent)return f(t);var e=t.parentNode;e.setAttribute("class","visible"),e.style.display="table-cell",t.style.display="block",t.focus(),t.select();var n=document.getElementById("testron-download-link");if(!n){n=document.createElement("a"),n.setAttribute("id","testron-download-link"),n.innerHTML="∇ donwload ∇";var s=new Date;n.setAttribute("download","testron-"+s.getTime()+".json"),n.setAttribute("target","_blank"),n.setAttribute("title","download json"),n.style.textShadow="1px 1px 2px #333333",m(n,"click",function(){return n.style.display="none",!1}),e.appendChild(n)}n.setAttribute("style","display:inline"),n.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(t.innerHTML)),t.setAttribute("style","display:none")}function f(t){var e=t.parentNode;if(e.getAttribute("class").indexOf("hidden")>-1){e.setAttribute("class","visible"),e.style.display="table-cell",t.focus(),t.select();var n=!1;window&&window.clipboardData&&window.clipboardData.setData?(window.clipboardData.setData("Text",t.innerHTML),n=!0):document.execCommand&&(n=document.execCommand("copy")),n===!1?alert("Your browser doesn't allows copy from 'textarea'"):alert("OKAY. Copied text. \n Now you can paste it into any text file to save")}else e.setAttribute("class","hidden"),e.style.display="none"}function y(e){return t.parseTestrons(JSON.parse(e.value))}function v(e){function n(e){var n=null;return e||window.clearInterval(s),e&&e.element&&e.element.parentNode&&(n=e.element.parentNode,n&&(n.id=n.id?n.id:"testron-parent-"+t.getTests().length,e.conf.container=n,e.container=n)),n&&window.clearInterval(s),n}var s,i=!1;if(!e.conf.container&&!e.container&&e.element&&window&&window.setInterval)try{s=window.setInterval(function(){n(e)},500),i=!0}catch(r){}return i}function O(t,e){if(b=t?t:b,b&&e){var n=e.parent&&e.parent.parent?e.parent.parent.marker:null;b.call(null,e,n)}}function g(t,e){if(S=t?t:S,S&&e){var n=e.parent&&e.parent.parent?e.parent.parent.marker:null;S.call(null,e,n)}}function k(t,e){if(L=t?t:L,L&&e){var n=e.parent&&e.parent.parent?e.parent.parent.marker:null;L.call(null,e,n)}}function w(t,e){if(H=t?t:H,H&&e){var n=e.parent?e.parent.marker:null;H.call(null,e,n)}}function I(t,e){q=t?t:q,q&&e&&q.call(null,e)}function E(t,e){Q=t?t:Q,Q&&e&&Q.call(null,e)}function R(){for(var e=[],n=0;n<t.getTests().length;n++){var s=t.getTests()[n];e.push(s.toJSON())}return'{ "testrons": [ '+e.join(", ")+" ] }"}function T(t,e){t=t||{},e=e||{};for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}var C="abcdefghijklmnopqrstuvwxyz",N="data:image/gif;base64,R0lGODlhEAAQAIABAAAAAP///yH5BAEKAAEALAAAAAAQABAAAAI",j=[],b=null,S=null,L=null,H=null,q=null,Q=null;t.id=o(),t.getTests=e,t.addTest=n,t.removeTestIndex=s,t.removeTest=i,t.resetTests=r,t.utils={generateId:o,toPrecision:a,toDecimals:l,toDigits:h,icos:p(),addEvent:m,editListener:d,saveListener:A,copyClipboardListener:f,resetListener:y,setTimerContainer:v},t.parseTestrons=c,t.filterContainer=u,t.toJSON=R,t.merge=T,t.onOk=O,t.onFail=g,t.onClick=k,t.onNext=w,t.onMarker=I,t.onFinished=E}(testron||(testron={})),function(t){"use strict";function e(e){this.id,t.utils&&t.utils.generateId&&(this.id=t.utils.generateId()),this.num=n++,this.root=t,this.questions=[],this.element=null,this.valid=!0,this.marker=null,this.markerElement=null,this.conf=this.filterConf(e||{}),e.testron&&this.parseTestron(e),this.className=this.conf.className,this.container=this.conf.container,this.markerContainer=this.conf.markerContainer,this.remove=this.conf.remove,this.markerRemove=this.conf.markerRemove,this.finished=!1,this.root.addTest(this),this.update()}var n=0;e.prototype.getCounter=function(){return n},e.prototype.filterConf=function(t){var e=this.root.filterContainer(t.container,t.remove),n=this.root.filterContainer(t.markerContainer,t.markerRemove);return{className:"testron"+(t.className?" "+t.className:""),container:e,markerContainer:n,remove:t.remove,markerRemove:t.markerRemove,nQ:t.nQ||1,nA:t.nA||4,digits:t.digits||2,precision:t.precision||2,stopOnSuccess:t.stopOnSuccess||!1,charset:t.charset||"utf-8"}},e.prototype.sanitizeQuestions=function(){for(var t=[],e=0;e<this.questions.length;e++)this.questions[e].valid&&t.push(this.questions[e]);this.questions=t,this.update_nAnQ()},e.prototype.update_nAnQ=function(){for(var t=0,e=0;e<this.questions.length;e++)t+=this.questions[e].conf.nA;this.conf.nA=t,this.conf.nQ=this.questions.length},e.prototype.update=function(){this.toHtml(),this.marker||(this.marker=this.createMarker(this.conf)),this.marker&&this.marker.update&&this.marker.update()},e.prototype.checkFinished=function(){for(var t=!0,e=0;e<this.questions.length;e++)if(!this.questions[e].ok){t=!1;break}return this.finished=t},e.prototype.addQuestion=function(t,e){if(!t||!t.conf)return t;var n=!1,s=0,i=null;for(this.sanitizeQuestions(),s=0;s<this.questions.length;s++)i=this.questions[s],i.conf.num===t.conf.num&&(i=t,n=!0);return n||(t.position=this.questions.length,this.questions.push(t)),e&&this.update(),t},e.prototype.createQuestion=function(t,e){return this.addQuestion(new this.Question(this,t),e)},e.prototype.createMarker=function(t){if(t=t||this.conf,!t.markerContainer)return this.marker;var e=t.markerContainer;return!e.getAttribute&&e.replace&&(e=document.getElementById(e)),e?(this.markerElement=e.getElementsByClassName("testron-marker")[0],this.markerElement||(this.marker=new this.Marker(this,t)),this.marker.update(),this.marker):this.marker},e.prototype.parseTestron=function(t){var e=["Analizing Test.parseTestron() ... "];if(t&&t.replace&&(t=JSON.parse(t),e.push("string JSON detected !")),!t)return e.push("ERROR: 'test' object not exists!"),e.join("\n");t.testron&&(t=t.testron),t.conf||e.push("WARNING: 'test.conf' object not exists!"),this.conf=this.filterConf(t.conf);var n=t.questions;if(!n)return e.push("ERROR/WARNING: 'test.questions' array not exists!"),e.join("\n");for(var s=0;s<n.length;s++){var i=n[s];i?this.createQuestion({question:i}):e.push("WARNING: 'question["+s+"]' object not exists!")}return e.push("... test FINISH"),e.join("\n")},e.prototype.toHtml=function(){var e=document.createElement("ul");if(this.element&&this.element.innerHTML&&(this.element.innerHTML="",e=this.element),e.setAttribute("class",this.className),this.valid){var n=document.createElement("caption");n.innerHTML="Testron",e.appendChild(n),this.sanitizeQuestions();for(var s=0;s<this.questions.length;s++){var i=document.createElement("li");i.setAttribute("class","li-question"),i.appendChild(this.questions[s].toHtml()),e.appendChild(i)}this.element=e,this.container?this.container.appendChild(this.element):t.utils.setTimerContainer(this)}else e.style.background="#333333";return e},e.prototype.toJSON=function(){var t=this.marker&&this.marker.container?this.marker.container:"";this.markerContainer&&(this.markerContainer.id?t=this.markerContainer.id:this.markerContainer.replace&&(t=this.markerContainer));var e=this.className.split("testron");this.className="testron"+e[e.length-1],this.conf.className=this.className;for(var n={className:this.conf.className,container:this.container?this.container.id:"",markerContainer:t,remove:this.remove||this.conf.remove||!0,markerRemove:this.markerRemove||this.conf.markerRemove||!0,num:this.conf.num,nQ:this.conf.nQ,nA:this.conf.nA,digits:this.conf.digits,precision:this.conf.precision,stopOnSuccess:this.conf.stopOnSuccess,charset:this.conf.charset},s=[],i=0;i<this.questions.length;i++){var r=this.questions[i];s.push(r.toJSON())}return'{"conf": '+JSON.stringify(n)+', "questions": [ '+s.join(", ")+" ] }"},e.prototype.emitNext=function(t){var e="Test:: click in "+t.intents+" intents for Question ("+t.conf.num+") ";e+=t.position<this.questions.length-1?"- to Next Question at :: "+(t.position+2):"- This is the last Question ...",this.root.onNext(null,t)},e.prototype.emitMarker=function(t){this.update_nAnQ(),this.marker||(this.marker=this.createMarker(this.conf)),this.marker&&this.marker.update&&this.marker.update(t),this.root.onMarker(null,this.marker),this.checkFinished()&&this.root.onFinished(null,this)},t.Test=e}(testron||(testron={})),function(t){"use strict";function e(t,e){this.root=t.root,this.utils=this.root&&this.root.utils?this.root.utils:null,this.parent=t,this.id,this.utils&&this.utils.generateId&&(this.id=this.utils.generateId()),this.id=(t?t.id+"-":"")+this.id,this.num=n++,this.conf=this.filterConf(e||this.parent.conf),this.container=this.conf.container,this.results={"true":0,"false":0,"null":0,blank:0},this.position=0,this.element=null,this.elementScore=null,this.elementTrue=null,this.elementFalse=null,this.elementPointsTrue=null,this.elementPointsFalse=null,this.elementBlank=null,this.elementBtnEdit=null,this.elementBtnDownload=null,this.elementBtnReset=null,this.elementAreaEditSave=null,this.intents=0,this.score=0,this.currentQuestion=null,this.valid=!0,this.toHtml()}var n=0,s=10;e.prototype.getCounter=function(){return n},e.prototype.filterConf=function(t){var e=this.root.filterContainer(t.markerContainer,t.markerRemove);return{container:e,digits:t.digits||this.parent.conf.digits||4,precision:t.precision||this.parent.conf.precision||2,nQ:t.nQ||this.parent.conf.nQ||1,nA:t.nA||this.parent.conf.nA||4,charset:t.charset||this.parent.conf.charset||"utf-8"}},e.prototype.sanitizeResults=function(){this.results={"true":this.results["true"],"false":this.results["false"],"null":this.results["null"],blank:this.results.blank}},e.prototype.plusTrue=function(){return this.valid?(this.results["true"]++,this.intents++,this.results["true"]):-1},e.prototype.plusFalse=function(){return this.valid?(this.results["false"]++,this.intents++,this.results["false"]):-1},e.prototype.plusNull=function(){return this.valid?(this.results["null"]++,this.intents++,this.results["null"]):-1},e.prototype.plusBlank=function(){return this.valid?(this.results.blank++,this.intents++,this.results.blank):-1},e.prototype.resetResults=function(){this.valid&&(this.results={"true":0,"false":0,"null":0,blank:0})},e.prototype.reset=function(){this.valid&&(this.intents=0,this.resetResults())},e.prototype.update=function(t){var e=this.parent.questions;if(this.valid&&e){this.reset();for(var n=0;n<e.length;n++){var i=e[n],r=i.ok?i.intents-1:i.intents;if(i.ok&&this.plusTrue(),i.marked)for(var o=0;r>o;o++)this.plusFalse();else this.plusBlank()}this.conf.nQ=this.parent.conf.nQ,this.conf.nA=t&&t.conf?t.conf.nA:this.parent.conf.nA}this.elementScore.innerHTML='<strong>TOTAL: </strong> <span class="marker-score">'+this.calcScore()+"</span>",this.calcScore()>=s/2?this.elementScore.getElementsByClassName("marker-score")[0].style.color="darkGreen":this.elementScore.getElementsByClassName("marker-score")[0].style.color="red",this.elementPointsTrue.innerHTML="<strong>Points:</strong> (True:"+this.filterDigits(this.scoreSuccesses()*s)+") ",this.elementPointsFalse.innerHTML="(False:"+this.filterDigits(this.scoreFailures()*s)+")",this.elementTrue.innerHTML=this.results["true"],this.elementFalse.innerHTML=this.results["false"],this.elementBlank.innerHTML=this.results.blank,this.elementAreaEditSave.innerHTML=this.root.toJSON()},e.prototype.calcScore=function(){return this.score=this.filterDigits(s*(this.scoreSuccesses()-this.scoreFailures())),this.score},e.prototype.coefficientSuccesses=function(){return this.filterDigits(1/this.conf.nQ)},e.prototype.coefficientFailures=function(){return this.filterDigits(1/((this.conf.nA-1)*this.conf.nQ))},e.prototype.scoreSuccesses=function(){return this.filterDigits(this.results["true"]*this.coefficientSuccesses())},e.prototype.scoreFailures=function(){return this.filterDigits(this.results["false"]*this.coefficientFailures())},e.prototype.filterDigits=function(t,e,n,s){return e=e||this.conf.precision,n=n||this.conf.digits,this.utils&&(this.utils.toDecimals&&(t=this.utils.toDecimals(t,e)),this.utils.toDigits&&(t=this.utils.toDigits(t,n,s))),t},e.prototype.toHtml=function(){var t=this,e=document.createElement("table");if(this.element&&this.element.innerHTML&&(this.element.innerHTML="",e=this.element),e.setAttribute("class","marker testron-marker"),e.setAttribute("id",this.id),this.valid){var n=document.createElement("caption");n.innerHTML="Marker ("+this.num+")",e.appendChild(n),this.sanitizeResults();var i=document.createElement("thead"),r=document.createElement("tr"),o=document.createElement("th");o.innerHTML="",r.appendChild(o);var a=document.createElement("th");a.innerHTML="Value",r.appendChild(a),i.appendChild(r),e.appendChild(i);var l=document.createElement("tfoot"),h=document.createElement("tr"),c=document.createElement("td");c.setAttribute("class","marker-total"),c.setAttribute("colspan",2),c.innerHTML='<strong>TOTAL: </strong> <span class="marker-score">'+this.calcScore()+"</span>",this.elementScore=c,h.appendChild(c),l.appendChild(h);var u=document.createElement("tr");u.style.fontSize="smaller";var p=document.createElement("td");p.innerHTML="<strong>Points:</strong> (Success:"+this.filterDigits(this.scoreSuccesses()*s)+") ",this.elementPointsTrue=p,u.appendChild(p);var m=document.createElement("td");m.innerHTML="(Fails:"+this.filterDigits(this.scoreFailures()*s)+") ",this.elementPointsFalse=m,u.appendChild(m),l.appendChild(u);var d=document.createElement("tr");d.style.fontSize="smaller";var A=document.createElement("td"),f=document.createElement("i");f.setAttribute("class","btn btn-16"),f.innerHTML='<image src="'+this.root.utils.icos.PENCIL+'" title="edit/import ... modify or paste other text"/>',this.elementBtnEdit=f,this.elementBtnEdit.disabled=!document.queryCommandSupported("copy"),this.utils.addEvent(f,"click",function(){t.utils.editListener(k)}),A.appendChild(f);var y=document.createElement("i");y.setAttribute("class","btn btn-16"),y.innerHTML='<image src="'+this.root.utils.icos.DOWNLOAD+'" title="view save/download ... click on download link"/>',this.elementBtnDownload=y,this.utils.addEvent(y,"click",function(){t.utils.saveListener(k)}),A.appendChild(y);var v=document.createElement("i");v.setAttribute("class","btn btn-16"),v.innerHTML='<image src="'+this.root.utils.icos.UNDO+'" title="reset the tests"/>',this.elementBtnReset=v,this.utils.addEvent(v,"click",function(){var e=t.utils.resetListener(k);e.charAt&&"ERROR"===e.substr(0,5)&&(k.innerHTML=t.parent.toJSON(),e=t.utils.resetListener(k),e.charAt&&"ERROR"===e.substr(0,5)&&alert("ERROR parsing JSON"))}),A.appendChild(v),d.appendChild(A),l.appendChild(d);var O=document.createElement("tr");O.style.fontSize="larger";var g=document.createElement("td");g.setAttribute("colspan","2"),g.setAttribute("class","hidden"),g.setAttribute("id","testron-area-celd"),g.style.textAling="center",g.style.display="none";var k=document.createElement("textarea");k.setAttribute("rows","5"),k.style.width="98%",k.style.fontSize="smaller";var w=this.root.toJSON().toString();k.innerHTML=w>30?w:t.parent.toJSON(),this.elementAreaEditSave=k,this.utils.addEvent(this.elementAreaEditSave,"change",function(){t.root.parseTestrons(JSON.parse(k.value))}),g.appendChild(k),O.appendChild(g),l.appendChild(O),e.appendChild(l);var I=document.createElement("tbody"),E=document.createElement("tr"),R=document.createElement("td");R.innerHTML="Success",E.appendChild(R);var T=document.createElement("td");T.setAttribute("class","marker-values"),T.innerHTML=this.results["true"],this.elementTrue=T,E.appendChild(T),I.appendChild(E);var C=document.createElement("tr"),N=document.createElement("td");N.innerHTML="Fails",C.appendChild(N);var j=document.createElement("td");j.setAttribute("class","marker-values"),j.innerHTML=this.results["false"],this.elementFalse=j,C.appendChild(j),I.appendChild(C);var b=document.createElement("tr"),S=document.createElement("td");S.innerHTML="Blank",b.appendChild(S);var L=document.createElement("td");L.setAttribute("class","marker-values"),L.innerHTML=this.results.blank,this.elementBlank=L,b.appendChild(L),I.appendChild(b),e.appendChild(I),this.element=e,this.container?this.container.appendChild(this.element):this.root.utils.setTimerContainer(this)}else e.style.background="#666666";return e},t.prototype.Marker=e}(testron.Test||(testron.Test=function(){})),function(t){"use strict";function e(t,e){if(this.root=t.root,this.id,this.root.utils&&this.root.utils.generateId&&(this.id=this.root.utils.generateId()),this.id=(t?t.id+"-":"")+this.id,this.num=n++,this.parent=t,this.answers=[],this.position=0,this.ok=!1,this.element=null,this.marked=!1,this.intents=0,this.valid=!0,this.conf=this.filterConf(e||this.parent.conf),e.question){this.parseQuestion(e)}this.solution=this.conf.solution,this.stopOnSuccess=this.conf.stopOnSuccess,this.update_nA()}var n=0;e.prototype.getCounter=function(){return n},e.prototype.filterConf=function(t){return{num:t.num,nA:t.nA||this.parent.conf.nA||4,solution:t.solution||0,stopOnSuccess:void 0!==t.stopOnSuccess?t.stopOnSuccess:void 0!==this.parent.conf.stopOnSuccess?this.parent.conf.stopOnSuccess:!1,charset:t.charset||this.parent.conf.charset||"utf-8",txt:t.txt||"?"}},e.prototype.sanitizeAnswers=function(){for(var t=[],e=0;e<this.answers.length;e++)this.answers[e].valid&&t.push(this.answers[e]);this.answers=t},e.prototype.addAnswer=function(t){if(!t||!t.conf)return t;var e=!1,n=0;for(this.sanitizeAnswers(),n=0;n<this.answers.length;n++){var s=this.answers[n];s.conf.name===t.conf.name&&(s=t,e=!0)}return e||(t.position=this.answers.length,this.answers.push(t)),this.update_nA(),t},e.prototype.createAnswer=function(t){return this.addAnswer(new this.Answer(this,t))},e.prototype.removeAnswers=function(){for(var t=0;t<this.answers.length;t++)this.answers[t].remove();this.answers=[]},e.prototype.remove=function(){this.removeAnswers(),this.root=this.parent=this.conf=this.element=null,this.valid=!1},e.prototype.update_nA=function(){this.conf.nA=this.answers.length},e.prototype.verify=function(t){return t+1===this.solution},e.prototype.toOK=function(){this.valid&&this.element&&(this.element.style.backgroundColor="aquamarine",this.ok=!0,this.parent.emitMarker(this)),this.emitNext()},e.prototype.toFail=function(){this.valid&&this.element&&(this.element.style.backgroundColor="maroon",this.parent.emitMarker(this))},e.prototype.parseQuestion=function(t){var e=["Analizing Question.parseQuestion() ... "];if(t&&t.replace&&(t=JSON.parse(t),e.push("string JSON detected !")),!t)return e.push("ERROR: 'question' object not exists!"),e.join("\n");t.question&&(t=t.question),t.conf||e.push("WARNING: 'question.conf' object not exists!"),this.conf=this.filterConf(t.conf);var n=t.answers;if(!n)return e.push("ERROR/WARNING: 'anwers' array in this question ("+this.id+") not exists!"),e.join("\n");for(var s=0;s<n.length;s++){var i=n[s];i?this.createAnswer({answer:i}):e.push("ERROR/WARNING: 'anwers["+s+"]' object in this question ("+this.id+") not exists!")}return e.push("... question FINISH"),e.join("\n")},e.prototype.toHtml=function(){var t=document.createElement("ul");if(t.setAttribute("class","question"),this.valid){var e=document.createElement("caption");e.innerHTML='<span class="caption">('+this.conf.num+")</span>   "+this.conf.txt,t.appendChild(e),this.sanitizeAnswers();for(var n=0;n<this.answers.length;n++)t.appendChild(this.answers[n].toHtml());this.element=t}else t.style.background="#666666";return t},e.prototype.toJSON=function(){for(var t={num:this.conf.num,nA:this.conf.nA,solution:this.conf.solution,charset:this.conf.charset,txt:this.conf.txt},e=[],n=0;n<this.answers.length;n++){var s=this.answers[n];e.push(s.toJSON())}return'{"conf": '+JSON.stringify(t)+', "answers": [ '+e.join(", ")+" ] }"},e.prototype.emitClick=function(t){this.marked&&(this.stopOnSuccess?this.ok:1)||(this.intents++,this.verify(t.position)?(t.toOK(),this.toOK(),this.root.onOk(null,t)):(t.toFail(),this.toFail(),this.root.onFail(null,t)),this.marked=!0,this.root.onClick(null,t))},e.prototype.emitNext=function(){this.update_nA(),this.parent.emitNext(this)},t.prototype.Question=e}(testron.Test||(testron.Test=function(){})),function(t){"use strict";function e(t,e){if(this.root=t.root,this.id,this.root.utils&&this.root.utils.generateId&&(this.id=this.root.utils.generateId()),this.id=(t?t.id+"-":"")+this.id,this.num=n++,this.parent=t,this.element=null,this.checked=!1,this.valid=!0,this.conf=this.filterConf(e||this.parent.conf),e.answer){this.parseAnswer(e)}this.name=this.conf.name}var n=0;e.prototype.getCounter=function(){return n},e.prototype.filterConf=function(t){return{num:t.num,name:t.name,charset:t.charset||this.parent.conf.charset||"utf-8",txt:t.txt||""}},e.prototype.remove=function(){this.root=this.parent=this.conf=this.element=null,this.valid=!1},e.prototype.toOK=function(){this.valid&&this.element&&(this.element.style.backgroundColor="lightGreen")},e.prototype.toFail=function(){this.valid&&this.element&&(this.element.style.backgroundColor="coral")},e.prototype.parseAnswer=function(t){var e=["Analizing answer.parseAnswers() ... "];return t&&t.replace&&(t=JSON.parse(t),e.push("string JSON detected !")),t?(t.answer&&(t=t.answer),this.conf=this.filterConf(t),e.push("... answers FINISH"),e.join("\n")):(e.push("ERROR: 'answer' object not exists!"),e.join("\n"))},e.prototype.toHtml=function(){var t=this,e=document.createElement("li");return e.setAttribute("class","answer"),this.valid?(e.innerHTML='<span class="caption">'+this.conf.name+")</span> "+this.conf.txt,e.addEventListener("click",function(){t.emitClick()}),this.element=e):e.style.backgroundColor="#666666",e},e.prototype.toJSON=function(){return JSON.stringify({num:this.conf.num,name:this.name,charset:this.conf.charset,txt:this.conf.txt})},e.prototype.emitClick=function(){this.valid&&!this.checked&&(this.checked=!0,this.parent.emitClick(this))},t.prototype.Answer=e}(testron.Test.prototype.Question||(testron.Test.prototype.Question=function(){}));