/* This software is licensed under a BSD license; see the LICENSE file for details. */ // - Version beta 0.1 // - Last Update: 2018, June 22 // - Major changes in beta 0.1: // + New syntax: // each element gets created by newX and retrieved by getX // commands come in 3 types: actions (.command), settings (.settings.command) and tests (.test.command) // 'instructions' are no longer a thing // defaultX can be used to define commands to be automatically executed upon creation of each element X // + Replaced all .record with settings.log // + Elements get printed on the screen only when .print is called (exception when part of canvas) // + Added .settings.left/right/center/color to each element // + Added .settings.before/after to each element // + Created a button element // + Created a textInput element // + Created a scale element (previously radio) // + Created a HTML element // + Created a voiceRecorder element // + Can retrieve table with PennController.GetTable and filter them using .filter // + Added a .logAppend command on PennController() to add values to each line for the trial in the results // - Major changes in alpha 0.4: // + Revised the preloading method // + Replaced all .save with .record // + Added the FeedItems command // - Major changes in alpha 0.3: // + Added the Canvas instruction // + Added the Instruction.id method !function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},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=135)}([function(e,t,n){"use strict";n.r(t),n.d(t,"Abort",function(){return r}),n.d(t,"Ctrlr",function(){return i}),n.d(t,"changeRunningOrder",function(){return s}),n.d(t,"getChangeRunningOrder",function(){return a}),n.d(t,"PennController",function(){return u});var r=new Object;window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;var i={building:{},running:{},list:[]},o=[];function s(e){if(!(e instanceof Function))return console.log("ERROR: changeRunningOrder only takes functions as parameters");o.push(e)}function a(e){return o}var u=function(){let e=i.list.length,t=arguments;i.building.id=e,i.building.sequence=t,i.list.push(i.building),i.building={};let n={instructions:t,id:e,_toSave:[],save:function(e,t,r){return n._toSave.push([e,t,r]),n},_appendResultLine:[],logAppend:function(e,t){return void 0===t&&(t=e),n._appendResultLine.push([e,t]),n}};return n};u.Configure=function(e){for(let t in e)t.indexOf.Configure<0&&(u[t]=e[t])};let l={};u.GetURLParameter=function(e){if(!Object.keys(l).length){let e=window.location.search.replace("?","").split("&");for(let t in e)l[e[t].split("=")[0]]=e[t].split("=")[1]}if(l.hasOwnProperty(e))return l[e]},u.AddHost=function(){u.hasOwnProperty("hosts")||(u.hosts=[]);for(let e=0;e1;)try{return c.stringifyByChunk(e,r,n)}catch(e){n=Math.floor(n/2)}return c.stringifyByChar(e)}function f(e,t){for(var n=0;n").append(n)),i instanceof Function&&a){let e=new a(t=>{0!==t[0].addedNodes.length&&-1!==Array.prototype.indexOf.call(t[0].addedNodes,n[0])&&(e.disconnect(),i())});e.observe(t[0],{childList:!0})}if(this.origin._left){let e=$("").addClass("PennController-before");this.origin._left instanceof l?(this.origin._left.origin.parentElement=e,this.origin._left.hasBeenRun||this.origin._left.run(),this.origin._left.origin.print().run()):this.origin._left instanceof jQuery&&e.append(this.origin._left),n.prepend(e)}if(t.append(n),this.origin._right){let e=$("").addClass("PennController-after");this.origin._right instanceof l?(this.origin._right.origin.parentElement=e,this.origin._right.hasBeenRun||this.origin._right.run(),this.origin._right.origin.print().run()):this.origin._right instanceof jQuery&&e.append(this.origin._right),n.append(e)}}setElement(e){this.element=e;let t=this;for(let e in this.origin.element)"function"==typeof t.origin.element[e]?t.j[e]=function(){return t.origin.element[e].apply(t.origin.element,arguments),t.newMeta(function(){this.done()})}:t.j[e]=function(){return t.origin.element[e]}}_addToPreload(){if(this.origin.resource)return r;o.e.indexOf(this.origin)<0&&o.e.push(this.origin),e.building.hasOwnProperty("preloadingInstructions")||(e.building.preloadingInstructions=[]),e.building.preloadingInstructions.indexOf(this.origin)<0&&e.building.preloadingInstructions.push(this.origin)}_setResource(e){if(this.origin.resource)return console.log("Warning: trying to replace resource for "+this.origin.content+"; several host copies of the same file? Ignoring new resource."),r;let t=o.e.indexOf(this.origin);t>=0&&o.e.splice(t,1),this.origin.resource=e}fetchResource(e,t){let n,o,a=this;if(this.origin.resource)return r;if(s.d&&s.a.length>0&&!e.match(/^http/i))return void s.c.push(function(){a.fetchResource(e,t)});let u="load";if(s.b.hasOwnProperty(e))t=s.b[e].type,o=URL.createObjectURL(s.b[e].blob),t.match(/audio/)&&(u="canplay");else if(e.match(/^http/i)){let n=e.match(/\.([^.]+)$/);if(!t&&!n)return console.log("Error: extension of resource "+file+" not recognized"),r;n=n[1],"audio"==t||n.match(/mp3|ogg|wav/i)?(t="audio/"+n.toLowerCase().replace("mp3","mpeg").toLowerCase(),o=e,u="canplaythrough"):"image"==t||n.match(/gif|png|jpe?g/i)?(t="image/"+n.replace(/jpg/i,"jpeg").toLowerCase(),o=e):"video"==t||n.match(/mp4|ogg|webm/i)}else if(i.hosts.length)for(let n in i.hosts)"string"==typeof i.hosts[n]&&i.hosts[n].match(/^http/i)&&a.fetchResource(i.hosts[n]+e,t);t.match(/audio/)?(n=$("