From fd262405c7c5ac4a56f3558187fe574d86da6b49 Mon Sep 17 00:00:00 2001 From: Bailey Brightman Date: Mon, 8 Feb 2021 09:54:46 -0400 Subject: [PATCH 1/5] Commenting and minor code changes --- CHANGELOG.md | 4 +- README.md | 8 +-- dist/SpringRoll-Container-umd.js | 2 +- dist/index.js | 2 +- src/plugins/ButtonSizePlugin.js | 9 ++- src/plugins/CaptionsStylePlugin.js | 40 ++++++++----- src/plugins/CaptionsTogglePlugin.js | 27 ++++++--- src/plugins/ColorVisionPlugin.js | 11 +++- src/plugins/CompletionPercentagePlugin.js | 12 ++-- src/plugins/ControlSensitivityPlugin.js | 7 ++- src/plugins/DragThresholdScalePlugin.js | 6 +- src/plugins/FullScreenPlugin.js | 0 src/plugins/HUDPlugin.js | 6 +- src/plugins/HealthPlugin.js | 11 ++-- src/plugins/HelpPlugin.js | 23 +++++-- src/plugins/HitAreaScalePlugin.js | 10 ++-- src/plugins/InputCountPlugin.js | 9 +-- src/plugins/KeyboardMapPlugin.js | 10 ++-- src/plugins/LayersPlugin.js | 7 ++- src/plugins/ObjectCountPlugin.js | 9 +-- src/plugins/PausePlugin.js | 48 +++++++++------ src/plugins/PointerSizePlugin.js | 11 ++-- src/plugins/SoundPlugin.js | 33 ++++++---- src/plugins/SpeedScalePlugin.js | 9 ++- src/plugins/TimersScalePlugin.js | 12 ++-- src/plugins/UserDataPlugin.js | 73 ++++++++++++----------- src/ui-elements/RadioGroup.js | 4 ++ 27 files changed, 240 insertions(+), 163 deletions(-) delete mode 100644 src/plugins/FullScreenPlugin.js diff --git a/CHANGELOG.md b/CHANGELOG.md index b7756c00..2b2a655c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,3 @@ - # Changelog All notable changes to this project will be documented in this file. @@ -7,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2.1.1] - UNRELEASED ### Added -- update NPM modules to remove security vulnerabilities - Indexeddb additions to the userdata class +### Changed +- update NPM modules to remove security vulnerabilities \ No newline at end of file diff --git a/README.md b/README.md index 82d2eaed..738e3a84 100644 --- a/README.md +++ b/README.md @@ -202,11 +202,11 @@ Some games will support many of these features, some none at all. We doubt one g Each plugin is responsible for one of the listed mechanics and should be provided a [HTML range input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range), and an optional default value. -Each mechanic's value will range between 0 to 1, and the default initial value is aways 0.5. +Each mechanic's value will range between 0 to 1, and the default initial value is always 0.5. ```javascript import { - HitAreaScalePlugin, DragThresholdScalePlugin, HealtPlugin, ObjectCountPlugin, + HitAreaScalePlugin, DragThresholdScalePlugin, HealthPlugin, ObjectCountPlugin, CompletionPercentagePlugin, SpeedScalePlugin, TimersScalePlugin, InputCountPlugin, Container } from 'springroll-container'; @@ -370,7 +370,7 @@ For example the SoundPlugin can accept more than one volume slider or button if musicSliders: '#musicSlider, #musicSliderTwo', }); ``` -As long as the string you pass to the constructor is a valid selector string the plugin will use anything you pass to it. The plugins will keep settings in sync across the controls if neccessary as well. Sliders will update each other, buttons will set a dataSet attribute or class (see individual plugin sections for the exact attribute), and any other controls will match each other appropriately. +As long as the string you pass to the constructor is a valid selector string the plugin will use anything you pass to it. The plugins will keep settings in sync across the controls if necessary as well. Sliders will update each other, buttons will set a dataSet attribute or class (see individual plugin sections for the exact attribute), and any other controls will match each other appropriately. *Note: at this time there is no support for multiple HTMLElements as parameters. If you are passing an HTMLElement as the parameter rather than a selector string you cannot pass multiple controls. If you do wish to use multiple controls, pass the plugin a selector string instead. @@ -477,7 +477,7 @@ let dbVersion = 1 let dbName = 'dbName'; // Finally, pass these parameters in to establish a connection with the database -savedData.onOpenDb( dbName, dbVersion, additions, deletions) +savedData.onOpenDb(dbName, dbVersion, additions, deletions); ``` There are other methods currently supported to interact with the database. These allow you to [Add a record](https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/add), [Deleting a record](https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/delete), [Reading](https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/get), [reading all records](https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/getAll) Each will return a success, or on failure, an error message diff --git a/dist/SpringRoll-Container-umd.js b/dist/SpringRoll-Container-umd.js index 09f79efc..16154b2f 100644 --- a/dist/SpringRoll-Container-umd.js +++ b/dist/SpringRoll-Container-umd.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).springroll=t.springroll||{})}(this,(function(t){"use strict";var e="URLSearchParams"in self,n="Symbol"in self&&"iterator"in Symbol,r="FileReader"in self&&"Blob"in self&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in self,i="ArrayBuffer"in self;if(i)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(t){return t&&s.indexOf(Object.prototype.toString.call(t))>-1};function u(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function l(t){return"string"!=typeof t&&(t=String(t)),t}function c(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function d(t){this.map={},t instanceof d?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function h(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function f(t){return new Promise((function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}}))}function p(t){var e=new FileReader,n=f(e);return e.readAsArrayBuffer(t),n}function v(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function y(){return this.bodyUsed=!1,this._initBody=function(t){var n;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:r&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:e&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():i&&r&&((n=t)&&DataView.prototype.isPrototypeOf(n))?(this._bodyArrayBuffer=v(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):i&&(ArrayBuffer.prototype.isPrototypeOf(t)||a(t))?this._bodyArrayBuffer=v(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r&&(this.blob=function(){var t=h(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(p)}),this.text=function(){var t=h(this);if(t)return t;if(this._bodyBlob)return function(t){var e=new FileReader,n=f(e);return e.readAsText(t),n}(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),n=new Array(e.length),r=0;r-1?r:n),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function b(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var n=t.split("="),r=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(o))}})),e}function S(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new d(e.headers),this.url=e.url||"",this._initBody(t)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},y.call(m.prototype),y.call(S.prototype),S.prototype.clone=function(){return new S(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},S.error=function(){var t=new S(null,{status:0,statusText:""});return t.type="error",t};var w=[301,302,303,307,308];S.redirect=function(t,e){if(-1===w.indexOf(e))throw new RangeError("Invalid status code");return new S(null,{status:e,headers:{location:t}})};var k=self.DOMException;try{new k}catch(t){(k=function(t,e){this.message=t,this.name=e;var n=Error(t);this.stack=n.stack}).prototype=Object.create(Error.prototype),k.prototype.constructor=k}function E(t,e){return new Promise((function(n,o){var i=new m(t,e);if(i.signal&&i.signal.aborted)return o(new k("Aborted","AbortError"));var s=new XMLHttpRequest;function a(){s.abort()}s.onload=function(){var t,e,r={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",e=new d,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var n=t.split(":"),r=n.shift().trim();if(r){var o=n.join(":").trim();e.append(r,o)}})),e)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var o="response"in s?s.response:s.responseText;n(new S(o,r))},s.onerror=function(){o(new TypeError("Network request failed"))},s.ontimeout=function(){o(new TypeError("Network request failed"))},s.onabort=function(){o(new k("Aborted","AbortError"))},s.open(i.method,i.url,!0),"include"===i.credentials?s.withCredentials=!0:"omit"===i.credentials&&(s.withCredentials=!1),"responseType"in s&&r&&(s.responseType="blob"),i.headers.forEach((function(t,e){s.setRequestHeader(e,t)})),i.signal&&(i.signal.addEventListener("abort",a),s.onreadystatechange=function(){4===s.readyState&&i.signal.removeEventListener("abort",a)}),s.send(void 0===i._bodyInit?null:i._bodyInit)}))}E.polyfill=!0,self.fetch||(self.fetch=E,self.Headers=d,self.Request=m,self.Response=S);var x="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function B(t,e){return t(e={exports:{}},e.exports),e.exports}var P=function(t){return t&&t.Math==Math&&t},L=P("object"==typeof globalThis&&globalThis)||P("object"==typeof window&&window)||P("object"==typeof self&&self)||P("object"==typeof x&&x)||Function("return this")(),_={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},C=function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t},A=function(t,e,n){if(C(t),void 0===e)return t;switch(n){case 0:return function(){return t.call(e)};case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}},O=function(t){try{return!!t()}catch(t){return!0}},V={}.toString,D=function(t){return V.call(t).slice(8,-1)},I="".split,R=O((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==D(t)?I.call(t,""):Object(t)}:Object,T=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},M=function(t){return Object(T(t))},j=Math.ceil,N=Math.floor,F=function(t){return isNaN(t=+t)?0:(t>0?N:j)(t)},K=Math.min,G=function(t){return t>0?K(F(t),9007199254740991):0},U=function(t){return"object"==typeof t?null!==t:"function"==typeof t},H=Array.isArray||function(t){return"Array"==D(t)},z=!O((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),q=L.document,W=U(q)&&U(q.createElement),X=function(t){return W?q.createElement(t):{}},Y=!z&&!O((function(){return 7!=Object.defineProperty(X("div"),"a",{get:function(){return 7}}).a})),J=function(t){if(!U(t))throw TypeError(String(t)+" is not an object");return t},$=function(t,e){if(!U(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!U(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!U(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!U(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")},Q=Object.defineProperty,Z={f:z?Q:function(t,e,n){if(J(t),e=$(e,!0),J(n),Y)try{return Q(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},tt=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},et=z?function(t,e,n){return Z.f(t,e,tt(1,n))}:function(t,e,n){return t[e]=n,t},nt=function(t,e){try{et(L,t,e)}catch(n){L[t]=e}return e},rt="__core-js_shared__",ot=L[rt]||nt(rt,{}),it=B((function(t){(t.exports=function(t,e){return ot[t]||(ot[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.5",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),st={}.hasOwnProperty,at=function(t,e){return st.call(t,e)},ut=0,lt=Math.random(),ct=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++ut+lt).toString(36)},dt=!!Object.getOwnPropertySymbols&&!O((function(){return!String(Symbol())})),ht=dt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ft=it("wks"),pt=L.Symbol,vt=ht?pt:pt&&pt.withoutSetter||ct,yt=function(t){return at(ft,t)||(dt&&at(pt,t)?ft[t]=pt[t]:ft[t]=vt("Symbol."+t)),ft[t]},gt=yt("species"),mt=function(t,e){var n;return H(t)&&("function"!=typeof(n=t.constructor)||n!==Array&&!H(n.prototype)?U(n)&&null===(n=n[gt])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===e?0:e)},bt=[].push,St=function(t){var e=1==t,n=2==t,r=3==t,o=4==t,i=6==t,s=5==t||i;return function(a,u,l,c){for(var d,h,f=M(a),p=R(f),v=A(u,l,3),y=G(p.length),g=0,m=c||mt,b=e?m(a,y):n?m(a,0):void 0;y>g;g++)if((s||g in p)&&(h=v(d=p[g],g,f),t))if(e)b[g]=h;else if(h)switch(t){case 3:return!0;case 5:return d;case 6:return g;case 2:bt.call(b,d)}else if(o)return!1;return i?-1:r||o?o:b}},wt={forEach:St(0),map:St(1),filter:St(2),some:St(3),every:St(4),find:St(5),findIndex:St(6)},kt=function(t,e){var n=[][t];return!!n&&O((function(){n.call(null,e||function(){throw 1},1)}))},Et=Object.defineProperty,xt={},Bt=function(t){throw t},Pt=function(t,e){if(at(xt,t))return xt[t];e||(e={});var n=[][t],r=!!at(e,"ACCESSORS")&&e.ACCESSORS,o=at(e,0)?e[0]:Bt,i=at(e,1)?e[1]:void 0;return xt[t]=!!n&&!O((function(){if(r&&!z)return!0;var t={length:-1};r?Et(t,1,{enumerable:!0,get:Bt}):t[1]=1,n.call(t,o,i)}))},Lt=wt.forEach,_t=kt("forEach"),Ct=Pt("forEach"),At=_t&&Ct?[].forEach:function(t){return Lt(this,t,arguments.length>1?arguments[1]:void 0)};for(var Ot in _){var Vt=L[Ot],Dt=Vt&&Vt.prototype;if(Dt&&Dt.forEach!==At)try{et(Dt,"forEach",At)}catch(t){Dt.forEach=At}}var It,Rt=function(t){return R(T(t))},Tt=Math.max,Mt=Math.min,jt=function(t){return function(e,n,r){var o,i=Rt(e),s=G(i.length),a=function(t,e){var n=F(t);return n<0?Tt(n+e,0):Mt(n,e)}(r,s);if(t&&n!=n){for(;s>a;)if((o=i[a++])!=o)return!0}else for(;s>a;a++)if((t||a in i)&&i[a]===n)return t||a||0;return!t&&-1}},Nt={includes:jt(!0),indexOf:jt(!1)},Ft={},Kt=Nt.indexOf,Gt=function(t,e){var n,r=Rt(t),o=0,i=[];for(n in r)!at(Ft,n)&&at(r,n)&&i.push(n);for(;e.length>o;)at(r,n=e[o++])&&(~Kt(i,n)||i.push(n));return i},Ut=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Ht=Object.keys||function(t){return Gt(t,Ut)},zt=z?Object.defineProperties:function(t,e){J(t);for(var n,r=Ht(e),o=r.length,i=0;o>i;)Z.f(t,n=r[i++],e[n]);return t},qt=L,Wt=function(t){return"function"==typeof t?t:void 0},Xt=function(t,e){return arguments.length<2?Wt(qt[t])||Wt(L[t]):qt[t]&&qt[t][e]||L[t]&&L[t][e]},Yt=Xt("document","documentElement"),Jt=it("keys"),$t=function(t){return Jt[t]||(Jt[t]=ct(t))},Qt=$t("IE_PROTO"),Zt=function(){},te=function(t){return"