/*! * PennController for IBEX * This software is licensed under a BSD license; see the LICENSE file for details. * * - Version 2.1.beta * - Last Update: 2021, December 8 * - Major changes in version 2.1.beta: * * Improved resource creation and zip downloads * * Improved preloading of audio and video elements * */!function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=37)}([function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var i=n(1);let r=[],s={keypress:[]};const o={};class a{constructor(e,t,n=!0){void 0===o[e]&&(o[e]=[]),o[e].push(this);const i=l.controllers.underConstruction;i.resources.push(this),l.resources.list.push(this),this.name=e,this.value=e,this.uris=[e],this.creator=t,this.object=null,this.status="void",this.useURLs=n,this.created_at=0,this.controller=i,this.resolveCallback=[]}addURI(e){this.uris.indexOf(e)>=0||(this.uris.push(e),"pending"==this.status&&this.creator.call(this,e,e=>this.resolve(e)))}callCreatorOnAllURIs(){this.uris.forEach(e=>{this.creator.call(this,e,e=>this.resolve(e))})}create(){"void"==this.status&&(this.created_at=Date.now(),this.useURLs&&l.URLs.forEach(e=>{e.endsWith("/")||(e+="/"),this.addURI(e+this.name)}),this.status="pending",this.callCreatorOnAllURIs())}resolve(e){"ready"!==this.status&&(this.object=e,this.status="ready",l.debug.log("
Successfully preloaded resource "+this.name+"
"),this.resolveCallback.forEach(t=>t instanceof Function&&t.call(this,e)))}}var l={resources:{new:(e,t,n=!0)=>{let i;if(void 0===o[e])i=new a(e,t,n);else{i=o[e][0];const r=l.controllers.underConstruction,s=l.controllers.header,c=l.controllers.footer;(r.resources.filter(t=>t.name==e).length>0||s&&!1!==r.runHeader&&s.resources.filter(t=>t.name==e).length>0||c&&!1!==r.runFooter&&c.resources.filter(t=>t.name==e).length>0||!i instanceof a)&&(i=new a(e,t,n))}return i},list:[]},controllers:{list:[],running:null,underConstruction:null},elements:{list:[]},events:{keypress:e=>{let t=[e,l.controllers.running||l.controllers.underConstruction];if(s.keypress.push(t),l.controllers.running){let e=l.controllers._endTrial;l.controllers.running._endTrial=async function(){await e.apply(l.controllers.running),t[0]=()=>{}}}else{let e=l.controllers.underConstruction.sequence;l.controllers.underConstruction.sequence=Object(i.d)([e,e=>{t[0]=()=>{},e()}])}}},URLs:[],utils:{guidGenerator:i.b,parseCoordinates:i.h,printAndRefreshUntil:i.j,levensthein:i.e,upload:i.k,overToScale:i.g},tmpItems:[],tables:{},Prerun:function(e){r.push(e)}};let c=window.ibex_controller_set_properties;window.ibex_controller_set_properties=function(e,t){if(c(e,t),"__SendResults__"==e){document.addEventListener("keydown",e=>{if(!e.repeat&&l.controllers.running)for(let t=0;t{const e=t=>{l.runningOrder&&l.runningOrder.active?t():window.requestAnimationFrame(()=>e(t))};await new Promise(e);let t=[];for(let e=0;e{if(n=n.filter(e=>"ready"!=e.status&&(0===e.created_at||Date.now()-e.created_at>1e4)),t.length>0&&n.length<4){let e=t.shift();for(;(void 0===e||"ready"==e.status)&&t.length;)e=t.shift();e&&"ready"!=e.status&&n.push(e)}0!=n.length&&(n.forEach(e=>{e instanceof a&&"void"==e.status&&e.create()}),window.requestAnimationFrame(i))};i()})},function(e,t,n){"use strict";function i(e){return()=>new Promise((async function(t){for(let t in e)if(e[t]instanceof Function)var n=await e[t]();t(n)}))}function r(e){const t=new Uint8Array(e);let n=[];return t.forEach(e=>{n.push(e.toString(16))}),n.join("").toUpperCase()}n.d(t,"d",(function(){return i})),n.d(t,"c",(function(){return r})),n.d(t,"g",(function(){return o})),n.d(t,"k",(function(){return a})),n.d(t,"a",(function(){return l})),n.d(t,"f",(function(){return c})),n.d(t,"b",(function(){return d})),n.d(t,"i",(function(){return u})),n.d(t,"h",(function(){return h})),n.d(t,"j",(function(){return f})),n.d(t,"e",(function(){return m}));const s=function(e){const t=this.css("transform").match(/matrix\(\s*(-?\d+(.\d+)?),[^,]+,[^,]+,\s*(-?\d+(.\d+)?),/);return t&&(e.x=e.x*Number(t[1]),e.y=e.y*Number(t[3])),e};function o(e,t){let n=this,i={x:1,y:1};for(;n;)s.call(n,i),n=n.parent(),n[0]===document&&(n=void 0);let r=this.offset(),o=this.width(),a=this.height(),l=o*i.x,c=a*i.y;return r.left<=e&&r.top<=t&&r.left+l>=e&&r.top+c>=t}async function a(e,t,n,i){let r;try{r=await new Promise((n,r)=>{const s=new XMLHttpRequest,o=e.match(/\?/)?"&":"?";s.open("GET",e+o+"filename="+encodeURIComponent(t)+"&mimetype="+encodeURIComponent(i),!0),s.setRequestHeader("Content-Type","application/json"),s.onerror=t=>r("Could not GET "+e+";"),s.onload=function(){let e=null;try{e=JSON.parse(this.responseText)}catch{e=this.responseText}console.log("response",e),n(e)},console.log("before sending xhr"),s.send(),console.log("after sending xhr")})}catch(e){return new Promise((t,n)=>n(e))}console.log("presignedPostData",r);const s=new FormData;return void 0===r||"string"==typeof r?(s.append("fileName",t),s.append("mimeType",i),s.append("file",n)):(Object.keys(r).forEach(t=>{"url"==t?e=r.url:s.append(t,r[t])}),s.append("file",n),r.key&&(t=r.key)),new Promise((n,i)=>{const r=new XMLHttpRequest;r.open("POST",e,!0),r.onload=()=>n(t),r.onerror=()=>i(r.responseText);try{r.send(s)}catch(t){return i("Could not POST to "+e+"; "+t)}})}function l(e,t){if(e.match(/^00000[12]00/i))return"image/x-icon";if(e.match(/424D/i))return"image/bmp";if(e.match(/^89504E470?D0?A1A0?A/i))return"image/png";if(e.match(/^474946383[79]61/i))return"image/gif";if(e.match(/^52494646........574542505650/i))return"image/webp";if(e.match(/^FFD8FF/i))return"image/jpeg";if(e.match(/^2E736E64/i))return"audio/basic";if(e.match(/^464F524D........41494646/i))return"audio/aiff";if(e.match(/^(fff[b3a2]|494433)/i))return"audio/mpeg";if(e.match(/^664C6143/i))return"audio/flac";if(e.match(/^4F67675300/i))return"application/ogg";if(e.match(/^4D546864......06/i))return"audio/midi";if(e.match(/^52494646........41564920/i))return"video/avi";if(e.match(/^52494646.{4,8}57415645/i))return"audio/wave";if(e.match(/^1A45DFA3/i))return"video/webm";if(e.match(/^25504446/i))return"application/pdf";if(e.match(/^504B0304/i))return"application/zip";{let e=t.match(/\.([^.]+)$/);if(!e)return"";switch(e[1].toLowerCase()){case"bmp":return"image/bmp";case"png":return"image/png";case"gif":return"image/gif";case"webp":return"image/webp";case"jpg":case"jpeg":return"image/jpeg";case"mp3":return"audio/mpeg";case"flac":return"audio/flac";case"ogg":case"oga":return"audio/ogg";case"midi":case"mid":return"audio/midi";case"wav":return"audio/wave";case"webm":return"video/webm";case"avi":return"video/avi";case"mp4":return"video/mp4";case"ogv":return"video/ogg";case"mov":return"video/quicktime";default:return""}}}function c(e){let t=e/1e3%60,n=Math.trunc(e/6e4);return(n>0?n+"min":"")+(t>0?t+"s":"")}function d(){var e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}function u(e){return e.map(e=>e instanceof Object&&e.hasOwnProperty("_promises")&&e.type&&e._element?e.type+":"+e._element.id:e)}function h(e,t){const n=this.css("transform").match(/matrix\(\s*(-?\d+(.\d+)?),[^,]+,[^,]+,\s*(-?\d+(.\d+)?),/),i=window.getComputedStyle(this[0]),r=Number(i.width.replace(/px$/,"")),s=Number(i.height.replace(/px$/,""));let o=r,a=s;n&&(o=Math.abs(o*n[1]),a=Math.abs(a*n[3]));let l=String(e).match(/^(.+)\s+at\s+(.+)$/i),c=String(t).match(/^(.+)\s+at\s+(.+)$/i);if(l&&(e=String(l[2])),c&&(t=String(c[2])),isNaN(e)||(e+="px"),isNaN(t)||(t+="px"),l){if(l[1].match(/top|bottom/i))throw"Passed Y coordinate in place of X";e=l[1].match(/center|middle/i)?`calc(${e} - ${r/2}px)`:l[1].match(/right/i)?`calc(${e} - ${o-(o-r)/2}px)`:`calc(${e} + ${(o-r)/2}px)`}else e=`calc(${e} + ${(o-r)/2}px)`;if(c){if(c[1].match(/left|right/i))throw"Passed X coordinate in place of Y";t=c[1].match(/center|middle/i)?`calc(${t} - ${s/2}px)`:c[1].match(/bottom/i)?`calc(${t} - ${a-(a-s)/2}px)`:`calc(${t} + ${(a-s)/2}px)`}else t=`calc(${t} + ${(a-s)/2}px)`;return{x:e,y:t}}function p(e,t,n,i,r){if(i instanceof Function&&i())return this.css(r);const s=h.call(this,e,t);this.css({position:"absolute",left:s.x,top:s.y}),window.requestAnimationFrame(()=>p.call(this,e,t,n,i,r))}function f(e,t,n,i){n=n||$("body");const r=this.parent()[0],s={display:this.css("display"),position:this.css("position"),left:this.css("left"),top:this.css("top")};void 0!==r&&r==n[0]||this.appendTo(n).css("display","inline-block"),p.call(this,e,t,n,i,s)}function m(e,t){let n=[];n[0]=("a"+t).split("").map((e,t)=>t);for(let i=1;i0)];for(let i=1;ie.toUpperCase());String.prototype.isSpecialKey=function(e){return e?g.indexOf(this)>-1:y.indexOf(this.toUpperCase())>-1},jQuery.fn.printed=function(){let e=this.parent();for(;e.length;){if(e[0]==document.body)return!0;e=e.parent()}return!1}},function(e,t,n){"use strict";n.d(t,"a",(function(){return l})),n.d(t,"b",(function(){return d}));var i=n(0),r=n(1);let s=null,o=null,a=[];class l{constructor(){if(this.id=i.a.controllers.list.length,this.useLabel=!1,this.addToItems=!0,this.appendResultLine=[],this.linesToSave=[],this.resources=[],this.elements={},this.ambiguousElementNames=[],this.preloadDelay=6e4,i.a.controllers.list.push(this),this.defaultCommands={},this.headerDefaultCommands={},s&&s.defaultCommands)for(let e in s.defaultCommands)this.defaultCommands[e]=[].concat(s.defaultCommands[e])}_addElement(e){if(!e.hasOwnProperty("type")||!e.hasOwnProperty("id"))return i.a.debug.error("Attempted to create an invalid element");this.elements.hasOwnProperty(e.type)||(this.elements[e.type]={}),this.elements[e.type].hasOwnProperty(e.id)&&i.a.debug.warning("Overwrting another "+e.type+" element with the same name ("+e.id+")"),this.elements[e.type][e.id]=e}_getElement(e,t){if("string"!=typeof e||e.length<1||"string"!=typeof t||t.length<1)return i.a.debug.error("Attempted to get an invalid element",e,t);if(!this.elements.hasOwnProperty(t))return i.a.debug.error("Attempted to get an element of an invalid type ("+t+")",e);if(!this.elements[t].hasOwnProperty(e)){let n=[];for(let t in this.elements)this.elements[t].hasOwnProperty(e)&&n.push(t);return i.a.debug.error("No "+t+" element named ""+e+"" found",n.length?"Found ""+e+"" of type "+n.join(","):null)}return this.elements[t][e]}label(e){return this.useLabel=e,this}logAppend(e,t,n){return this.linesToSave.push(["PennController",this.id,e,t,Date.now(),n]),this}log(e,t){return null==t&&(t=e),void 0===e?(i.a.debug.warning("Used newTrial().log with no arguments"),this):(this.appendResultLine.push([csv_url_encode(e),t]),this)}noHeader(){return this.runHeader=!1,this}noFooter(){return this.runFooter=!1,this}setOption(e,t){return this[e]=t,this}noTrialLog(...e){return this.skipLog=e,this}}i.a.controllers.underConstruction=new l,i.a.controllers.new=()=>new l;const c=[];var d=function(...e){let t=i.a.controllers.underConstruction;if(window.items)for(let e in window.items)i.a.tmpItems.indexOf(window.items[e])<0&&i.a.tmpItems.push(window.items[e]);i.a.tmpItems.push(t),e.length&&"string"==typeof e[0]&&(t.useLabel=e[0]);let n=[];return function e(...t){for(let n in t)c.filter(e=>e instanceof Function&&e.call(null,t[n])),t[n]&&t[n]._promises?this.push(Object(r.d)(t[n]._promises)):t[n]&&t[n]instanceof Array&&e.apply(this,t[n])}.apply(n,e),t.sequence=Object(r.d)(n),i.a.controllers.underConstruction=new l,t};i.a.NewTrialArgumentCallback=e=>c.push(e),d.newTrial=d,d.Debug=function(e){i.a.debug.on=null==e||e},d.DebugOff=()=>d.Debug(!1),d.Sequence=function(...e){for(let t=0;t1&&"__SendResults__"==e[t]._item[1]){let n="sendResults-"+Object(r.b)();e[t].label(n),e[t]=n}window.shuffleSequence=window.seq(...e)};let u={};d.GetURLParameter=function(e){if(!Object.keys(u).length){let e=window.location.search.replace("?","").split("&");for(let t in e)u[e[t].split("=")[0]]=e[t].split("=")[1]}if(u.hasOwnProperty(e))return u[e]},d.AddHost=function(...e){for(let t in e)"string"==typeof e[t]&&e[t].match(/^https?:\/\//i)?i.a.URLs.push(e[t]):i.a.debug.warning("URL #"+t+" is not a valid URL (PennController.AddHost).",e[t])},d.CheckPreloaded=function(...e){let t=new l;t.id="Preloader-"+a.length,t.runHeader=!1,t.runFooter=!1,a.push(t),i.a.controllers.list.pop(),t.sequence=()=>new Promise(e=>e()),t.ignoreWhenCheckingPreload=!0,i.a.tmpItems.push(t),e.length&&Number(e[e.length-1])>0&&(t.preloadDelay=Number(e[e.length-1]),e.pop());let n=[];if(e.length)for(let t in e){let i=e[t];"string"==typeof i&&(i=n=>n==e[t]),i instanceof Function&&n.push(i)}else n=[e=>!0];return i.a.Prerun(()=>{let e=window.conf_modifyRunningOrder;window.conf_modifyRunningOrder=function(i){e instanceof Function&&(i=e.call(this,i));for(let e=0;e{let t=!1;for(let i=0;it.resources.indexOf(e)<0))}return i}}),t};const h=window.JSON.stringify;window.JSON.stringify=function(...e){const t=h.apply(this,e);if(1==e.length&&e[0]instanceof Array&&6==e[0].length&&!1===e[0][0]&&e[0][1]==window.__counter_value_from_server__&&e[0][4]==(()=>{for(var e=(new Date).getTimezoneOffset()+":",t=["Java","QuickTime","DevalVR","Shockwave","Flash","Windows Media Player","Silverlight","VLC Player"],n=0;nnew Promise(e=>{const n=window.__server_py_script_name__;let r={_finishedCallback:()=>{window.__server_py_script_name__=n,e()},_cssPrefix:"",_utils:i.a.controllers.running.utils},s=window.$("

").addClass("PennController-SendResults");i.a.controllers.running.element.append(s),addSafeBindMethodPair("__SendResults__"),"string"==typeof t&&(window.__server_py_script_name__=t),s.__SendResults__(r)}),o={label:e=>(r[0]=e,o),setOption:(e,t)=>(n[e]=t,o)};o._item=r,o.type="__SendResults__",o._element={id:"SendResults"};const a=e=>{if(e==o){let e=window.items&&window.items.indexOf(r);e>=0&&window.items.splice(e,1),i.a.tmpItems=i.a.tmpItems.filter(e=>e!=r)}};return i.a.ArgumentCallback(a),i.a.NewTrialArgumentCallback(a),o._promises=[s],o._runPromises=s,window.items.push(r),o},d.SetCounter=function(...e){null==window.items&&(window.items=[]);let t="setCounter",n={};e.length&&(isNaN(Number(e[0]))?1==e.length?isNaN(Number(e[0]))?t=e[0]:n.set=Number(e[0]):2!=e.length||isNaN(Number(e[1]))?e.length>2&&!isNaN(Number(e[2]))?(t=e[0],e[1].match(/\s*inc\s*$/i)?n.inc=e[2]:n.set=e[2]):t=e[0]:e[0].match(/\s*inc\s*$/i)?n.inc=e[1]:(n.set=e[1],e[0].match(/\s*set\s*$/i)||(t=e[0])):n.set=Number(e[0]));let i=[t,"__SetCounter__",n];return n.label=e=>(i[0]=e,n),n.setOption=(e,t)=>(n[e]=t,n),window.items.push(i),n},d.Header=function(...e){let t=i.a.controllers.underConstruction;t.id="Header",t.addToItems=!1,i.a.controllers.list.pop(),t.sequence=Object(r.d)(e.map(e=>Object(r.d)(e._promises)));for(let e in t.defaultCommands)for(let n in t.defaultCommands[e])t.defaultCommands[e][n].push("header");return s?(s.resources=s.resources.concat(t.resources),$.extend(!0,s.elements,t.elements),s.headerDefaultCommands=t.headerDefaultCommands,s.sequence=Object(r.d)([s.sequence,t.sequence])):s=t,i.a.controllers.header=s,i.a.controllers.underConstruction=new l,s},d.Footer=function(...e){let t=i.a.controllers.underConstruction;return t.id="Footer",t.addToItems=!1,i.a.controllers.list.pop(),t.sequence=Object(r.d)(e.map(e=>Object(r.d)(e._promises))),o?(o.resources=o.resources.concat(t.resources),$.extend(!0,o.elements,t.elements),o.headerDefaultCommands=t.headerDefaultCommands,o.sequence=Object(r.d)([o.sequence,t.sequence])):o=t,i.a.controllers.footer=o,i.a.controllers.underConstruction=new l,o},define_ibex_controller({name:"PennController",jqueryWidget:{_init:function(){var e=this;i.a.controllers.running=e,e.cssPrefix=e.options._cssPrefix,e.utils=e.options._utils,e.finishedCallback=e.options._finishedCallback,e.id=e.options.id,"string"==typeof e.id&&e.id.match(/^Preloader-/)?e.controller=a[Number(e.id.replace(/Preloader-/,""))]:"Header"==e.id?e.controller=s:"Footer"==e.id?e.controller=o:Number(e.id)>=0&&Number(e.id)e.controller.resources.indexOf(t)<0)),$.extend(!0,e.controller.elements,s.elements);for(let t=0;te.controller.resources.indexOf(t)<0)),$.extend(!0,e.controller.elements,o.elements);for(let t=0;t0&&0==o.skipLog.filter(e=>e.match(/start/i)).length)||e.save("PennController",e.id,"_Footer_","Start",Date.now(),"NULL"),o._getElement=(t,n)=>e.controller._getElement(t,n),await o.sequence(),o.skipLog instanceof Array&&!(o.skipLog.length>0&&0==o.skipLog.filter(e=>e.match(/end/i)).length)||e.save("PennController",e.id,"_Footer_","End",Date.now(),"NULL"));for(let t in e.controller.elements)for(let n in e.controller.elements[t])await e.controller.elements[t][n].end();e.controller.skipLog instanceof Array&&!(e.controller.skipLog.length>0&&0==e.controller.skipLog.filter(e=>e.match(/end/i)).length)||e.save("PennController",e.id,"_Trial_","End",Date.now(),"NULL"),n.sort((e,t)=>e[4][1]>t[4][1]),n.map(e=>{for(let t in e){e[t][1]instanceof Function&&(e[t][1]=e[t][1]());let n=[];for(;e[t][1].value&&e[t][1].value._element;)n.indexOf(e[t][1]._element)<0?(n.push(e[t][1]._element),e[t][1]=e[t][1].value):e[t][1]=e[t][1]._element.id;e[t][1]._element&&e[t][1]._element.id&&(e[t][1]=e[t][1]._element.value),e[t][1]=csv_url_encode(""+e[t][1])}}),e.finishedCallback(n)}};e.endTrial=d;let u,h=!1,p=$("

Please wait while the resources are preloading

This may take up to "+Object(r.f)(t)+".

");e.element.append(p);const f=n=>{void 0===u&&(u=n);const r=n-u>=t;r||0==e.controller.resources.filter(e=>"ready"!=e.status).length?async function(t){h||(e.element.css({display:"flex","flex-direction":"column",position:"absolute",left:0,width:"100vw"}),h=!0,t&&e.controller.resources.forEach(t=>"ready"!=t.status&&(e.save("PennController",e.id,"_PreloadFailed_",csv_url_encode(t.name),Date.now(),"NULL")||i.a.debug.warning("Failed to preload a resource named '"+t.name+"'"))),p.remove(),e.controller.skipLog instanceof Array&&!(e.controller.skipLog.length>0&&0==e.controller.skipLog.filter(e=>e.match(/start/i)).length)||e.save("PennController",e.id,"_Trial_","Start",Date.now(),"NULL"),e.runHeader&&s instanceof l&&(s.skipLog instanceof Array&&!(s.skipLog.length>0&&0==s.skipLog.filter(e=>e.match(/start/i)).length)||e.save("PennController",e.id,"_Header_","Start",Date.now(),"NULL"),await s.sequence(),s.skipLog instanceof Array&&!(s.skipLog.length>0&&0==s.skipLog.filter(e=>e.match(/end/i)).length)||e.save("PennController",e.id,"_Header_","End",Date.now(),"NULL")),e.controller.sequence().then(d))}(r):window.requestAnimationFrame(f)};window.requestAnimationFrame(f)}},properties:{obligatory:[],countsForProgressBar:!0,htmlDescription:null}}),window.PennController=new Proxy(d,{get:(e,t)=>{if(t in e)return e[t];i.a.debug.error("Unknown global PennController command: ‘"+t+"’")}})},function(e,t,n){(function(n){var i,r,s;r=[],void 0===(s="function"==typeof(i=function(){"use strict";function t(e,t,n){var i=new XMLHttpRequest;i.open("GET",e),i.responseType="blob",i.onload=function(){a(i.response,t,n)},i.onerror=function(){console.error("could not download file")},i.send()}function i(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function r(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var s="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof n&&n.global===n?n:void 0,o=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),a=s.saveAs||("object"!=typeof window||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!o?function(e,n,o){var a=s.URL||s.webkitURL,l=document.createElement("a");n=n||e.name||"download",l.download=n,l.rel="noopener","string"==typeof e?(l.href=e,l.origin===location.origin?r(l):i(l.href)?t(e,n,o):r(l,l.target="_blank")):(l.href=a.createObjectURL(e),setTimeout((function(){a.revokeObjectURL(l.href)}),4e4),setTimeout((function(){r(l)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,n,s){if(n=n||e.name||"download","string"!=typeof e)navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!=typeof t&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}(e,s),n);else if(i(e))t(e,n,s);else{var o=document.createElement("a");o.href=e,o.target="_blank",setTimeout((function(){r(o)}))}}:function(e,n,i,r){if((r=r||open("","_blank"))&&(r.document.title=r.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,i);var a="application/octet-stream"===e.type,l=/constructor/i.test(s.HTMLElement)||s.safari,c=/CriOS\/[\d]+/.test(navigator.userAgent);if((c||a&&l||o)&&"undefined"!=typeof FileReader){var d=new FileReader;d.onloadend=function(){var e=d.result;e=c?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),r?r.location.href=e:location=e,r=null},d.readAsDataURL(e)}else{var u=s.URL||s.webkitURL,h=u.createObjectURL(e);r?r.location=h:location.href=h,r=null,setTimeout((function(){u.revokeObjectURL(h)}),4e4)}});s.saveAs=a.saveAs=a,e.exports=a})?i.apply(t,r):i)||(e.exports=s)}).call(this,n(7))},function(e,t,n){"use strict";var i=n(0),r=n(1);$.prototype.left=function(){return Number(this.css("left").replace(/px/,""))},$.prototype.top=function(){return Number(this.css("top").replace(/px/,""))};i.a.Prerun(()=>{const e=window.location.pathname;if(!i.a.debug.on||null==="2.1.beta".match(/beta/i)||window.localStorage&&window.localStorage.getItem(e))return;const t=new s("Beta Version",400,200,"calc(50vw - 200px)","calc(50vh - 100px)");t.container.find("div:nth-child(3)").remove(),t.content.html("

Please note that this project is using a beta version of PennController (2.1.beta).

\n

Report new bugs at https://www.pcibex.net/bug-report/\n or at support@pcibex.net

"),t.popIn(),t.titleExpand.click().remove();const n=t.popOut;t.popOut=()=>{window.localStorage.setItem(e,!0),n.call(t)}});class s{constructor(e,t,n,i,r){let s=this;this.title=e,this.width=t,this.height=n,this.x=i,this.y=r,this.tabs=[],this.container=$("
").css({width:t,height:"3em",overflow:"hidden",position:"fixed","border-radius":"5px","background-color":"floralwhite","min-height":"3em","min-width":"3em","z-index":9999}),this.titleBar=$("
").css({width:"100%",height:"1.5em",margin:0,padding:0,"background-color":"gray",cursor:"move",color:"white","border-radius":"5px 5px 0px 0px"}),this.titleExpand=$("").css({display:"inline-block","line-height":"1.3em",padding:"2px","margin-right":"0.25em",cursor:"pointer"}).click(()=>{9656==this.titleExpand.html().charCodeAt(0)?(this.titleExpand.html("▾"),this.container.css({height:this.height,overflow:"unset"})):(this.titleExpand.html("▸"),this.container.css({height:"3em",overflow:"hidden"}))}),this.titleSpan=$(""+e+"").css({display:"inline-block",padding:"2px","line-height":"1.3em",overflow:"hidden"}),this.titleBar.append(this.titleSpan.prepend(this.titleExpand)).append($("X").css({width:"1.3em",height:"1.3em",margin:"0.1em","line-height":"1.3em","border-radius":"2px","text-align":"center",position:"absolute",right:0,cursor:"pointer",overflow:"hidden"}).click((function(){s.popOut()})).mouseenter((function(){$(this).css({border:"solid 1px lightgray","border-radius":"2px"})})).mouseleave((function(){$(this).css({border:"none"})}))).mousedown((function(e){s.updatePosition={x:e.clientX,y:e.clientY,left:s.container.left(),top:s.container.top()},e.preventDefault()})),this.tabBar=$("
").css({width:"calc(100% - 10px)",height:"1.5em","margin-bottom":"0px",overflow:"hidden",display:"flex","margin-left":"5px","margin-right":"5px"}),this.tabBar.append($("
").css({width:"100%","border-bottom":"solid 1px lightgray"})),this.newTab=(e,t)=>{e instanceof jQuery||(e=$("").append(e)),t instanceof jQuery||(t=$("
").append(t));let n={title:e,content:t,jQuery:$("
").append(e).css({border:"solid 1px lightgray","border-top-right-radius":"5px","border-top-left-radius":"5px","padding-left":"5px","padding-right":"5px",cursor:"pointer"}).click(()=>{this.content.children().detach(),this.content.append(n.content),this.tabBar.children().css({background:"linen",color:"darkgray","border-bottom":"solid 1px lightgray"}),n.jQuery.css({color:"black",background:"inherit","border-bottom":"none"}),a.activeTab=n}),remove:()=>this.jQuery.remove()};return this.tabs.push(n),this.tabBar.prepend(n.jQuery),n},this.container.append($("
").css({display:"inline-block",width:"1.3em",height:"1.3em",position:"absolute",bottom:0,right:0,cursor:"se-resize",background:"repeating-linear-gradient(135deg,rgba(255,255,255,.5),rgba(255,255,255,.5) 2px,#777 2px,#777 4px)","clip-path":"polygon(90% 0,90% 90%,0 90%)",opacity:"0.5"}).mousedown((function(e){s.updateSize=!0,s.offsetRight=e.clientX-(s.container.left()+s.container.width()),s.offsetBottom=e.clientY-(s.container.top()+s.container.height()),e.preventDefault()}))),this.content=$("
").css({border:"solid 1px lightgray","font-family":"monospace","font-size":"0.9em",margin:"0px 5px 5px 5px",padding:"2px",height:"calc(100% - 4.5em - 30px)",overflow:"auto","border-top":"none"}),this.container.append(this.titleBar),this.container.append($("
Use DebugOff() before publishing.
").css({height:"1.5em","overflow-x":"hidden"})),this.container.append(this.tabBar),this.container.append(this.content),this.container.css({left:i,top:r}),$(document).mousemove((function(e){s.updatePosition&&(s.x=s.updatePosition.left+(e.clientX-s.updatePosition.x),s.y=s.updatePosition.top+(e.clientY-s.updatePosition.y),s.container.css({left:s.x,top:s.y})),s.updateSize&&(s.width=e.clientX-s.container.left()-s.offsetRight,s.height=e.clientY-s.container.top()-s.offsetBottom,s.container.css({width:s.width,height:s.height}))})).mouseup((function(){s.updatePosition=void 0,s.updateSize=!1}))}popIn(){$(document.body).append(this.container)}popOut(){this.container.detach()}}let o=!1,a={popin:{},tablePopin:{},infoTab:null,runningOrder:null,runningIndex:-1,runningElement:-1,currentController:null,currentTable:null,activeTab:null};i.a.debug={on:!0,currentPromise:null,forceResolve:()=>{i.a.debug.currentPromise instanceof Function&&i.a.debug.currentPromise()},addToTab:(e,...t)=>{if(!i.a.debug.on)return;let n;n=i.a.controllers.running?i.a.controllers.list[i.a.controllers.running.id]:i.a.controllers.underConstruction,null==n&&(n={id:"NA"});let r=new Date;e.prepend($("
["+[r.getHours(),r.getMinutes(),r.getSeconds()].join(":")+"] "+t.join(";")+" (newTrial: "+n.id+(n.useLabel?"-"+n.useLabel:"")+")
").css({"border-bottom":"dotted 1px gray","margin-bottom":"1px","padding-bottom":"1px"}))},log:(...e)=>i.a.debug.addToTab(a.logTab.log,...e),warning:(...e)=>{i.a.debug.on&&(i.a.debug.addToTab(a.warningsTab.content,...e),a.warningsTab.title.css("color","orange"),a.warningsTab.content.find(".PennController-debug-nowarnings").css("display","none"),9656==a.popin.titleExpand.html().charCodeAt(0)&&a.popin.titleExpand.click(),a.warningsTab.jQuery.click())},error:(...e)=>{i.a.debug.on&&(i.a.debug.addToTab(a.errorsTab.content,...e),a.errorsTab.title.css("color","red"),a.errorsTab.content.find(".PennController-debug-noerrors").css("display","none"),9656==a.popin.titleExpand.html().charCodeAt(0)&&a.popin.titleExpand.click(),a.errorsTab.jQuery.click())}},a.popin=new s("Debug (PennController 2.1.beta)",440,240,window.innerWidth-450,10),a.logTab=a.popin.newTab("Log"),a.logTab.controls=$("
").append($("").click(()=>{"PennController-"==a.currentController._cssPrefix?i.a.controllers.running.endTrial():a.currentController._finishedCallback()})).append($("").click(()=>i.a.debug.forceResolve())).css({background:"lightgray","border-bottom":"dotted 1px black"}).appendTo(a.logTab.content),a.logTab.log=$("
").appendTo(a.logTab.content),a.warningsTab=a.popin.newTab("Warnings"),a.warningsTab.content.prepend($("
No warnings
").css({"font-style":"italic","text-align":"center",margin:"5px"}).addClass("PennController-debug-nowarnings")),a.errorsTab=a.popin.newTab("Errors"),a.errorsTab.content.prepend($("
No errors found
").css({"font-style":"italic","text-align":"center",margin:"5px"}).addClass("PennController-debug-noerrors"));let l=()=>{a.currentTable&&a.currentTable.debug&&(a.currentTable.debug.content.find("tr").css("background-color","transparent"),$(a.currentTable.debug.content.find("tr")[a.currentRow+1]).css("background-color","pink"),a.tablePopin.titleSpan.after(c),a.currentTable.hasOwnProperty("group")&&a.currentTable.table[0].hasOwnProperty(a.currentTable.group)&&c.after(u))},c=$("").click((function(){a.currentTable.debug.jQuery.click();let e=$(a.currentTable.debug.content.find("tr")[a.currentRow+1]).position().top;a.currentTable.debug.content.children()[2].scrollTop+=e})).css({display:"inline-block",padding:"2px 5px","line-height":"1.3em",overflow:"hidden"}),d=!1,u=$("👁").click((function(){if(d)a.currentTable.debug.content.find("tr").css("display","table-row");else{let e=a.currentTable.table[a.currentRow][a.currentTable.group],t=a.currentTable.debug.content.find("tr");for(let n=0;n{let t=Object.keys(e.table[0]),n=$("").css({display:"table","table-layout":"fixed",height:"100%",width:70*(t.length+1)}),i=$("
").css({display:"table","table-layout":"fixed",height:"100%",width:70*(t.length+1)}),r=$("");r.append($("
").html("#").css({width:70,overflow:"hidden"}));for(let e=0;e").html(t[e]).css({width:70,overflow:"hidden"}));i.append(r);for(let i=0;i");r.append($("").html(""+Number(i+1)+".").css({width:70,overflow:"hidden"}));for(let n=0;n").html(e.table[i][t[n]]).css({width:70,overflow:"hidden"}));n.append(r)}let s=$("
").css({height:"calc(100% - 1.5em)",overflow:"auto"}).append(n),o=$("
").css({height:"1.5em",width:"100%"}),a=$("
").css({width:"100%",position:"absolute",left:0,top:0}).append(i);return s.scroll(()=>a.css("margin-left",-1*s[0].scrollLeft)),$("
").css({width:"100%",height:"100%","white-space":"nowrap",position:"relative",overflow:"hidden"}).append(a).append(o).append(s)},p=e=>{if(a.tablePopin.hasOwnProperty("container"))a.tablePopin.container.parent().length>0?a.tablePopin.tabs[e].jQuery.click():$(document.body).append(a.tablePopin.container);else{a.tablePopin=new s("Tables",window.innerWidth-320,190,10,window.innerHeight-200);let t=Object.keys(i.a.tables);for(let e=0;e{if(a.runningIndex<0&&(a.runningIndex=0),a.runningElement<0?a.runningElement=0:(a.runningElement++,a.runningElement>=a.runningOrder[a.runningIndex].length&&(a.runningElement=0,a.runningIndex++)),"__SendResults__"==a.runningOrder[a.runningIndex][a.runningElement].controller&&(o=!0),!i.a.debug.on)return void(window.items=void 0);if(b(),g(),c.detach(),u.detach(),a.currentTable=null,a.currentTableName="NA",a.currentRow=-1,a.currentController=a.runningOrder[a.runningIndex][a.runningElement].options,a.currentController.hasOwnProperty("_PennController")){a.currentTable=a.currentController._PennController.table;for(let e in i.a.tables)i.a.tables[e]==a.currentTable&&(a.currentTableName=e);a.currentRow=Number(a.currentController._PennController.row),l()}let e=a.runningOrder[a.runningIndex][a.runningElement];a.infoTab.content.empty(),a.infoTab.content.append($("
Trial in sequence "+Number(a.runningIndex+1)+" / "+a.runningOrder.length+"
")).append($("
Element in trial "+Number(a.runningElement+1)+" / "+a.runningOrder[a.runningIndex].length+"
")).append($("
Trial's label: "+e.type+"
")).append($("
Trial's type (controller): "+e.controller+"
")).append($("
Trial's index: "+e.itemNumber+" / "+window.items.length+"
")).append($("
From table: "+a.currentTableName+"
")),"PennController"==e.controller?$(a.logTab.controls.children()[1]).css("display","inline-block"):$(a.logTab.controls.children()[1]).css("display","none")};let m=window.dget;window.dget=(...e)=>{let t=m(...e);return e[1]&&"displayMode"==e[1]&&e[2]&&"overwrite"==e[2]&&f(),t};const g=()=>{if(window.conf_showProgressBar){let e=0,t=0;a.runningOrder.forEach((n,i)=>n.forEach((n,r)=>{const s=ibex_controller_get_property(n.controller,"countsForProgressBar");(void 0===s||s)&&(e++,(i table div.bar-container"),i=n.find(".bar"),r=5*e<300?5*e:300,s=t*r/e;n.css("width",r),i.css("width",Math.round(s)+"px")}},y=e=>{a.runningIndexy(e),1))},b=()=>{const e=$("
    ");for(let t=0;t").append(s);t<=a.runningIndex?o.css({color:"gray","background-color":t==a.runningIndex?"pink":"transparent"}):o.append($("").click(()=>y(t))),e.append(o)}a.sequenceTab.content.empty().append(e)};let w=window.$.ajax;window.$.ajax=(...e)=>(i.a.debug.on&&e[0]&&e[0].url&&e[0].url.match(/\?allchunks=1$/)&&a.popin.popIn(),w(...e)),i.a.Prerun(()=>{window.onbeforeunload=function(){if(!o)return"Your results have not been sent yet. Do you really want to leave the page?"};let e=!1;PennController.version="2.1.beta";let t=window.assert;window.assert=function(...n){if(e||"There must be some items in the running order!"!=n[1])return t.apply(this,n);e=!0;let r=window.conf_modifyRunningOrder;return window.conf_modifyRunningOrder=function(e){a.runningOrder=r instanceof Function?r.call(this,e):e,i.a.runningOrder={active:a.runningOrder,original:[...a.runningOrder]};const t=i.a.runningOrder.active.push;let n=!1;return i.a.runningOrder.active.push=function(...e){const r=t.apply(this,e);return!n&&e[0]instanceof Array&&e[0][0]&&"__SendResults__"==e[0][0].controller&&(i.a.runningOrder.original=[...this],n=!0),r},Object.defineProperty(i.a.runningOrder,"runningIndex",{get:()=>a.runningIndex}),i.a.debug.on&&(()=>{let e=Object.keys(i.a.tables);if(e.length>0){let t=$("
      ");for(let n=0;n").html(e[n]).click(()=>p(n)).css("cursor","pointer"));a.popin.newTab("Tables",t)}a.sequenceTab=a.popin.newTab("Sequence"),a.infoTab=a.popin.newTab("Info"),b(),a.activeTab?a.activeTab.jQuery.click():a.errorsTab.jQuery.click(),$(window.document).bind("keyup keydown",(function(e){if(e.ctrlKey&&68==e.keyCode){let t=window.innerWidth-450,n=window.innerHeight-250;return $(window.document.body).append(a.popin.container),a.popin.x=t,a.popin.y=n,a.popin.container.css({top:n,left:t}),e.preventDefault(),e.stopPropagation(),!1}}))})(),f(),a.runningOrder},t.apply(this,n)}}),window.onerror=function(e,t,n){if(!t.match(/include=data$/))return;let s=e.match(/ReferenceError: (.+) is not defined/);if(s)if(s[1].match(/^(new|get|default)/)&&PennController.Elements[s[1]])i.a.debug.error("Tried to use ‘"+s[1]+"’ without a prefix on line "+n+"; did you forget to use PennController.ResetPrefix?");else{let e={score:1,command:""},t=Object.getOwnPropertyNames(PennController.Elements);for(let n=0;n"+e.command+"’?"):i.a.debug.error("Unrecognized expression ‘"+s[1]+"’ (line "+n+")")}else i.a.debug.error(e)};let v=window.ibex_controller_get_property;window.ibex_controller_get_property=(e,t)=>{let n=Object.getOwnPropertyNames($.ui);if(n.indexOf(e)>-1)return v(e,t);let s={score:1,controllerName:""};for(let t=0;t"+s.controllerName+"?"):i.a.debug.error("Invalid controller reference: ‘"+e+"’")}},function(e,t,n){"use strict";var i=n(1),r=n(2),s=n(0);r.b.Elements={};class o{constructor(){this._commands=[],this._currentType="action."}}Object.defineProperty(r.b.Elements,"self",{get:()=>{const e=new o,t=new Proxy(e,{get:(n,i)=>{if("_commands"==i||"_currentType"==i||"hasOwnProperty"==i)return e[i];if(console.log("Getting self's proxy, with",i),"settings"==i)e._currentType="settings.";else if("test"==i)e._currentType="test.";else{if("testNot"!=i){console.log("Action on self");let n={name:e._currentType.replace("action.","")+i};e._commands.push(n);const r=(...e)=>(n.args=e,console.log("Added args",e,"to",n),t);return e._currentType="action.",r}e._currentType="testNot."}return t}});return t}});const a=[];s.a.ArgumentCallback=e=>a.push(e);const l=async function(e){for(let t=0;tn instanceof Function&&n.call(null,e[t])),e[t]instanceof p&&"Var"==e[t].type&&0==e[t]._promises.length)e[t]._runPromises instanceof Function&&await e[t]._runPromises(),e[t]=e[t].value;else if(e[t]instanceof o){let n=new p(this,m[this.type]),i=n._proxy;const r=e[t]._commands;for(let e=0;e{let r=s.a.controllers.running;s.a.debug.currentPromise=i;await l.call(n,t),e.apply(n,[(...e)=>s.a.controllers.running!=r||i(...e)].concat(t))})}},d=function(e){let t=[],n=()=>new Promise(e=>e()),r=()=>new Promise(e=>e()),o=function(...i){let o=this;return new Promise((async function(a){let c=s.a.controllers.running;s.a.debug.currentPromise=a;let d=(...e)=>s.a.controllers.running!=c||a(...e);await l.call(o,i);let u=e.apply(o,i),h="and";for(let e=0;e{t.push("and"),t.push(e)},o.or=e=>{t.push("or"),t.push(e)},o.success=function(...e){n=Object(i.d)(e.map(e=>async()=>{const t=await l.call(this,[e]);t[0]&&t[0]._runPromises instanceof Function&&await t[0]._runPromises()}))},o.failure=function(...e){r=Object(i.d)(e.map(e=>async()=>{const t=await l.call(this,[e]);t[0]&&t[0]._runPromises instanceof Function&&await t[0]._runPromises()}))},o};class u{constructor(e,t,n){let i=$(""),r=i.css,o=[];i.css=(...e)=>{o.push(e),r.apply(i,e)};let a=!1;Object.defineProperty(this,"jQueryElement",{set:function(t){if(!(t instanceof jQuery))return s.a.debug.error("Tried to assign a non jQuery element to PennElement named "+e);if(a)return i=t;let n=i.data("events");n&&$.each(n,(function(){$.each(this,(function(){t.bind(this.type,this.handler)}))}));for(let e in o)t.css(...o[e]);i=t,a=!0},get:function(){return i}}),this.jQueryContainer=$("
      "),this.id=e,this.type=t,this.validate=()=>this.hasValidated=!0,this._printCallback=[],n.hasOwnProperty("end")&&(this.end=async function(){await n.end.apply(this)})}}s.a.PennElement=u;let h=(e,t,n,r)=>{let o="",a=e.replace(/^\.(settings|testNot|test)\./,"");Object(i.e)(a,"settings")/"settings".length<.5&&(o=" Did you mean to type ‘settings’?"),Object(i.e)(a,"test")/"test".length<.5&&(o=" Did you mean to type ‘test’?"),Object(i.e)(a,"testNot")/"testNot".length<.5&&(o=" Did you mean to type ‘testNot’?");let l={score:1,command:""};for(let e=0;e"+e.replace(a,l.command)+"?"),s.a.debug.error("Command ‘"+e+"’ unknown on "+t+" element ‘"+n+"’."+o)};class p{constructor(e,t){let n=new Proxy(this,{get:(e,i)=>{if(i in this)return e[i];{if("_runPromises"==i)return()=>this._runPromises.call(this);let e;try{e=this[i]}catch(e){return h(i,this.type,this._element.id,Object.getOwnPropertyNames(t.actions)),n}return void 0===e&&"string"==typeof i&&"nodeType"!=i&&h(i,this.type,this._element.id,Object.getOwnPropertyNames(t.actions)),e}}});if(this._proxy=n,e instanceof u)n._element=e;else if("string"==typeof e){let i;i=s.a.controllers.running?s.a.controllers.list[s.a.controllers.running.id]:s.a.controllers.underConstruction,Object.defineProperty(n,"_element",{get:()=>i._getElement(e,t.name)})}n.type=t.name,n._promises=[];for(let e in t.actions)n[e]=function(...r){let o=c((function(...r){s.a.debug.on&&s.a.debug.log("
      "+n._element.id+" ("+t.name+") Action command '"+e+"' running, params: "+JSON.stringify(Object(i.i)(r))+"
      "),t.actions[e].apply(this,r)}));return n._promises.push(()=>o.apply(n._element,r)),n};n.settings=new Proxy({},{get:(e,n)=>{if(n in e)return e[n];h(".settings."+n,this.type,this._element.id,Object.getOwnPropertyNames(t.settings))}});for(let e in t.settings)n.settings[e]=function(...r){let o=c((function(...r){s.a.debug.on&&s.a.debug.log("
      "+n._element.id+" ("+t.name+") Settings command '"+e+"' running, params: "+JSON.stringify(Object(i.i)(r))+"
      "),t.settings[e].apply(this,r)}));return n._promises.push(()=>o.apply(n._element,r)),n};n.test=new Proxy({},{get:(e,n)=>{if(n in e)return e[n];h(".test."+n,this.type,this._element.id,Object.getOwnPropertyNames(t.test))}}),n.testNot=new Proxy({},{get:(e,n)=>{if(n in e)return e[n];h(".testNot."+n,this.type,this._element.id,Object.getOwnPropertyNames(t.test))}});for(let e in t.test)n.test[e]=function(...r){let o=d((function(...r){return s.a.debug.on&&s.a.debug.log("
      "+n._element.id+" ("+t.name+") Test command '"+e+"' running, params: "+JSON.stringify(Object(i.i)(r))+"
      "),t.test[e].apply(this,r)}));return n._promises.push(()=>o.apply(n._element,r)),n.success=(...e)=>(o.success.apply(n._element,e),n),n.failure=(...e)=>(o.failure.apply(n._element,e),n),n.and=e=>(o.and.call(n._element,e),n),n.or=e=>(o.or.call(n._element,e),n),n},n.testNot[e]=function(...r){let o=d((function(...n){return s.a.debug.on&&s.a.debug.log(t.name+" testNot command "+e+" running, params: "+JSON.stringify(Object(i.i)(n))),!t.test[e].apply(this,n)}));return n._promises.push(()=>o.apply(n._element,r)),n.success=(...e)=>(o.success.apply(n._element,e),n),n.failure=(...e)=>(o.failure.apply(n._element,e),n),n.and=e=>(o.and.call(n._element,e),n),n.or=e=>(o.or.call(n._element,e),n),n};t.value&&Object.defineProperty(n,"value",{get:()=>t.value.apply(n._element)})}_runPromises(){return Object(i.d)(this._promises)()}}s.a.PennElementCommands=p;let f={actions:{scaling:function(e,t,n){let i=this.jQueryElement,r=0,o=0,a=0,l=0;const c=s.a.controllers.running,d=(e,t)=>{let n=0;if(!isNaN(Number(e)))return Number(e);if(e.match(/(\d+(.\d+)?)px/))n=Number(e.replace(/^[^\d]*(\d+(.\d+)?)px.*$/,"$1"));else{const t=$("
      ").css("width",e);n=t.appendTo(i.parent()).width(),t.remove()}return n/t},u=()=>{if(c!=s.a.controllers.running)return;this.jQueryContainer&&this.jQueryContainer instanceof jQuery&&this.jQueryContainer.parent().length&&(i=this.jQueryContainer);const e=i.width(),h=i.height(),p=$(window).width(),f=$(window).height();window.requestAnimationFrame(u),r=e,o=h,a=p,l=f;let m="";if(t.match(/page|screen/i)){m=a/lthis.jQueryElement.css(...e)),this.jQueryElement.addClass("PennController-"+this.type.replace(/[\s_]/g,"")),this.jQueryElement.addClass("PennController-"+this.id.replace(/[\s_]/g,""));let e=this.jQueryContainer;if(e.css("display","inherit"),"string"==typeof this.jQueryAlignment&&(this.jQueryAlignment.match(/left/i)?e.css("align-self","start"):this.jQueryAlignment.match(/center/i)?e.css("align-self","center"):this.jQueryAlignment.match(/right/i)&&e.css("align-self","end")),e.addClass("PennController-elementContainer").addClass("PennController-"+this.type.replace(/[\s_]+/g,"")+"-container").addClass("PennController-"+this.id.replace(/[\s_]+/g,"")+"-container").append(this.jQueryElement),t instanceof jQuery)t.append(e);else if(t instanceof p&&t._element.jQueryElement instanceof jQuery)t._element.jQueryElement.append(e);else if(void 0!==n){const r=s.a.controllers.running;i.j.call(e,t,n,$("body"),()=>r!=s.a.controllers.running||this._lastPrint!=a)}else s.a.controllers.running.element.append(e);this.cssContainer instanceof Array&&this.cssContainer.forEach(t=>e.css(...t));let r=$("
      ").css("display","inline-block").addClass("PennController-before"),o=$("
      ").css("display","inline-block").addClass("PennController-after");this.jQueryElement.before(r),this.jQueryElement.after(o);for(let e in this.jQueryBefore)this.jQueryBefore[e]&&this.jQueryBefore[e]._element&&await new Promise(t=>f.actions.print.call(this.jQueryBefore[e]._element,t,r));for(let e in this.jQueryAfter)this.jQueryAfter[e]&&this.jQueryAfter[e]._element&&await new Promise(t=>f.actions.print.call(this.jQueryAfter[e]._element,t,o))}else s.a.debug.warning("No jQuery instance to print for element "+this.id);this.printTime=Date.now();for(let e=0;e");t.before(n),r.b.Elements["get"+this.type](this.id).print(n)._runPromises().then(()=>{n.before(this.jQueryElement.parent()),n.remove(),e()})},remove:function(e){if(this.jQueryContainer instanceof jQuery&&this.jQueryContainer.detach(),this.jQueryElement instanceof jQuery?this.jQueryElement.detach():s.a.debug.error("No jQuery instance to remove for element "+this.id),this.jQueryBefore&&this.jQueryBefore.length)for(let e in this.jQueryBefore)this.jQueryBefore[e]._element&&this.jQueryBefore[e]._element.jQueryElement instanceof jQuery&&this.jQueryBefore[e]._element.jQueryElement.detach();if(this.jQueryAfter&&this.jQueryAfter.length)for(let e in this.jQueryAfter)this.jQueryAfter[e]._element&&this.jQueryAfter[e]._element.jQueryElement instanceof jQuery&&this.jQueryAfter[e]._element.jQueryElement.detach();e()},wait:function(e,t){if("first"==t&&this.hasValidated)e();else{let n=!1,i=this.validate;if(this.validate=()=>{if(i.apply(this),!n)if(t instanceof Object&&t._runPromises&&t.success){let i=this.disabled;this.jQueryElement.attr("disabled",!0),this.disabled="tmp",t._runPromises().then(t=>{"success"==t&&(n=!0,e()),"tmp"==this.disabled&&(this.disabled=i,this.jQueryElement.attr("disabled",i))})}else n=!0,e()},"number"==typeof t&&t>0){let e=Date.now(),t=()=>{Date.now()-e<=0?this.validate():window.requestAnimationFrame(t)};window.requestAnimationFrame(t)}}}},settings:{after:function(e,t){t._element&&t._element.jQueryElement instanceof jQuery?(t._element.jQueryAfter instanceof Array&&(t._element.jQueryAfter=t._element.jQueryAfter.filter(e=>e._element!=this)),this.jQueryElement instanceof jQuery&&this.jQueryElement.printed()&&(t=t.print(this.jQueryContainer.find(".PennController-after"))),t._runPromises().then(()=>{this.jQueryAfter.push(t),e()})):(s.a.debug.error("Tried to add an invalid element after element named "+this.id),e())},before:function(e,t){t._element&&t._element.jQueryElement instanceof jQuery?(t._element.jQueryBefore instanceof Array&&(t._element.jQueryBefore=t._element.jQueryBefore.filter(e=>e._element!=this)),this.jQueryElement instanceof jQuery&&this.jQueryElement.printed()&&t.print(this.jQueryContainer.find(".PennController-"+this.type+"-before")),t._runPromises().then(()=>{this.jQueryBefore.push(t),e()})):(s.a.debug.error("Tried to add an invalid element before element named "+this.id),e())},bold:function(e){this.jQueryElement instanceof jQuery?this.jQueryElement.css("font-weight","bold"):s.a.debug.error("Element named "+this.id+" has not jQuery element to render as bold"),e()},center:function(e){this.jQueryElement instanceof jQuery?(this.jQueryAlignment="center",this.jQueryElement.parent().length&&this.jQueryContainer.css("align-self","center")):s.a.debug.error("Element named "+this.id+" has not jQuery element to render as centered"),e()},color:function(e,t){this.jQueryElement&&"string"==typeof t?this.jQueryElement.css("color",t):s.a.debug.error("Element named "+this.id+" has not jQuery element to render as "+t),e()},cssContainer:function(e,...t){this.cssContainer||(this.cssContainer=[]),this.cssContainer.push(t),this.jQueryContainer.printed()&&this.jQueryContainer.css(...t),e()},css:function(e,...t){this.cssToApply||(this.cssToApply=[]),this.cssToApply.push(t),this.jQueryElement instanceof jQuery?this.jQueryElement.css(...t):s.a.debug.error("Element named "+this.id+" has not jQuery element on which to apply the CSS"),e()},disable:function(e){this.hasOwnProperty("jQueryElement")&&this.jQueryElement instanceof jQuery?this.jQueryElement.attr("disabled",!0).addClass("PennController-disabled"):s.a.debug.error("No jQuery instance to disable for element "+this.id),e()},enable:function(e){this.hasOwnProperty("jQueryElement")&&this.jQueryElement instanceof jQuery?this.jQueryElement.removeAttr("disabled").removeClass("PennController-disabled"):s.a.debug.error("No jQuery instance to enable for element "+this.id),e()},hidden:function(e){this.hasOwnProperty("jQueryElement")&&this.jQueryElement instanceof jQuery?this.jQueryElement.css({visibility:"hidden"}):s.a.debug.error("No jQuery instance to hide for element "+this.id),e()},italic:function(e){this.jQueryElement instanceof jQuery?this.jQueryElement.css("font-style","italic"):s.a.debug.error("Element named "+this.id+" has not jQuery element to render in italic"),e()},left:function(e){this.jQueryElement instanceof jQuery?(this.jQueryAlignment="left",this.jQueryElement.parent().length&&this.jQueryContainer.css("align-self","left")):s.a.debug.error("Element named "+this.id+" has not jQuery element to render as aligned to the left"),e()},log:function(e,t){this.log=void 0===t||t,e()},once:function(e){if(this.hasValidated)this.disabled=!0,this.jQueryElement.attr("disabled",!0);else{let e=this.validate;this.validate=()=>{e.apply(this),this.disabled=!0,this.jQueryElement.attr("disabled",!0)}}e()},right:function(e){this.jQueryElement instanceof jQuery?(this.jQueryAlignment="right",this.jQueryElement.parent().length&&this.jQueryContainer.css("align-self","right")):s.a.debug.error("Element named "+this.id+" has not jQuery element to render as aligned to the right"),e()},size:function(e,t,n){this.jQueryElement instanceof jQuery?(this.jQueryElement.width(t),this.jQueryElement.height(n),this.jQueryContainer instanceof jQuery&&("string"==typeof t&&t.match(/%$/)&&this.jQueryContainer.width("100%"),"string"==typeof n&&n.match(/%$/)&&this.jQueryContainer.height("100%"))):s.a.debug.error("Element named "+this.id+" has not jQuery element to render as aligned to the right"),e()},visible:function(e){this.hasOwnProperty("jQueryElement")&&this.jQueryElement instanceof jQuery?this.jQueryElement.css({visibility:"visible"}):s.a.debug.error("No jQuery instance to make visible for element "+this.id),e()}},test:{printed:function(){return!!(this.hasOwnProperty("jQueryElement")&&this.jQueryElement instanceof jQuery)&&this.jQueryElement.printed()}}};s.a.elements.standardCommands=f,r.b.Elements.jump=function(e){var t;"string"==typeof e&&(t=e,e=e=>e==t);let n=-1;const r=e=>s.a.runningOrder&&e()||setTimeout(()=>r(e),50);new Promise(e=>r(e)).then(()=>{console.log("ro",s.a.runningOrder);for(let t=0;tnew Promise(e=>{if(n<0)return e();s.a.runningOrder.active.splice(s.a.runningOrder.runningIndex+1,s.a.runningOrder.active.length,...s.a.runningOrder.original.slice(n,s.a.runningOrder.original.length)),e()});return{_promises:[o],_runPromises:()=>Object(i.d)([o])()}},r.b.Elements.fullscreen=function(){const e=()=>new Promise(e=>{if(document.documentElement.requestFullscreen)return document.documentElement.requestFullscreen().then(e).catch(e);document.documentElement.mozRequestFullScreen?document.documentElement.mozRequestFullScreen():document.documentElement.webkitRequestFullscreen?document.documentElement.webkitRequestFullscreen():document.documentElement.msRequestFullscreen&&document.documentElement.msRequestFullscreen(),e()});return{_promises:[e],_runPromises:()=>Object(i.d)([e])()}},r.b.Elements.exitFullscreen=function(){const e=()=>new Promise(e=>{if(document.exitFullscreen)return document.exitFullscreen().then(e).catch(e);document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen(),e()});return{_promises:[e],_runPromises:()=>Object(i.d)([e])()}},r.b.Elements.clear=function(){const e=()=>new Promise(async e=>{let t=s.a.controllers.list[s.a.controllers.running.id];for(let e in t.elements)for(let n in t.elements[e]){let i=t.elements[e][n],s=r.b.Elements["get"+i.type](i.id);await s.remove()._runPromises()}e()});return{_promises:[e],_runPromises:()=>Object(i.d)([e])()}},r.b.Elements.end=function(){const e=()=>new Promise(async e=>{await s.a.controllers.running.endTrial(),e()});return{_promises:[e],_runPromises:()=>Object(i.d)([e])()}};let m={};r.b._AddElementType=function(e,t){m.hasOwnProperty(e)&&s.a.debug.error("Element type "+e+" defined more than once"),m[e]=function(t){let n=new t(s.a);n.hasOwnProperty("actions")||(n.actions={}),n.hasOwnProperty("settings")||(n.settings={}),n.hasOwnProperty("test")||(n.test={});for(let e in f.actions)n.actions.hasOwnProperty(e)||(n.actions[e]=f.actions[e]);for(let e in f.settings)n.settings.hasOwnProperty(e)||(n.settings[e]=f.settings[e]);for(let e in f.test)n.test.hasOwnProperty(e)||(n.test[e]=f.test[e]);for(let e in n.settings)n.actions.hasOwnProperty(e)||(n.actions[e]=n.settings[e]);let i=n.uponCreation;n.uponCreation=function(e){this.jQueryAfter=[],this.jQueryBefore=[],this.jQueryElement&&this.jQueryElement instanceof jQuery&&this.jQueryElement.removeAttr("style"),this.jQuerycontainer&&this.jQueryContainer instanceof jQuery&&(this.jQuerycontainer=$("
      ")),i instanceof Function?i.apply(this,[e]):e()};let r=n.end;return n.end=async function(){this.jQueryElement instanceof jQuery&&this.jQueryElement.remove();for(let e in this.jQueryBefore)this.jQueryBefore[e]._element&&this.jQueryBefore[e]._element.jQueryElement instanceof jQuery&&this.jQueryBefore[e]._element.jQueryElement.remove();for(let e in this.jQueryAfter)this.jQueryAfter[e]._element&&this.jQueryAfter[e]._element.jQueryElement instanceof jQuery&&this.jQueryAfter[e]._element.jQueryElement.remove();this.jQueryContainer instanceof jQuery&&this.jQueryContainer.remove(),r instanceof Function&&await r.apply(this)},n.name=e,n}(t),r.b.Elements["new"+e]=function(...t){let n=m[e],i=s.a.controllers.underConstruction;s.a.controllers.running&&(i=s.a.controllers.list[s.a.controllers.running.id]);let r="unnamed-"+e;t.length<1?t=[r]:"string"==typeof t[0]&&t[0].length>0&&(r=t[0]);let o=new u(r,e,n);l.call(o,t),n.hasOwnProperty("immediate")&&n.immediate instanceof Function&&n.immediate.apply(o,t);let a=o.id;for(let t=2;i.elements.hasOwnProperty(e)&&i.elements[e].hasOwnProperty(o.id);t++)o.id=a+String(t);a!=o.id&&(s.a.debug.warning("Found an existing "+o.type+" element named “"+a+"”--using name “"+o.id+"” instead for new element"),i.ambiguousElementNames.push(a)),i._addElement(o);let c=new p(o,n);if(c=c._proxy,c._promises.push(()=>new Promise(e=>{o.printTime=0,o.log=!1,e()})),c._promises.push(()=>new Promise(e=>n.uponCreation.apply(o,[e]))),i.defaultCommands.hasOwnProperty(e))for(let t in i.defaultCommands[e]){let n=i.defaultCommands[e][t];c._promises.push(()=>new Promise(e=>{"header"==n[2]&&0==s.a.controllers.running.options.runHeader?e():n[0].apply(o,[e,...n[1]])}))}return c},r.b.Elements["get"+e]=function(t){let n=s.a.controllers.underConstruction;s.a.controllers.running&&(n=s.a.controllers.list[s.a.controllers.running.id]);let i=m[e];return n.ambiguousElementNames.indexOf(t)>=0&&s.a.debug.error("Ambiguous use of get"+e+"(“"+t+"”): more than one elements were created with that name-- get"+e+"(“"+t+"”) will refer to the first one"),new p(t,i)._proxy},Object.defineProperty(r.b.Elements,"default"+e,{get:function(){let t=m[e],n={},i=function(){s.a.controllers.underConstruction.hasOwnProperty("defaultCommands")||(s.a.controllers.underConstruction.defaultCommands={}),s.a.controllers.underConstruction.defaultCommands.hasOwnProperty(e)||(s.a.controllers.underConstruction.defaultCommands[e]=[])};for(let r in t.actions)n[r]=function(...o){return i(),s.a.controllers.underConstruction.defaultCommands[e].push([t.actions[r],o]),n};n.settings={};for(let r in t.settings)n.settings[r]=function(...o){return i(),s.a.controllers.underConstruction.defaultCommands[e].push([t.settings[r],o]),n};return n}})},r.b._AddStandardCommands=function(e){let t=new e(s.a);for(let e in t)if(e.match(/^(actions|settings|test)$/))for(let n in t[e]){let i=t[e][n];if(f[e].hasOwnProperty(n))s.a.debug.error("There already is a standard "+e+" command named "+n);else if(i instanceof Function){f[e][n]=i;for(let t in m)m[t][e].hasOwnProperty(n)||(m[t][e][n]=i),"settings"!=e||m[t].actions.hasOwnProperty(n)||(m[t].actions[n]=i)}else s.a.debug.error("Standard "+e+" command "+n+" should be a function")}else s.a.debug.error("Standard command type unknown",e)}},function(e,t,n){"use strict";var i=n(1),r=n(2),s=n(0),o=n(3);const a=n(35);let l=[];async function c(e,t){const n=s.a.resources.list.filter(e=>e&&e.name==t);if(n.length<1)return;console.log("Processing",t);const r=await e.arrayBuffer();if(void 0===Object(i.a)(Object(i.c)(r.slice(0,28)),t))return console.log("Could not determine type for file",t);const o=URL.createObjectURL(e);n.forEach(e=>e.addURI(o))}s.a.utils.zip=a,s.a.utils.saveAs=o.saveAs,r.b.PreloadZip=function(){for(let e in arguments)l.push(arguments[e])},s.a.Prerun((function(){if(!l.length)return;const e=async function(e){try{const t=await fetch(e);s.a.debug.log("Download of "+e+" complete");const n=await t.blob(),i=new a.ZipReader(new a.BlobReader(n)),r=await i.getEntries();for(let e=0;e=0&&l.splice(t,1)}()};for(let t in l){let n=l[t],i=n.match(/^https?:\/\/.+\.(zip)$/i);"string"==typeof n&&i?"zip"==i[1].toLowerCase()&&e(n):s.a.debug.warning("Preload: entry #"+t+" is not a valid URL, ignoring it")}}))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";n(9);var i=n(2),r=n(0),s=n(1);r.a.tables={};var o={};let a=[];class l{constructor(e,t){if(!(e instanceof Array)||e.length<1||!Object.keys(e[0]).length)return r.a.debug.error("Invalid format for table when creating new table");this.id=t||"unnamed",this.table=e;for(let t in e[0])t.match(/^item$/i)&&(this.item=t),t.match(/^(group|list)$/i)&&(this.group=t),t.match(/^label$/i)&&(this.label=t)}setItem(e){return this.table[0].hasOwnProperty(e)?this.item=e:r.a.debug.warning("Error when setting table's item column: no column found with the name "+e),this}setGroup(e){return this.table[0].hasOwnProperty(e)?this.group=e:r.a.debug.warning("Error when setting table's group column: no column found with the name "+e),this}setLabel(e){return this.table[0].hasOwnProperty(e)?this.label=e:r.a.debug.warning("Error when setting table's label column: no column found with the name "+e),this}filter(...e){if(2==e.length&&"string"==typeof e[0]&&("string"==typeof e[1]||e[1]instanceof RegExp)){if(this.table[0].hasOwnProperty(e[0])){let t=e[1];"string"==typeof t&&(t=new RegExp("^"+t+"$"));let n=[];for(let i=0;ir[t]=n[e][i]),t.push(r)}}catch(e){t.push({})}try{let t=$.csv.toArrays(e,{separator:"\t"}),i=t[0];for(let e=1;er[n]=t[e][i]),n.push(r)}}catch(e){n.push({})}return Object.keys(t[0]).length>Object.keys(n[0]).length?t:Object.keys(n[0]).length?n:r.a.debug.error("Format of table is invalid")}let u=[],h=window.$.ajax;window.$.ajax=function(...e){if(e[0]&&e[0].url&&e[0].url.match(/allchunks=1$/)){let t=e[0].success;e[0].success=e=>{if(0==u.length)return t(e);let n,r=[];for(let s=u.length-1;s>=0;s--)n=s==u.length-1?n=>{i.b.AddTable(u[s].name,n),t(e)}:e=>{i.b.AddTable(u[s].name,e),r[0]()},r.push(()=>$.ajax({url:u[s].table,cache:!1,dataType:"text",success:n}));r[0]()}}return h(...e)},i.b.AddTable=function(e,t){if("string"!=typeof e||"string"!=typeof t)return r.a.debug.error("Table "+e+" not added: tables and table names should be strings");if(r.a.tables.hasOwnProperty(e)&&r.a.debug.warning("A table named "+e+" already exists; overriding it"),t.match(/^http/))u.push({name:e,table:t});else{if(!(t=d(t)))return r.a.debug.error("Table "+e+" does not have the right format.");t=new l(t,e),r.a.tables[e]=t}},i.b.GetTable=function(e){return new c(e)};let p,f=[];i.b.Template=function(e,t){if(window.items)for(let e in window.items)r.a.tmpItems.indexOf(window.items[e])<0&&r.a.tmpItems.push(window.items[e]);let n={PennTemplate:[]};return r.a.tmpItems.push(n),f.push((function(){let i,d=r.a.tmpItems.length;if(e instanceof Function){t=e;let n=Object.keys(r.a.tables);if(!(n.length&&r.a.tables[n[0]]instanceof l))return r.a.debug.error("No valid table detected");i=r.a.tables[n[0]]}else if("string"==typeof e){if(!r.a.tables.hasOwnProperty(e)){let t=Object.keys(r.a.tables),n="";for(let i=0;i’?");return r.a.debug.error("No table found with name "+e+"."+n)}if(!(r.a.tables[e]instanceof l))return r.a.debug.error("Table "+e+" does not have the right format.");i=r.a.tables[e]}else{if(!(e instanceof c))return r.a.debug.error("Bad format for Template's first argument (should be a PennController table, table name or function from rows to Ibex elements)");if(Object.keys(r.a.tables).length<1)return r.a.debug.error("No table was defined");if(e.name==o)i=r.a.tables[Object.keys(r.a.tables)[0]];else{if(!e.name||!r.a.tables.hasOwnProperty(e.name)){let t=Object.keys(r.a.tables),n="";for(let i=0;i’?");return r.a.debug.error("No table named "+e.name+" was found."+n)}i=r.a.tables[e.name]}for(let t=0;t{let t=h.filter((t,n)=>t==e.groups[n]);h.indexOf(e.runningGroup)>-1&&t.length==e.groups.length&&t.length==h.length&&(u=e.runningGroup)}),void 0===u){let e=window.__counter_value_from_server__;"number"==typeof window.counterOverride&&(e=counterOverride),u=h[e%h.length]}a.push({runningGroup:u,groups:h})}let p=[];for(let e=0;e{if(n in i.table[e])return t[n];{let t=Object.keys(i.table[e]),o="";for(let e=0;e’?");r.a.debug.error("No column named ‘"+n+"’ found in table "+i.id+"."+o)}return""}});try{n=t.call(null,a)}catch(e){window.onerror(e.name+": "+e.message,"include=data","inside PennController.Template")}n instanceof Array?n.length%2&&"string"==typeof n[0]&&(o=n[0],n.splice(0,1)):(o=n.useLabel,n.addToItems=!1,n=["PennController",n]),o||(o=i.label&&i.table[e].hasOwnProperty(i.label)?i.table[e][i.label]:i.item&&i.table[e].hasOwnProperty(i.item)?"Item-"+i.table[e][i.item]:"Item-"+e);let l=[o];for(let t in n)n[t]instanceof Object&&(n[t]._PennController={table:i,row:e}),l.push(n[t]);p.push(l)}for(n.PennTemplate=p;r.a.tmpItems.length>d;)r.a.tmpItems.pop()})),window.items||(window.items=[]),{log:()=>r.a.debug.error("Tried to call .log command on Template(); .log commands should be called on newTrial()"),label:()=>r.a.debug.error("Tried to call .label command on Template(); .label commands should be called on newTrial()"),setOption:()=>r.a.debug.error("Tried to call .setOption command on Template(); .setOption commands should be called on newTrial()"),noHeader:()=>r.a.debug.error("Tried to call .noHeader command on Template(); .noHeader commands should be called on newTrial()"),noFooter:()=>r.a.debug.error("Tried to call .noFooter command on Template(); .noFooter commands should be called on newTrial()"),noTrialLog:()=>r.a.debug.error("Tried to call .noTrialLog command on Template(); .noTrialLog commands should be called on newTrial()")}},i.b.FeedItems=(e,t)=>i.b.Template(e,t),$(document).ready((function(){p=document.createElement("P"),p.style["text-align"]="center",p.innerHTML="Loading, please wait...",p.id="FirstLoadingMessage",document.body.appendChild(p)})),r.a.Prerun(()=>{for(let e in window.CHUNKS_DICT){if(e.match(/\.(html?|mp3)$/i))continue;let t=d(window.CHUNKS_DICT[e]);t?(t=new l(t,e),r.a.tables[e]=t):(t=$.csv.toObjects(window.CHUNKS_DICT[e],{separator:"\t"}),Object.keys(t[0]).length>1&&(t=new l(t,e),r.a.tables[e]=t))}for(let e=0;e=t.end&&(l=!0),t.state.rowNum++,t.state.colNum=1}function d(){if(void 0===t.onParseValue)s.push(a);else{var e=t.onParseValue(a,t.state);!1!==e&&s.push(e)}a="",o=0,t.state.colNum++}var u=RegExp.escape(n),h=RegExp.escape(i),p=/(D|S|\r\n|\n|\r|[^DS\r\n]+)/,f=p.source;return f=(f=f.replace(/S/g,u)).replace(/D/g,h),p=new RegExp(f,"gm"),e.replace(p,(function(e){if(!l)switch(o){case 0:if(e===n){a+="",d();break}if(e===i){o=1;break}if(/^(\r\n|\n|\r)$/.test(e)){d(),c();break}a+=e,o=3;break;case 1:if(e===i){o=2;break}a+=e,o=1;break;case 2:if(e===i){a+=e,o=1;break}if(e===n){d();break}if(/^(\r\n|\n|\r)$/.test(e)){d(),c();break}throw new Error("CSVDataError: Illegal State [Row:"+t.state.rowNum+"][Col:"+t.state.colNum+"]");case 3:if(e===n){d();break}if(/^(\r\n|\n|\r)$/.test(e)){d(),c();break}if(e===i)throw new Error("CSVDataError: Illegal Quote [Row:"+t.state.rowNum+"][Col:"+t.state.colNum+"]");throw new Error("CSVDataError: Illegal Data [Row:"+t.state.rowNum+"][Col:"+t.state.colNum+"]");default:throw new Error("CSVDataError: Unknown State [Row:"+t.state.rowNum+"][Col:"+t.state.colNum+"]")}})),0!==s.length&&(d(),c()),r},splitLines:function(e,n){if(e){var i=(n=n||{}).separator||t.csv.defaults.separator,r=n.delimiter||t.csv.defaults.delimiter;n.state=n.state||{},n.state.rowNum||(n.state.rowNum=1);var s=[],o=0,a="",l=!1,c=RegExp.escape(i),d=RegExp.escape(r),u=/(D|S|\n|\r|[^DS\r\n]+)/,h=u.source;return h=(h=h.replace(/S/g,c)).replace(/D/g,d),u=new RegExp(h,"gm"),e.replace(u,(function(e){if(!l)switch(o){case 0:if(e===i){a+=e,o=0;break}if(e===r){a+=e,o=1;break}if("\n"===e){p();break}if(/^\r$/.test(e))break;a+=e,o=3;break;case 1:if(e===r){a+=e,o=2;break}a+=e,o=1;break;case 2:var t=a.substr(a.length-1);if(e===r&&t===r){a+=e,o=1;break}if(e===i){a+=e,o=0;break}if("\n"===e){p();break}if("\r"===e)break;throw new Error("CSVDataError: Illegal state [Row:"+n.state.rowNum+"]");case 3:if(e===i){a+=e,o=0;break}if("\n"===e){p();break}if("\r"===e)break;if(e===r)throw new Error("CSVDataError: Illegal quote [Row:"+n.state.rowNum+"]");throw new Error("CSVDataError: Illegal state [Row:"+n.state.rowNum+"]");default:throw new Error("CSVDataError: Unknown state [Row:"+n.state.rowNum+"]")}})),""!==a&&p(),s}function p(){if(o=0,n.start&&n.state.rowNum=n.end&&(l=!0),n.state.rowNum++}},parseEntry:function(e,t){var n=t.separator,i=t.delimiter;t.state.rowNum||(t.state.rowNum=1),t.state.colNum||(t.state.colNum=1);var r=[],s=0,o="";function a(){if(void 0===t.onParseValue)r.push(o);else{var e=t.onParseValue(o,t.state);!1!==e&&r.push(e)}o="",s=0,t.state.colNum++}if(!t.match){var l=RegExp.escape(n),c=RegExp.escape(i),d=/(D|S|\n|\r|[^DS\r\n]+)/.source;d=(d=d.replace(/S/g,l)).replace(/D/g,c),t.match=new RegExp(d,"gm")}return e.replace(t.match,(function(e){switch(s){case 0:if(e===n){o+="",a();break}if(e===i){s=1;break}if("\n"===e||"\r"===e)break;o+=e,s=3;break;case 1:if(e===i){s=2;break}o+=e,s=1;break;case 2:if(e===i){o+=e,s=1;break}if(e===n){a();break}if("\n"===e||"\r"===e)break;throw new Error("CSVDataError: Illegal State [Row:"+t.state.rowNum+"][Col:"+t.state.colNum+"]");case 3:if(e===n){a();break}if("\n"===e||"\r"===e)break;if(e===i)throw new Error("CSVDataError: Illegal Quote [Row:"+t.state.rowNum+"][Col:"+t.state.colNum+"]");throw new Error("CSVDataError: Illegal Data [Row:"+t.state.rowNum+"][Col:"+t.state.colNum+"]");default:throw new Error("CSVDataError: Unknown State [Row:"+t.state.rowNum+"][Col:"+t.state.colNum+"]")}})),a(),r}},helpers:{collectPropertyNames:function(e){var t=[],n=[],i=[];for(t in e)for(n in e[t])e[t].hasOwnProperty(n)&&i.indexOf(n)<0&&"function"!=typeof e[t][n]&&i.push(n);return i}},toArray:function(e,n,i){n=void 0!==n?n:{};var r={};r.callback=void 0!==i&&"function"==typeof i&&i,r.separator="separator"in n?n.separator:t.csv.defaults.separator,r.delimiter="delimiter"in n?n.delimiter:t.csv.defaults.delimiter;var s=void 0!==n.state?n.state:{};n={delimiter:r.delimiter,separator:r.separator,onParseEntry:n.onParseEntry,onParseValue:n.onParseValue,state:s};var o=t.csv.parsers.parseEntry(e,n);if(!r.callback)return o;r.callback("",o)},toArrays:function(e,n,i){n=void 0!==n?n:{};var r={};r.callback=void 0!==i&&"function"==typeof i&&i,r.separator="separator"in n?n.separator:t.csv.defaults.separator,r.delimiter="delimiter"in n?n.delimiter:t.csv.defaults.delimiter;var s;if(void 0!==(n={delimiter:r.delimiter,separator:r.separator,onPreParse:n.onPreParse,onParseEntry:n.onParseEntry,onParseValue:n.onParseValue,onPostParse:n.onPostParse,start:n.start,end:n.end,state:{rowNum:1,colNum:1}}).onPreParse&&n.onPreParse(e,n.state),s=t.csv.parsers.parse(e,n),void 0!==n.onPostParse&&n.onPostParse(s,n.state),!r.callback)return s;r.callback("",s)},toObjects:function(e,n,i){n=void 0!==n?n:{};var r={};r.callback=void 0!==i&&"function"==typeof i&&i,r.separator="separator"in n?n.separator:t.csv.defaults.separator,r.delimiter="delimiter"in n?n.delimiter:t.csv.defaults.delimiter,r.headers="headers"in n?n.headers:t.csv.defaults.headers,n.start="start"in n?n.start:1,r.headers&&n.start++,n.end&&r.headers&&n.end++;var s,o=[];n={delimiter:r.delimiter,separator:r.separator,onPreParse:n.onPreParse,onParseEntry:n.onParseEntry,onParseValue:n.onParseValue,onPostParse:n.onPostParse,start:n.start,end:n.end,state:{rowNum:1,colNum:1},match:!1,transform:n.transform};var a={delimiter:r.delimiter,separator:r.separator,start:1,end:1,state:{rowNum:1,colNum:1}};void 0!==n.onPreParse&&n.onPreParse(e,n.state);var l=t.csv.parsers.splitLines(e,a),c=t.csv.toArray(l[0],n);s=t.csv.parsers.splitLines(e,n),n.state.colNum=1,n.state.rowNum=c?2:1;for(var d=0,u=s.length;d-1&&(d=d.replace(new RegExp(r.delimiter,"g"),r.delimiter+r.delimiter));var u="\n|\r|S|D";u=(u=u.replace("S",r.separator)).replace("D",r.delimiter),d.search(u)>-1&&(d=r.delimiter+d+r.delimiter),o.push(d)}c+=o.join(r.separator)+"\n"}if(!r.callback)return c;r.callback("",c)},fromObjects:function(e,n,i){n=void 0!==n?n:{};var r={};if(r.callback=void 0!==i&&"function"==typeof i&&i,r.separator="separator"in n?n.separator:t.csv.defaults.separator,r.delimiter="delimiter"in n?n.delimiter:t.csv.defaults.delimiter,r.headers="headers"in n?n.headers:t.csv.defaults.headers,r.sortOrder="sortOrder"in n?n.sortOrder:"declare",r.manualOrder="manualOrder"in n?n.manualOrder:[],r.transform=n.transform,"string"==typeof r.manualOrder&&(r.manualOrder=t.csv.toArray(r.manualOrder,r)),void 0!==r.transform){var s,o=e;for(e=[],s=0;s0){var d,u=[].concat(r.manualOrder);for(d=0;d{let n=Object.getOwnPropertyDescriptors(t);for(let t in n){let i=n[t];i.value instanceof Function?e[t]=i.value:i.get instanceof Function&&Object.defineProperty(e,t,i)}};window.PennController.ResetPrefix=function(e){if("string"==typeof e){if(window[e])throw"ERROR: prefix string already used for another JS object";window[e]={};var t=window[e]}else t=window;n(t,window.PennController.Elements),n(t,window.PennController)}},function(e,t,n){"use strict";var i=n(0),r=n(2);i.a.Prerun(()=>{let e=[];function t(t){return t instanceof r.a?e.indexOf(t)<0&&t.addToItems?[t.useLabel||"unlabeled","PennController",t]:null:t}if(window.items instanceof Array)for(let t=0;t2)for(let n=2;n2)for(let n=2;ne instanceof Array&&e.length>2),window.shuffleSequence||(window.conf_shuffleSequence=window.seq(window.anyType))})},function(e,t){window.PennController._AddElementType("Audio",(function(e){this.immediate=function(t,n){"string"==typeof t&&void 0===n&&(n=t);let i=!n.match(/^http/i);this.resource=e.resources.new(n,(function(e,t){const i=document.createElement("audio");i.muted=!0;let r=!1;const s=()=>{if(r||(console.log("Starting to preload "+n,i),i.muted=!0,i.play()),r=!0,i.buffered.length&&i.seekable.length){const e=i.buffered.end(0)/i.seekable.end(0);if(i.currentTime==i.duration||e>=.95)return i.pause(),i.currentTime=0,i.muted=!1,r=!1,t(i)}return window.requestAnimationFrame(s),!0};i.addEventListener("progress",()=>r||s()),i.src=e,i.load()}),i),void 0!==t&&"string"==typeof t&&0!=t.length||(t="Audio"),this.id=t},this.uponCreation=function(e){this.resource.object.controls=!0,this.audio=this.resource.object,this.hasPlayed=!1,this.disabled=!1,this.resource.object.style=null,this.jQueryElement=$(this.audio),this.jQueryElement.removeClass(),this.jQueryDisable=null,this.playEvents=[],this.endEvents=[],this.pauseEvents=[],this.seekEvents=[],this.bufferEvents=[],this.whatToSave=[],this.resource.object.onplay=()=>{this.playEvents.push(["play",this.audio.currentTime,Date.now()])},this.resource.object.onended=()=>{this.hasPlayed=!0,this.endEvents.push(["end",this.audio.currentTime,Date.now()])},this.resource.object.onpause=()=>{this.pauseEvents.push(["pause",this.audio.currentTime,Date.now()])},this.resource.object.onseeked=()=>{this.seekEvents.push(["seek",this.audio.currentTime,Date.now()])},this.resource.object.onwaiting=()=>{this.bufferEvents.push(["buffer",this.audio.currentTime,Date.now()])},this.printDisable=e=>{void 0===e&&(e=this.disabled),(!0===e||isNaN(Number(e)))&&(e=.5),this.jQueryDisable instanceof jQuery&&this.jQueryDisable.remove(),this.jQueryDisable=$("
      ").css({position:"absolute",display:"inline-block","background-color":"gray",opacity:e,width:this.jQueryElement.width(),height:this.jQueryElement.height()}),this.jQueryElement.before(this.jQueryDisable)},e()},this.end=function(){if(this.whatToSave&&this.whatToSave.indexOf("play")>-1){this.playEvents.length||e.controllers.running.save(this.type,this.id,"play","NA","Never");for(let t in this.playEvents)e.controllers.running.save(this.type,this.id,...this.playEvents[t])}if(this.whatToSave&&this.whatToSave.indexOf("end")>-1){this.endEvents.length||e.controllers.running.save(this.type,this.id,"end","NA","Never");for(let t in this.endEvents)e.controllers.running.save(this.type,this.id,...this.endEvents[t])}if(this.whatToSave&&this.whatToSave.indexOf("pause")>-1){this.pauseEvents.length||e.controllers.running.save(this.type,this.id,"pause","NA","Never");for(let t in this.pauseEvents)e.controllers.running.save(this.type,this.id,...this.pauseEvents[t])}if(this.whatToSave&&this.whatToSave.indexOf("seek")>-1){this.seekEvents.length||e.controllers.running.save(this.type,this.id,"seek","NA","Never");for(let t in this.seekEvents)e.controllers.running.save(this.type,this.id,...this.seekEvents[t])}if(this.bufferEvents)for(let t in this.bufferEvents)e.controllers.running.save(this.type,this.id,...this.bufferEvents[t]);this.resource.object.pause(),this.resource.object.currentTime=0,this.jQueryDisable&&this.jQueryDisable.remove()},this.value=function(){return this.endEvents.length?this.endEvents[this.endEvents.length-1][2]:0},this.actions={play:function(t,n){this.hasOwnProperty("audio")&&this.audio instanceof Audio?(n&&"once"==n?this.audio.removeAttribute("loop"):n&&(this.audio.loop=!0),this.audio.play()):e.debug.error("No audio to play for element ",this.id),t()},pause:function(e){this.audio.pause(),e()},print:function(t,...n){e.elements.standardCommands.actions.print.apply(this,[()=>{(this.disabled||null!==this.disabled&&!1!==this.disabled&&!isNaN(this.disabled))&&this.printDisable(this.disabled),t()},...n])},stop:function(e){this.audio.currentTime=this.audio.duration,e()},wait:function(e,t){if("first"==t&&this.hasPlayed)e();else{let n=!1,i=this.audio.onended;this.audio.onended=function(...r){if(i.apply(this,r),!n)if(t instanceof Object&&t._runPromises&&t.success){let i=this.disabled;this.disabled="tmp",t._runPromises().then(t=>{"success"==t&&(n=!0,e()),"tmp"==this.disabled&&(this.disabled=i)})}else n=!0,e()}}}},this.settings={disable:function(e,t){this.jQueryElement.addClass("PennController-disabled"),this.jQueryContainer.addClass("PennController-disabled"),t=!(!isNaN(t)&&null!==t)||Number(t),this.disabled=t,this.printDisable(t),e()},enable:function(e){this.jQueryDisable instanceof jQuery&&(this.disabled=!1,this.jQueryDisable.remove(),this.jQueryDisable=null,this.jQueryElement.removeClass("PennController-disabled"),this.jQueryContainer.removeClass("PennController-disabled"),this.jQueryElement.attr("controls",!0)),e()},once:function(e){if(this.hasPlayed)this.disabled=!0,this.printDisable();else{let e=this.audio.onended,t=this;this.audio.onended=function(...n){e.apply(this,n),t.disabled=!0,t.printDisable()}}e()},log:function(e,...t){1==t.length&&"string"==typeof t[0]?this.whatToSave.push(t[0]):t.length>1?this.whatToSave=this.whatToSave.concat(t):this.whatToSave=["play","end","pause","seek"],e()}},this.test={hasPlayed:function(){return this.hasPlayed},playing:function(){return this.audio.currentTime&&!this.audio.paused}}}))},function(e,t){window.PennController._AddElementType("Button",(function(e){this.immediate=function(e,t){void 0===t&&(t=e,void 0!==e&&"string"==typeof e&&0!=e.length||(e="Button"),this.id=e),this.initialText=t},this.uponCreation=function(e){this.text=this.initialText,this.jQueryElement=$("").click((function(){c.remove(),window.webgazer.reg.RidgeWeightedReg.call(window.webgazer.getRegression()[0]),t(n,i,r,s-1)})).css("margin","auto"))):(l=!0,c.remove(),m().removeMouseEventListeners(),n())},3e3)};if(l)u();else{g(!0);const e=48,t=48,n=120;let i=[];const r=async s=>{const o=i.shift(),a=$("
      ").css({position:"fixed",display:"block",width:e+"px",height:t+"px",background:"green","border-radius":"100%",left:o[0],top:o[1],"z-index":999999});await new Promise(e=>setTimeout(e,750)),$("body").append(a),p.play(),await new Promise(e=>setTimeout(e,250));let l=n;const c=()=>{l%2&&d({clientX:o[0]+e/2,clientY:o[1]+t/2}),0==l?(a.detach(),i.length?r():u()):(l--,window.requestAnimationFrame(c))};c()},s=()=>$("body").append($("").bind("click",n=>{m().removeMouseEventListeners(),g(!1),$(n.target).detach();const s=window.innerWidth,o=window.innerHeight;i=[[(s-e)/2,(o-t)/2],...[[0,0],[(s-e)/2,0],[s-e,o-t],[(s-e)/2,o-t],[s-e,(o-t)/2],[s-e,0],[0,(o-t)/2],[0,o-t]].sort(e=>.5-Math.random()),[(s-e)/2,(o-t)/2]],r()}).css({position:"fixed",display:"block",left:"50vw",top:"50vh",transform:"translate(-50%,-50%)"}));if(h)s();else{const e=$("

      Wait until your face is detected (you should see green contours around it) and then click anywhere on the page until you see a red dot

      ");e.css({position:"fixed",left:"50vw",top:"50vh",transform:"translate(-50%,-50%)"}),$("body").append(e);const t=()=>{h?(e.remove(),s()):window.requestAnimationFrame(t)};t()}}$("#webgazerVideoFeed").before(c)}(t,this,n,i)},hideFeedback:function(e){g(!1),e()},start:function(e){this.enabled=!0,i=this,e()},stop:function(e){this.enabled=!1,i=void 0,e()},stopTraining:function(e){m().removeMouseEventListeners(),m().showPredictionPoints(!1),e()},showFeedback:function(e){g(),e()},train:function(e,t){m().addMouseEventListeners(),this.trainOnMouseMove||document.removeEventListener("mousemove",c,!0),m().showPredictionPoints(t),e()}},this.settings={add:function(e,...t){for(let e=0;e=Number(e)}}}))},function(e,t){window.PennController._AddElementType("Function",(function(e){this.immediate=function(e,t){"function"==typeof e&&(t=e,void 0!==e&&"string"==typeof e&&0!=e.length||(e="Function"),this.id=e),this.function=t},this.uponCreation=function(t){e.controllers.running.hasOwnProperty("internalVariables")||(e.controllers.running.internalVariables={}),t()},this.end=function(){e.controllers.running.internalVariables=void 0},this.value=function(){return this.function.apply(e.controllers.running.internalVariables)},this.actions={call:async function(t,...n){await this.function.apply(e.controllers.running.internalVariables,n),t()}},this.test={is:function(t){let n=this.function.apply(e.controllers.running.internalVariables);return void 0===t?!n:n==t}}}))},function(e,t){window.PennController._AddElementType("Html",(function(e){function t(e,t){var n=$("label.error[for=__ALL_FIELDS__]");if(n.length>0)n.addClass("Form-error-text").text(t);else{var i=$("label.error[for="+escape(e)+"]");i.length>0?i.addClass("Form-error-text").text(t):alert(t)}}function n(){for(var e=this.jQueryElement[0],t=$(e).find("input[type=text]"),n=$(e).find("textarea"),i=0;i").html(htmlCodeToDOM({include:this.html})):this.jQueryElement=$("
      ").append(this.html),this.log=!1,this.checkboxWarningMessage="You must check the %name% checkbox to continue.",this.inputWarningMessage="The ‘%name%’ field is obligatory.",this.radioWarningMessage="You must select an option for ‘%name%’.",e()},this.end=function(){if(this.log){for(var t=this.jQueryElement[0],n=$(t).find("input[type=text]"),i=$(t).find("textarea"),r=0;rt(n),n.src=e}),i)},this.uponCreation=function(e){this.image=this.resource.object,this.image&&(this.image.style=null),this.jQueryElement=$(this.image),this.jQueryElement.removeClass(),e()},this.end=function(){this.log&&(this.printTime?e.controllers.running.save(this.type,this.id,"Print","NA",this.printTime,"NULL"):e.controllers.running.save(this.type,this.id,"Print","NA","Never","NULL"))},this.value=function(){return this.jQueryElement.parent().length}}))},function(e,t){window.PennController._AddElementType("Key",(function(e){this.immediate=function(t,...n){n.length<1&&(n=[t],void 0!==t&&"string"==typeof t&&0!=t.length||(t="Key"),this.id=t),this.keys=[],this.specialKeys=[];for(let i=0;i0?this.keys.push(String.fromCharCode(n[i])):"string"!=typeof n[i]?e.debug.error("Invalid key(s) passed to new Key ""+t+"" (should be a string or a key code number)",n[i]):n[i].isSpecialKey()||n[i].replace(/^(Left|Right)/i,"").isSpecialKey()?this.specialKeys.push(n[i].toUpperCase()):n[i].length&&this.keys.push(n[i].toUpperCase())},this.uponCreation=function(t){this.pressed=[],this.pressedWait=[],this.log=!1,this.enabled=!0,e.events.keypress(e=>{if(!this.enabled)return;let t=e.key.isSpecialKey(),n=e.key.toUpperCase(),i={0:"",1:"LEFT",2:"RIGHT"};(0==this.keys.length&&0==this.specialKeys.length||t&&this.specialKeys.filter(t=>t==n||t===i[e.location]+n).length||!t&&this.keys.filter(e=>e.indexOf(n)>-1).length)&&this.press(e.key)}),this.press=e=>{this.pressed.push(["PressedKey",e.toUpperCase(),Date.now(),"NULL"])},t()},this.end=function(){if(this.log&&this.log instanceof Array)if(0==this.pressed.length)e.controllers.running.save(this.type,this.id,"Key","NA","Never","NULL");else if(this.log.indexOf("all")>-1)for(let t in this.pressed)e.controllers.running.save(this.type,this.id,...this.pressed[t]);else if(this.log.indexOf("wait")>-1){let t=!1;for(let n in this.pressed)"Wait success"==this.pressed[n][3]&&(e.controllers.running.save(this.type,this.id,...this.pressed[n]),t=!0);t||e.controllers.running.save(this.type,this.id,"Key","NA","Never","(failed keypresses happened)")}else 1==this.pressed.length?e.controllers.running.save(this.type,this.id,...this.pressed[0]):(this.log.indexOf("first")>-1&&e.controllers.running.save(this.type,this.id,...this.pressed[0]),this.log.indexOf("last")>-1&&e.controllers.running.save(this.type,this.id,...this.pressed[this.pressed.length-1]))},this.value=function(){return this.pressed.length?this.pressed[this.pressed.length-1][1]:""},this.actions={wait:function(e,t){if("first"==t&&this.pressed.length)e();else{let n=!1,i=this.press,r=document.activeElement;for(;r;)r.disabled?(r.blur(),r=null):r=r.parentElement;this.press=r=>{if(i.apply(this,[r]),!n)if(t instanceof Object&&t._runPromises&&t.success){let i=this.enabled;this.enabled=0,t._runPromises().then(t=>{"success"==t?(this.pressed[this.pressed.length-1][3]="Wait success",n=!0,e()):this.pressed[this.pressed.length-1][3]="Wait failure",0===this.enabled&&(this.enabled=i)})}else this.pressed[this.pressed.length-1][3]="Wait success",n=!0,e()}}}},this.settings={callback:function(e,...t){let n=this.press;this.press=async function(e){if(n.apply(this,[e]),this.enabled)for(let e in t)await t[e]._runPromises()},e()},disable:function(e){this.enabled=!1,e()},enable:function(e){this.enabled=!0,e()},log:function(e,...t){t.length?this.log=t:this.log=["wait"],e()}},this.test={pressed:function(e,t){for(let n in this.pressed){let i=this.pressed[n][1];if(Number(e)>0&&i.toUpperCase()==String.fromCharCode(e).toUpperCase())return!0;if("string"==typeof e&&e.toUpperCase()==i.toUpperCase())return!0;if(void 0===e)return!0;if(t)return!1}return!1}}}))},function(e,t){window.PennController._AddElementType("MouseTracker",(function(e){let t,n;this.immediate=function(e){void 0!==e&&"string"==typeof e&&0!=e.length||(e="MouseTracker"),this.id=e,$(document).mousemove(e=>{t=e.clientX,n=e.clientY,this.move&&this.move instanceof Function&&this.enabled&&this.move(e)}),$(document).click(e=>{this.click&&this.click instanceof Function&&this.enabled&&this.click(e)})},this.uponCreation=function(e){this.coordinates=[],this.enabled=!1,this.callbacks=[],this.clickCallbacks=[],this.currentStream=[],this.log=[],this.clicks=[];let i=this;this.click=async e=>{if(this.enabled){this.clicks.push([Date.now(),e.clientX,e.clientY]);for(let t=0;t{if(this.currentStream.length>1){let e=this.currentStream[0][1],t=this.currentStream[0][2],n=this.currentStream[0][0];void 0===e&&(e=this.currentStream[1][1]),void 0===t&&(t=this.currentStream[1][2]);let i="x"+e+"y"+t+"w"+this.currentStream[0][3]+"h"+this.currentStream[0][4];for(let r=1;r=0?"+":"")+s,i+=(o>=0?"+":"")+o,e=this.currentStream[r][1],t=this.currentStream[r][2],n=this.currentStream[r][0]}let r="NULL";window.innerWidth==this.currentStream[0][3]&&window.innerHeight==this.currentStream[0][4]||(r="Size of window changed to "+window.innerWidth+" * "+window.innerHeight),this.coordinates.push([i,this.currentStream[0][0],r])}this.currentStream=[]},e()},this.end=function(){this.enabled=!1,this.finishStream&&this.finishStream instanceof Function&&this.finishStream(),this.log.map(t=>{"string"==typeof t&&(t.match(/move/i)?this.coordinates.map(t=>e.controllers.running.save(this.type,this.id,"Move",...t)):t.match(/click/i)&&this.clicks.map(t=>e.controllers.running.save(this.type,this.id,"Click",t[1]+":"+t[2],t[0],"NULL")))})},this.value=function(){return t&&n?t+"-"+n:"NA-NA"},this.actions={start:function(e){this.currentStream=[[Date.now(),t,n,window.innerWidth,window.innerHeight]],this.enabled=!0,e()},stop:function(e){this.enabled=!1,this.finishStream(),e()}},this.settings={callback:function(e,...t){0!=t.length&&("string"==typeof t[0]&&t[0].match(/click/i)?(t.shift(),this.clickCallbacks=this.clickCallbacks.concat(t)):this.callbacks=this.callbacks.concat(t),e())},log:function(e,...t){console.log("log what?",t),t.length?this.log=t:this.log=["clicks","movements"],e()}},this.test={over:function(i){return i instanceof jQuery?e.utils.overToScale.call(i,t,n):!!(i._element&&i._element.hasOwnProperty("jQueryElement")&&i._element.jQueryElement instanceof jQuery)&&e.utils.overToScale.call(i._element.jQueryElement,t,n)}}}))},function(e,t){window.PennController._AddElementType("Palette",(function(e){this.immediate=function(e,t){void 0===t&&(t=e),this.mode=t||"background",void 0!==e&&"string"==typeof e&&0!=e.length||(e="Palette"),this.id=e},this.uponCreation=function(e){this.currentColor=null,this.enabled=!0,this.elements=[],this.colors=[],this.brushes=[],this.log=!1,this.select=e=>{if(!this.enabled||!this.currentColor)return;let t=this.elements.map(e=>e[0]).indexOf(e);if(t<0)return;this.elements[t][1]=this.currentColor;let n=e.jQueryElement;this.brushes.push([e.id,this.currentColor,Date.now()]),"background"==this.mode?n.css("background-color",this.currentColor):(n._tinter&&n._tinter instanceof jQuery&&n._tinter.remove(),n._tinter=$("
      ").css({display:"block",position:"absolute",width:n.width(),height:n.height(),"margin-top":-1*n.width(),background:this.elements[t][1],opacity:.5}),n.before(n._tinter))},e()},this.end=function(){if(this.enabled=!1,$("#bod").css("cursor","default"),this.log){if("all"==this.log)for(let t=0;t{let s=i.apply(this,[r]);n||!this.enabled&&!s||(t instanceof Object&&t._runPromises&&t.success?t._runPromises().then(t=>{"success"==t&&(n=!0,e())}):(n=!0,e()))}}}},this.settings={addColor:function(t,n,...i){this.colors.indexOf(n)<0&&this.colors.push(n);let r=[],s=()=>{this.colors.indexOf(n)<0||(this.currentColor=n,$(".PennController-"+this.type+"-palette-selected").removeClass("PennController-"+this.type+"-palette-selected"),r.map(e=>e.jQueryElement.addClass("PennController-"+this.type+"-palette-selected")),$("#bod").css("cursor","crosshair"))};for(let t in i){let n=i[t];"string"==typeof n?e.events.keypress(e=>{n.toUpperCase().indexOf(String.fromCharCode(e.which).toUpperCase())>-1?s():27==e.which&&($(".PennController-"+this.type+"-palette-selected").removeClass("PennController-"+this.type+"-palette-selected"),$("#bod").css("cursor","default"),this.currentColor=null)}):n._element&&n._element.jQueryElement&&(n._element.jQueryElement.bind("click",s),n._element.jQueryElement.addClass("PennController-"+this.type+"-palette"),n._element.jQueryElement.addClass("PennController-"+this.id+"-palette"),r.push(n._element))}t()},addElement:function(e,...t){for(let e in t){let n=t[e];n._element&&n._element.jQueryElement&&(n._element.jQueryElement.bind("click",()=>{this.select(n._element)}),this.elements.map(e=>e[0]).indexOf(n._element)<0&&this.elements.push([n._element,null]))}e()},callback:function(e,...t){let n=this.select;this.select=async function(e){if(n.apply(this,[e]),this.enabled)for(let e in t)await t[e]._runPromises()},e()},enable:function(e){this.jQueryContainer.removeClass("PennController-disabled"),this.jQueryElement.removeClass("PennController-disabled"),this.enabled=!0,e()},disable:function(e){this.jQueryContainer.addClass("PennController-disabled"),this.jQueryElement.addClass("PennController-disabled"),this.enabled=!1,e()},log:function(e,t){this.log=t||"all",e()},once:function(e){if(this.brushes.length)this.enabled=!1,$(".PennController-"+this.type+"-palette-selected").removeClass("PennController-"+this.type+"-palette-selected"),$("#bod").css("cursor","default"),this.currentColor=null;else{let e=this.select;this.select=t=>{if(e.apply(this,[t]),this.enabled)return this.enabled=!1,$(".PennController-"+this.type+"-palette-selected").removeClass("PennController-"+this.type+"-palette-selected"),$("#bod").css("cursor","default"),this.currentColor=null,"once"}}e()},removeColor:function(e,t){let n=this.colors.indexOf(t);n>-1&&this.colors.splice(n,1),e()}},this.test={color:function(e,t){if(e._element&&e._element){let n=this.elements.map(e=>e[0]).indexOf(e._element);return!(n<0)&&this.elements[n][1]==t}return!1}}}))},function(e,t){window.PennController._AddElementType("Scale",(function(e){function t(){this.jQueryElement.find("input").attr("disabled",!0),this.jQueryElement.find("div,label").css("cursor",""),this.disabled=!0}function n(){this.jQueryElement.find("input").removeAttr("disabled"),this.jQueryElement.find("div").css("cursor","pointer"),this.disabled=!1}function i(e,t){if("slider"==this.scaleType?this.jQueryElement.find("input[type=range]")[0].value=e:this.jQueryElement.find(`input#${this.id}-${e}`).attr("checked",!0).change(),t){let t=this.buttons[e];null!=t&&""!=t||(t=e+1),this.choice(t)}}async function r(){let t=this.defaultValue,n=this.orientation,i=this.scaleType;if(this.jQueryElement.empty(),"slider"==i){var r=$("").attr({type:"range",min:"0",max:String(this.buttons.length-1),value:String((this.buttons.length-1)/2),step:"1"});Number(t)>=0&&Number(t)<=this.buttons.length-1&&r.attr("value",String(t)),this.disabled&&r.attr("disabled",!0),r[0].oninput=()=>{this.firstClick||(this.firstClick=Date.now())},r[0].onchange=()=>this.choice(r[0].value),"vertical"==n&&(r.attr("orient","vertical"),r.css({"writing-mode":"vertical-lr","-webkit-appearance":"slider-vertical"})),r.css({width:"100%",height:"100%"}),this.jQueryElement.append(r)}else{this.jQueryElement.css({display:"inline-flex","justify-content":"space-between"});for(let n=0;n").attr({for:this.id+"-"+n}).html(r).css("cursor","pointer"),o=$("").attr({name:this.id,value:r,type:"checkbox"==i?"checkbox":"radio",id:this.id+"-"+n}),a=$("
      ").addClass("option").css({cursor:"pointer",display:"flex","align-items":"center"}).append(o).append(s);r._runPromises&&r.print(s.empty())._runPromises(),t!=r&&t!=n||o.attr("checked",!0),this.disabled&&o.attr("disabled",!0),o[0].onchange=()=>{this.choice(this.buttons[n]||r,"checkbox"==i&&!o[0].checked),this.jQueryElement.find("label").css("outline","none"),"buttons"==i&&s.css("outline","dotted 1px black")},"buttons"==i&&o.css("display","none"),"top"==this.labels?a.css("flex-direction","column-reverse"):"bottom"==this.labels?a.css("flex-direction","column"):"left"==this.labels&&a.css("flex-direction","row-reverse"),this.jQueryElement.append(a),"radio"==i&&!1===this.labels?s.css("display","none"):this.buttons[n]instanceof e.PennElementCommands&&await this.buttons[n].print(s.empty())._runPromises()}"vertical"==n&&this.jQueryElement.css("flex-direction","column")}this.width||this.jQueryElement.css("max-width","max-content")}this.immediate=function(e,...t){t.length||(t=[e],void 0!==e&&"string"==typeof e&&0!=e.length||(e="Scale")),this.id=e,"string"!=typeof t[0]&&Number(t[0])>0?this.initialButtons=new Array(Number(t[0])):this.initialButtons=t},this.uponCreation=function(t){this.jQueryElement=$("
      ").css("display","inline-block"),this.choices=[],this.log=!1,this.labels=!1,this.disabled=!1,this.vertical=!1,this.scaleType="radio",this.defaultValue=null,this.orientation="horizontal",this.width=null,this.keys=[],this.buttons=this.initialButtons,this.choice=(e,t)=>{if(this.disabled)return;this.unselected=t||void 0,e&&e._runPromises&&(e=e._element.id);let n=null;"slider"==this.scaleType&&this.firstClick&&(n=Date.now()-this.firstClick,this.firstClick=void 0),this.choices.push([t?"Unselect":"Choice",e,Date.now(),n||"NULL"])},e.controllers.running.safeBind($(document),"keydown",e=>{if(!this.disabled)for(let t=0;t-1)for(let t in this.choices)e.controllers.running.save(this.type,this.id,...this.choices[t]);else this.log.indexOf("first")>-1&&e.controllers.running.save(this.type,this.id,...this.choices[0]),this.log.indexOf("last")>-1&&e.controllers.running.save(this.type,this.id,...this.choices[this.choices.length-1]);else e.controllers.running.save(this.type,this.id,"Choice","NA","Never","No selection happened")},this.value=function(){return this.choices.length&&void 0===this.unselected?this.choices[this.choices.length-1][1]:NaN},this.actions={print:async function(t,...n){await r.apply(this),e.elements.standardCommands.actions.print.apply(this,[t,...n])},select:function(t,n,r){for(var s=0;s=this.buttons.length)return t(e.debug.error("Option "+n+" not found for selection on Scale "+this.id));i.apply(this,[s,r]),t()},unselect:function(e){if("slider"==this.scaleType){let e=this.jQueryElement.find("input[type=range]")[0];e.value=(e.max-e.min)/2}else this.jQueryElement.find("input").removeAttr("checked").change();this.unselected=!0,e()},wait:function(e,t){if("first"==t&&this.choices.length)e();else{let n=!1,i=this.choice;this.choice=r=>{if(i.apply(this,[r]),!n)if(t instanceof Object&&t._runPromises&&t.success){let i=this.disabled;this.disabled="tmp",t._runPromises().then(t=>{"success"==t&&(n=!0,e()),"tmp"==this.disabled&&(this.disabled=i)})}else n=!0,e()}}}},this.settings={button:async function(e){this.scaleType="buttons",await r.apply(this),e()},callback:function(e,...t){let n=this.choice;this.choice=async function(e){let i=this.disabled;if(n.apply(this,[e]),!i)for(let e in t)await t[e]._runPromises()},e()},checkbox:async function(e){this.scaleType="checkbox",await r.apply(this),e()},default:function(t,n){this.buttons.indexOf(n)>-1||Number(n)>=0&&Number(n)"string"==typeof e&&1==e.length).length!=n.length)return t(e.debug.error("Every key should be a string of length 1 in Scale "+this.id,n));this.keys=n.map(e=>e.toUpperCase())}else this.buttons.filter(e=>"string"==typeof e&&1==e.length).length==this.buttons.length?this.keys=this.buttons.map(e=>e.toUpperCase()):this.keys=Array.from({length:this.buttons.length},(e,t)=>t+1);t()},label:async function(e,t,n){if(isNaN(Number(t))||t<0||t>=this.buttons.length)return e();this.buttons[t]=n,await r.apply(this),e()},labels:function(e,t){this.labels=t,e()},labelsPosition:async function(e,t){this.labels=t,await r.apply(this),e()},log:function(e,...t){t.length?this.log=t:this.log=["last"],e()},once:function(e){if(this.hasClicked)t.apply(this);else{let e=this.choice;this.choice=n=>{e.apply(this,[n]),t.apply(this)}}e()},radio:async function(e){this.scaleType="radio",await r.apply(this),e()},size:async function(t,n,i){this.width=n,await r.apply(this),e.elements.standardCommands.settings.size.apply(this,[t,n,i])},slider:async function(e){this.scaleType="slider",await r.apply(this),e()},vertical:async function(e){this.orientation="vertical",this.jQueryElement.parent().length&&await r.apply(this),e()}},this.test={selected:function(e){return!(!this.choices.length||this.unselected)&&(null==e||e==this.choices[this.choices.length-1][1])}}}))},function(e,t){window.PennController._AddElementType("Selector",(function(e){async function t(t,...n){let i=[];if(n.length)for(let t in n){if(!(n[t]._element&&n[t]._element.jQueryElement instanceof jQuery)){e.debug.error("Invalid element #"+t+" in shuffling selector "+this.id);continue}let r=this.elements.map(e=>e[0]).indexOf(n[t]._element);r<0?e.debug.error("Cannot shuffle element "+n[t]._element.id+" for it has not been added to selector "+this.id):i.push(r)}else i=[...new Array(this.elements.length)].map((e,t)=>t);let r=[...i];fisherYates(r);const s=[],o=i.map(e=>{const t=this.elements[e][0],n=t._lastPrint;if(void 0===n[0]){const n=t.jQueryContainer;if(n instanceof jQuery&&n.parent().length){const t=$("");n.before(t),s[e]=t}}else if(n[0]instanceof jQuery&&(n[0].hasClass("PennController-after")||n[0].hasClass("PennController-before"))){const e={};let s=n[0][0].className.replace(/^.*PennController-(after|before).*$/,"$1");s=s.replace(/^[ab]/,e=>e.toUpperCase());for(let n=0;ne._element!=t),o["jQuery"+s].length{const t=this.elements[e][0];await window.PennController.Elements["get"+t.type](t.id).remove()._runPromises()}),r.forEach(async(e,t)=>{let n=this.elements[e][0],r=o[t];if(void 0===r)return;const a=window.PennController.Elements["get"+n.type](n.id);r.hasOwnProperty("After")?await window.PennController.Elements["get"+r.After.type](r.After.id).after(a)._runPromises():r.hasOwnProperty("Before")?await window.PennController.Elements["get"+r.Before.type](r.Before.id).after(a)._runPromises():await a.print(...r)._runPromises();const l=s[i[t]];l instanceof jQuery&&(n.jQueryContainer.css("position","unset"),l.before(n.jQueryContainer),l.remove())});const a=[...this.elements];i.forEach((e,t)=>this.elements[e]=a[r[t]]),t()}this.immediate=function(e){void 0!==e&&"string"==typeof e&&0!=e.length||(e="Selector"),this.id=e},this.uponCreation=function(t){this.elements=[],this.selections=[],this.disabled=!1,this.frame=$("
      ").css({position:"absolute",display:"inline-block",margin:"auto",outline:"dotted 1px grey","z-index":100}).addClass("PennController-"+this.type.replace(/[\s_]/g,"")+"-selectionFrame"),this.noClick=!1,this.select=t=>{if(!this.disabled){if(this.elements.map(e=>e[0]).indexOf(t)<0)return e.debug.error("Tried to select an element not part of Selector "+this.id);this.selections.push(["Selection",t.id,Date.now(),this.elements.map(e=>e[0].id).join(";")]),this.frame.css({width:t.jQueryElement.outerWidth(),height:t.jQueryElement.outerHeight(),"pointer-events":"none"}),"absolute"==t.jQueryElement.css("position")&&this.frame.css({left:t.jQueryElement.css("left"),top:t.jQueryElement.css("top")}),t.jQueryElement.before(this.frame),this.elements.map(e=>e[0].jQueryElement.removeClass("PennController-"+this.type.replace(/[\s_]/g,"")+"-selected")),t.jQueryElement.addClass("PennController-"+this.type.replace(/[\s_]/g,"")+"-selected")}},e.events.keypress(e=>{if(!this.disabled)for(let t=0;t1&&(n=this.elements[t][1]);let i=e.key.isSpecialKey(),r=e.key.toUpperCase(),s={0:"",1:"LEFT",2:"RIGHT"};if(i===n.replace(/^(Left|Right)/i,"").isSpecialKey()&&(n.toUpperCase()==r||n.toUpperCase()==s[e.location]+r))return this.select(this.elements[t][0])}}),t()},this.end=function(){if(this.select=()=>{},this.frame&&this.frame instanceof jQuery&&this.frame.remove(),this.log&&this.log instanceof Array)if(this.selections.length)if(1==this.selections.length)e.controllers.running.save(this.type,this.id,...this.selections[0]);else if(this.log.indexOf("all")>-1)for(let t in this.selections)e.controllers.running.save(this.type,this.id,...this.selections[t]);else this.log.indexOf("first")>-1&&e.controllers.running.save(this.type,this.id,...this.selections[0]),this.log.indexOf("last")>-1&&e.controllers.running.save(this.type,this.id,...this.selections[this.selections.length-1]);else e.controllers.running.save(this.type,this.id,"Selection","NA","Never",this.elements.map(e=>e[0].id).join(";")+";No selection happened");this.elements=[]},this.value=function(){if(this.selections.length){let e=this.selections[this.selections.length-1][1],t=this.elements.filter(t=>t[0].id==e);return t.length?(t=t[0][0],window.PennController.Elements["get"+t.type](t.id)):null}return null},this.actions={select:function(t,n){if(!isNaN(Number(n))&&Number(n)>=0&&Number(n)e[0].id).join(";")+";From script"]),this.frame.detach(),this.elements.map(e=>e[0].jQueryElement.removeClass("PennController-"+this.type+"-selected")),e()},wait:function(e,t){if("first"==t&&this.selections.length)e();else{let n=!1,i=this.select;this.select=r=>{let s=i.apply(this,[r]);if(!(n||this.disabled&&!s))if(t instanceof Object&&t._runPromises&&t.success){let i=this.disabled;this.disabled="tmp",t._runPromises().then(t=>{"success"==t&&(n=!0,e()),"tmp"==this.disabled&&(this.disabled=i)})}else n=!0,e()}}}},this.settings={add:function(t,...n){for(w in n){let t=n[w]._element;if(null==t||null==t.id)e.debug.error("Invalid element added to selector "+this.id);else if(this.elements.map(e=>e[0]).indexOf(t)>-1)e.debug.error("Element "+t.id+" already part of selector "+this.id);else if(null!=t.jQueryElement&&t.jQueryElement instanceof jQuery){this.elements.push([t]);let e=()=>{this.noClick||t.jQueryElement.css("cursor","pointer");let e=t.jQueryElement[0].onclick;t.jQueryElement[0].onclick=(...n)=>{e instanceof Function&&e.apply(t.jQueryElement[0],n),this.noClick||this.select(t)}};t.jQueryElement.parent().length?e():t._printCallback.push(e)}else e.debug.error("Element "+t.id+" has no visble element to be chosen in selector "+this.id)}t()},callback:function(e,...t){let n=this.select;this.select=async function(e){let i=this.disabled;if(n.apply(this,[e]),!i)for(let e in t)await t[e]._runPromises()},e()},disable:function(e){this.disabled=!0,this.elements.map(e=>e[0].jQueryElement.css("cursor","")),this.jQueryContainer.addClass("PennController-disabled"),this.jQueryElement.addClass("PennController-disabled"),e()},disableClicks:function(e){this.noClick=!0,this.elements.map(e=>e[0].jQueryElement.css("cursor","")),e()},enable:function(e){this.disabled=!1,this.noClick||this.elements.map(e=>e[0].jQueryElement.css("cursor","pointer")),this.jQueryContainer.removeClass("PennController-disabled"),this.jQueryElement.removeClass("PennController-disabled"),e()},enableClicks:function(e){this.noClick=!1,this.elements.map(e=>e[0].jQueryElement.css("cursor","pointer")),e()},frame:function(e,t){this.frame.css.apply(this.frame,["outline",t]),e()},keys:function(e,...t){for(let e=0;e=this.elements.length)break;"string"!=typeof n&&Number(n)>0&&(n=String.fromCharCode(n)),this.elements[e]=[this.elements[e][0],n]}e()},log:function(e,...t){t.length?this.log=t:this.log=["last"],e()},once:function(e){if(this.selections.length)this.disabled=!0,this.elements.map(e=>e[0].jQueryElement.css("cursor",""));else{let e=this.select;this.select=t=>{if(e.apply(this,[t]),!this.disabled)return this.disabled=!0,this.elements.map(e=>e[0].jQueryElement.css("cursor","")),"once"}}e()},shuffle:function(e,...n){t.apply(this,[e].concat(n))}},this.test={selected:function(t){if(0===this.selections.length)return!1;let n=this.selections[this.selections.length-1][1];return null==t?this.selections.length>0:"string"==typeof t?t==n:t._element?t._element.id==n:(e.debug.error("Invalid element tested for Selector "+this.id,t._element.id),!1)},index:function(t,n){return null==t||null==t._element?e.debug.error("Invalid element tested for selector "+this.id,t._element.id):Number(n)>=0?this.elements.map(e=>e[0]).indexOf(t._element)==Number(n):this.elements.map(e=>e[0]).indexOf(t._element)>=0}}})),window.PennController._AddStandardCommands((function(e){this.settings={selector:async function(t,n){var i;if("string"==typeof n){let t=e.controllers.running.options.elements;if(!t.hasOwnProperty("Selector")||!t.Selector.hasOwnProperty(n))return e.debug.error("No selector found named "+n);i=t.Selector[n]}else n._element&&n._runPromises&&("Selector"==n._element.type?(await n._runPromises(),i=n._element):e.debug.error("Tried to add "+this.name+" to an invalid Selector"));if(i.elements.map(e=>e[0]).indexOf(this)>-1)e.debug.error("Element "+this.id+" already part of Selector "+i.id);else if(null!=this.jQueryElement&&this.jQueryElement instanceof jQuery){i.elements.push([this]),this.noClick||this.jQueryElement.css("cursor","pointer");let e=this.jQueryElement[0].onclick;this.jQueryElement[0].onclick=(...t)=>{e instanceof Function&&e.apply(this.jQueryElement[0],t),i.noClick||i.select(this)}}else e.debug.error("Element "+this.id+" has no visble element to be chosen in Selector "+i.id);t()}}}))},function(e,t){window.PennController._AddElementType("Text",(function(e){this.immediate=function(e,t){void 0===t&&(t=e),this.id=e,t=t.replace(/(^\s|\s$)/," "),this.initialText=t,this.text=t},this.uponCreation=function(e){this.jQueryElement=$(""+this.initialText+"").css("display","inline-block"),e()},this.value=function(){return this.text},this.end=function(){this.log&&(this.printTime?e.controllers.running.save(this.type,this.id,"Print","NA",this.printTime,"NULL"):e.controllers.running.save(this.type,this.id,"Print","NA","Never","NULL"))},this.actions={unfold:function(t,n){let i=()=>{let e=Number(n);if(e>0){let t=Date.now();this.jQueryElement.css("visibility","visible");let n=this.jQueryElement.width(),i=$("
      ").css({display:"inline-block","overflow-x":"hidden",width:0,margin:0,padding:0,"white-space":"nowrap"});i=this.jQueryElement.wrap(i).parent();let r=0,s=()=>{let o=(Date.now()-t)/e;o>=1&&(o=1);let a=Math.round(n*o);a>r&&i.width(a),r=a,o<1&&window.requestAnimationFrame(s)};window.requestAnimationFrame(s)}};this.jQueryContainer instanceof jQuery&&this.jQueryContainer.parent().length?i():e.elements.standardCommands.actions.print.call(this,i),t()}},this.settings={text:function(t,n){n instanceof e.PennElementCommands&&(n=n.value),this.text=n,this.jQueryElement.html(n),t()}},this.test={text:function(e){return e instanceof RegExp?this.text.match(e):e==this.text}}}))},function(e,t){window.PennController._AddElementType("TextInput",(function(e){this.immediate=function(e,t){void 0!==e&&"string"==typeof e&&0!=e.length||(e="TextInput"),this.initialText=t,this.id=e},this.uponCreation=function(e){this.text=this.initialText,this.jQueryElement=$("