From 0a872aedf8aa30e599048e94446265f05ad2cb1a Mon Sep 17 00:00:00 2001 From: William Troup Date: Mon, 8 Jan 2024 10:45:50 +0000 Subject: [PATCH 1/8] Updated to v0.6.0. --- README.md | 6 +++--- README_NUGET.md | 6 +++--- dist/observe.js | 4 ++-- dist/observe.min.js | 4 ++-- docs/CHANGE_LOG.md | 6 ++++++ observe.js.nuspec | 2 +- package.json | 2 +- src/observe.js | 4 ++-- 8 files changed, 20 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 9943d02..9c23a9b 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,15 @@ Observe.js [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Observe.js%2C%20a%20free%20JavaScript%observe%builder&url=https://github.com/williamtroup/Observe.js&hashtags=javascript,html,observe) -[![npm](https://img.shields.io/badge/npmjs-v0.5.1-blue)](https://www.npmjs.com/package/jobserve.js) -[![nuget](https://img.shields.io/badge/nuget-v0.5.1-purple)](https://www.nuget.org/packages/jObserve.js/) +[![npm](https://img.shields.io/badge/npmjs-v0.6.0-blue)](https://www.npmjs.com/package/jobserve.js) +[![nuget](https://img.shields.io/badge/nuget-v0.6.0-purple)](https://www.nuget.org/packages/jObserve.js/) [![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/williamtroup/Observe.js/blob/main/LICENSE.txt) [![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/Observe.js/discussions) [![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://github.com/williamtroup) >

A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.

->

v0.5.1

+>

v0.6.0



diff --git a/README_NUGET.md b/README_NUGET.md index 8122dc4..5eceb85 100644 --- a/README_NUGET.md +++ b/README_NUGET.md @@ -1,8 +1,8 @@ -# Observe.js v0.5.1 +# Observe.js v0.6.0 [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Observe.js%2C%20a%20free%20JavaScript%observe%builder&url=https://github.com/williamtroup/Observe.js&hashtags=javascript,html,observe) -[![npm](https://img.shields.io/badge/npmjs-v0.5.1-blue)](https://www.npmjs.com/package/jobserve.js) -[![nuget](https://img.shields.io/badge/nuget-v0.5.1-purple)](https://www.nuget.org/packages/jObserve.js/) +[![npm](https://img.shields.io/badge/npmjs-v0.6.0-blue)](https://www.npmjs.com/package/jobserve.js) +[![nuget](https://img.shields.io/badge/nuget-v0.6.0-purple)](https://www.nuget.org/packages/jObserve.js/) [![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/williamtroup/Observe.js/blob/main/LICENSE.txt) [![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/Observe.js/discussions) [![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://github.com/williamtroup) diff --git a/dist/observe.js b/dist/observe.js index 1c3c287..d106c05 100644 --- a/dist/observe.js +++ b/dist/observe.js @@ -1,4 +1,4 @@ -/*! Observe.js v0.5.1 | (c) Bunoon | MIT License */ +/*! Observe.js v0.6.0 | (c) Bunoon | MIT License */ (function() { function collectDOMObjects() { var tagTypes = _configuration.domElementTypes; @@ -404,7 +404,7 @@ return this; }; this.getVersion = function() { - return "0.5.1"; + return "0.6.0"; }; (function(documentObject, windowObject) { _parameter_Document = documentObject; diff --git a/dist/observe.min.js b/dist/observe.min.js index 44cd370..1af929d 100644 --- a/dist/observe.min.js +++ b/dist/observe.min.js @@ -1,4 +1,4 @@ -/*! Observe.js v0.5.1 | (c) Bunoon | MIT License */ +/*! Observe.js v0.6.0 | (c) Bunoon | MIT License */ (function(){function I(){for(var a=q.domElementTypes,b=a.length,c=0;c=h.starts){if(d.hasOwnProperty(l)){var e=d[l],f=p(e.domElementId), m=null;f&&(m=y.getElementById(e.domElementId),r(m)?e.originalObject=m.outerHTML:(e.originalObject=B.empty,u(e.options.onRemove,e.domElementId)));var v=e.cachedObject,n=e.originalObject;n=f?n:JSON.stringify(n);if(v!==n){e.options.reset?f?m.outerHTML=e.cachedObject:e.originalObject=z(v).result:e.cachedObject=n;if(f)u(e.options.onChange,v,n);else if(f=z(v).result,m=z(n).result,w(f)||w(m))u(e.options.onChange,f,m);else{if(w(e.options.propertyNames))for(v=e.options.propertyNames.length,n=0;n + + ## Version 0.5.1: - Project description update. - Minor documentation updates. diff --git a/observe.js.nuspec b/observe.js.nuspec index 772b0f9..c890b7d 100644 --- a/observe.js.nuspec +++ b/observe.js.nuspec @@ -2,7 +2,7 @@ jObserve.js - 0.5.1 + 0.6.0 Observe.js A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements. William Troup diff --git a/package.json b/package.json index ffee6bc..526a5a1 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jobserve.js", "title": "Observe.js", "description": "A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.", - "version": "0.5.1", + "version": "0.6.0", "main": "dist/observe.js", "author": { "name": "Bunoon" diff --git a/src/observe.js b/src/observe.js index 6d1a3c3..54a2b89 100644 --- a/src/observe.js +++ b/src/observe.js @@ -4,7 +4,7 @@ * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements. * * @file observe.js - * @version v0.5.1 + * @version v0.6.0 * @author Bunoon * @license MIT License * @copyright Bunoon 2023 @@ -720,7 +720,7 @@ * @returns {string} The version number. */ this.getVersion = function() { - return "0.5.1"; + return "0.6.0"; }; From cd28ecfcd664bc85cfb3f032e10545d09982bc52 Mon Sep 17 00:00:00 2001 From: William Troup Date: Mon, 8 Jan 2024 11:19:18 +0000 Subject: [PATCH 2/8] Minor internal refactoring to make things a little clearer. --- dist/observe.js | 5 ++--- dist/observe.min.js | 18 +++++++++--------- docs/CHANGE_LOG.md | 4 +++- src/observe.js | 6 ++---- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/dist/observe.js b/dist/observe.js index d106c05..726e28e 100644 --- a/dist/observe.js +++ b/dist/observe.js @@ -149,7 +149,6 @@ } } function compareWatchObjectProperties(oldObject, newObject, watch) { - var options = watch.options; var propertyName; for (propertyName in oldObject) { if (oldObject.hasOwnProperty(propertyName)) { @@ -159,11 +158,11 @@ propertyNewValue = newObject[propertyName]; } if (isDefinedObject(propertyOldValue) && isDefinedObject(propertyNewValue)) { - compareWatchObjectProperties(propertyOldValue, propertyNewValue, options); + compareWatchObjectProperties(propertyOldValue, propertyNewValue, watch.options); } else { if (!isDefinedArray(watch.options.propertyNames) || watch.options.propertyNames.indexOf(propertyName) > -1) { if (JSON.stringify(propertyOldValue) !== JSON.stringify(propertyNewValue)) { - fireCustomTrigger(options.onPropertyChange, propertyName, propertyOldValue, propertyNewValue); + fireCustomTrigger(watch.options.onPropertyChange, propertyName, propertyOldValue, propertyNewValue); } } } diff --git a/dist/observe.min.js b/dist/observe.min.js index 1af929d..3c1b1bf 100644 --- a/dist/observe.min.js +++ b/dist/observe.min.js @@ -1,12 +1,12 @@ /*! Observe.js v0.6.0 | (c) Bunoon | MIT License */ -(function(){function I(){for(var a=q.domElementTypes,b=a.length,c=0;c=h.starts){if(d.hasOwnProperty(l)){var e=d[l],f=p(e.domElementId), -m=null;f&&(m=y.getElementById(e.domElementId),r(m)?e.originalObject=m.outerHTML:(e.originalObject=B.empty,u(e.options.onRemove,e.domElementId)));var v=e.cachedObject,n=e.originalObject;n=f?n:JSON.stringify(n);if(v!==n){e.options.reset?f?m.outerHTML=e.cachedObject:e.originalObject=z(v).result:e.cachedObject=n;if(f)u(e.options.onChange,v,n);else if(f=z(v).result,m=z(n).result,w(f)||w(m))u(e.options.onChange,f,m);else{if(w(e.options.propertyNames))for(v=e.options.propertyNames.length,n=0;n=e.options.maximumChangesBeforeCanceling&&x(l)}}A(h.expires)&&k>=h.expires&&x(l)}},h.timeout);d[g]=b}return g}function N(a,b,c){var g=c.options,h;for(h in a)if(a.hasOwnProperty(h)){var l= -a[h],k=null;b.hasOwnProperty(h)&&(k=b[h]);t(l)&&t(k)?N(l,k,g):(!w(c.options.propertyNames)||-1b;b++){8!==b&&12!==b&&16!==b&&20!==b||a.push("-");var c=Math.floor(16*Math.random()).toString(16);a.push(c)}return a.join(B.empty)}function r(a){return null!==a&&void 0!==a&&a!==B.empty}function t(a){return r(a)&&"object"===typeof a}function p(a){return r(a)&&"string"===typeof a}function C(a){return r(a)&&"function"===typeof a}function w(a){return t(a)&&a instanceof Array}function A(a){return t(a)&& -a instanceof Date}function H(a,b){return r(a)&&"boolean"===typeof a?a:b}function D(a,b){return C(a)?a:b}function G(a,b){return r(a)&&"number"===typeof a?a:b}function z(a){var b=!0,c=null;try{p(a)&&(c=JSON.parse(a))}catch(g){try{c=eval("("+a+")"),C(c)&&(c=c())}catch(h){b=Q("Errors in object: "+g.message+", "+h.message),c=null}}return{parsed:b,result:c}}function Q(a){var b=!0;q.safeMode||(console.error(a),b=!1);return b}function P(){q.safeMode=H(q.safeMode,!0);var a=q,b=q.domElementTypes,c=["*"];p(b)? +(function(){function I(){for(var a=q.domElementTypes,b=a.length,c=0;c=k.starts){if(d.hasOwnProperty(h)){var e=d[h],g=p(e.domElementId), +m=null;g&&(m=y.getElementById(e.domElementId),r(m)?e.originalObject=m.outerHTML:(e.originalObject=B.empty,u(e.options.onRemove,e.domElementId)));var v=e.cachedObject,n=e.originalObject;n=g?n:JSON.stringify(n);if(v!==n){e.options.reset?g?m.outerHTML=e.cachedObject:e.originalObject=z(v).result:e.cachedObject=n;if(g)u(e.options.onChange,v,n);else if(g=z(v).result,m=z(n).result,w(g)||w(m))u(e.options.onChange,g,m);else{if(w(e.options.propertyNames))for(v=e.options.propertyNames.length,n=0;n=e.options.maximumChangesBeforeCanceling&&x(h)}}A(k.expires)&&l>=k.expires&&x(h)}},k.timeout);d[f]=b}return f}function N(a,b,c){for(var f in a)if(a.hasOwnProperty(f)){var k=a[f], +h=null;b.hasOwnProperty(f)&&(h=b[f]);t(k)&&t(h)?N(k,h,c.options):(!w(c.options.propertyNames)||-1b;b++){8!==b&&12!==b&&16!==b&&20!==b||a.push("-");var c=Math.floor(16*Math.random()).toString(16);a.push(c)}return a.join(B.empty)}function r(a){return null!==a&&void 0!==a&&a!==B.empty}function t(a){return r(a)&&"object"===typeof a}function p(a){return r(a)&&"string"===typeof a}function C(a){return r(a)&&"function"===typeof a}function w(a){return t(a)&&a instanceof Array}function A(a){return t(a)&& +a instanceof Date}function H(a,b){return r(a)&&"boolean"===typeof a?a:b}function D(a,b){return C(a)?a:b}function G(a,b){return r(a)&&"number"===typeof a?a:b}function z(a){var b=!0,c=null;try{p(a)&&(c=JSON.parse(a))}catch(f){try{c=eval("("+a+")"),C(c)&&(c=c())}catch(k){b=Q("Errors in object: "+f.message+", "+k.message),c=null}}return{parsed:b,result:c}}function Q(a){var b=!0;q.safeMode||(console.error(a),b=!1);return b}function P(){q.safeMode=H(q.safeMode,!0);var a=q,b=q.domElementTypes,c=["*"];p(b)? (b=b.split(B.space),0===b.length&&(b=c)):b=w(b)?b:c;a.domElementTypes=b}var y=null,E=null,B={empty:""},d={},q={};this.watch=function(a,b){return L(a,b)};this.cancelWatch=function(a){var b=!1;if(d.hasOwnProperty(a))x(a),b=!0;else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&&d[c].domElementId===a){x(c);b=!0;break}return b};this.cancelWatches=function(){O();return this};this.getWatch=function(a){var b=null;if(d.hasOwnProperty(a))b=d[a];else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&& -d[c].domElementId===a){b=d[c];break}return b};this.getWatches=function(){return d};this.pauseWatch=function(a,b){var c=!1;if(d.hasOwnProperty(a))c=F(a,b);else for(var g in d)if(d.hasOwnProperty(g)&&p(d[g].domElementId)&&d[g].domElementId===a){c=F(g,b);break}return c};this.resumeWatch=function(a){var b=!1;if(d.hasOwnProperty(a))d[a].options.starts=null,b=!0;else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&&d[c].domElementId===a){d[c].options.starts=null;b=!0;break}return b};this.searchDomForNewWatches= +d[c].domElementId===a){b=d[c];break}return b};this.getWatches=function(){return d};this.pauseWatch=function(a,b){var c=!1;if(d.hasOwnProperty(a))c=F(a,b);else for(var f in d)if(d.hasOwnProperty(f)&&p(d[f].domElementId)&&d[f].domElementId===a){c=F(f,b);break}return c};this.resumeWatch=function(a){var b=!1;if(d.hasOwnProperty(a))d[a].options.starts=null,b=!0;else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&&d[c].domElementId===a){d[c].options.starts=null;b=!0;break}return b};this.searchDomForNewWatches= function(){I();return this};this.setConfiguration=function(a){q=t(a)?a:{};P();return this};this.getVersion=function(){return"0.6.0"};(function(a,b){y=a;E=b;P();y.addEventListener("DOMContentLoaded",function(){I()});E.addEventListener("unload",function(){O()});r(E.$observe)||(E.$observe=this)})(document,window)})(); \ No newline at end of file diff --git a/docs/CHANGE_LOG.md b/docs/CHANGE_LOG.md index fb42e7c..bd052ef 100644 --- a/docs/CHANGE_LOG.md +++ b/docs/CHANGE_LOG.md @@ -1,7 +1,9 @@ # Observe.js - Change Log: ## Version 0.6.0: -- + +#### **General Improvements:** +- Minor internal refactoring to make things a little clearer.
diff --git a/src/observe.js b/src/observe.js index 54a2b89..5f4514b 100644 --- a/src/observe.js +++ b/src/observe.js @@ -236,8 +236,6 @@ } function compareWatchObjectProperties( oldObject, newObject, watch ) { - var options = watch.options; - for ( var propertyName in oldObject ) { if ( oldObject.hasOwnProperty( propertyName ) ) { var propertyOldValue = oldObject[ propertyName ], @@ -248,12 +246,12 @@ } if ( isDefinedObject( propertyOldValue ) && isDefinedObject( propertyNewValue ) ) { - compareWatchObjectProperties( propertyOldValue, propertyNewValue, options ); + compareWatchObjectProperties( propertyOldValue, propertyNewValue, watch.options ); } else { if ( !isDefinedArray( watch.options.propertyNames ) || watch.options.propertyNames.indexOf( propertyName ) > -1 ) { if ( JSON.stringify( propertyOldValue ) !== JSON.stringify( propertyNewValue ) ) { - fireCustomTrigger( options.onPropertyChange, propertyName, propertyOldValue, propertyNewValue ); + fireCustomTrigger( watch.options.onPropertyChange, propertyName, propertyOldValue, propertyNewValue ); } } } From 80faec943c4f7b36326e46893f44fb9ffbbb41f0 Mon Sep 17 00:00:00 2001 From: William Troup Date: Mon, 8 Jan 2024 16:13:37 +0000 Subject: [PATCH 3/8] Updated project year. --- LICENSE.txt | 2 +- dist/observe.js | 2 +- dist/observe.min.js | 2 +- src/observe.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index c6914d5..55ece0d 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 William Troup +Copyright (c) 2024 William Troup Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/dist/observe.js b/dist/observe.js index 726e28e..3b64368 100644 --- a/dist/observe.js +++ b/dist/observe.js @@ -1,4 +1,4 @@ -/*! Observe.js v0.6.0 | (c) Bunoon | MIT License */ +/*! Observe.js v0.6.0 | (c) Bunoon 2024 | MIT License */ (function() { function collectDOMObjects() { var tagTypes = _configuration.domElementTypes; diff --git a/dist/observe.min.js b/dist/observe.min.js index 3c1b1bf..28b8815 100644 --- a/dist/observe.min.js +++ b/dist/observe.min.js @@ -1,4 +1,4 @@ -/*! Observe.js v0.6.0 | (c) Bunoon | MIT License */ +/*! Observe.js v0.6.0 | (c) Bunoon 2024 | MIT License */ (function(){function I(){for(var a=q.domElementTypes,b=a.length,c=0;c=k.starts){if(d.hasOwnProperty(h)){var e=d[h],g=p(e.domElementId), m=null;g&&(m=y.getElementById(e.domElementId),r(m)?e.originalObject=m.outerHTML:(e.originalObject=B.empty,u(e.options.onRemove,e.domElementId)));var v=e.cachedObject,n=e.originalObject;n=g?n:JSON.stringify(n);if(v!==n){e.options.reset?g?m.outerHTML=e.cachedObject:e.originalObject=z(v).result:e.cachedObject=n;if(g)u(e.options.onChange,v,n);else if(g=z(v).result,m=z(n).result,w(g)||w(m))u(e.options.onChange,g,m);else{if(w(e.options.propertyNames))for(v=e.options.propertyNames.length,n=0;n Date: Mon, 8 Jan 2024 16:36:04 +0000 Subject: [PATCH 4/8] Added "pauseWatches()" and "resumeWatches()" public functions. --- dist/observe.js | 18 ++++++++++++++++++ dist/observe.min.js | 17 +++++++++-------- docs/CHANGE_LOG.md | 4 ++++ docs/PUBLIC_FUNCTIONS.md | 18 ++++++++++++++++-- src/observe.js | 40 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 87 insertions(+), 10 deletions(-) diff --git a/dist/observe.js b/dist/observe.js index 3b64368..5d6f961 100644 --- a/dist/observe.js +++ b/dist/observe.js @@ -376,6 +376,15 @@ } return result; }; + this.pauseWatches = function(milliseconds) { + var storageId; + for (storageId in _watches) { + if (_watches.hasOwnProperty(storageId)) { + pauseWatchObject(storageId, milliseconds); + } + } + return this; + }; this.resumeWatch = function(id) { var result = false; if (_watches.hasOwnProperty(id)) { @@ -393,6 +402,15 @@ } return result; }; + this.resumeWatches = function() { + var storageId; + for (storageId in _watches) { + if (_watches.hasOwnProperty(storageId)) { + _watches[storageId].options.starts = null; + } + } + return this; + }; this.searchDomForNewWatches = function() { collectDOMObjects(); return this; diff --git a/dist/observe.min.js b/dist/observe.min.js index 28b8815..d29555f 100644 --- a/dist/observe.min.js +++ b/dist/observe.min.js @@ -2,11 +2,12 @@ (function(){function I(){for(var a=q.domElementTypes,b=a.length,c=0;c=k.starts){if(d.hasOwnProperty(h)){var e=d[h],g=p(e.domElementId), m=null;g&&(m=y.getElementById(e.domElementId),r(m)?e.originalObject=m.outerHTML:(e.originalObject=B.empty,u(e.options.onRemove,e.domElementId)));var v=e.cachedObject,n=e.originalObject;n=g?n:JSON.stringify(n);if(v!==n){e.options.reset?g?m.outerHTML=e.cachedObject:e.originalObject=z(v).result:e.cachedObject=n;if(g)u(e.options.onChange,v,n);else if(g=z(v).result,m=z(n).result,w(g)||w(m))u(e.options.onChange,g,m);else{if(w(e.options.propertyNames))for(v=e.options.propertyNames.length,n=0;n=e.options.maximumChangesBeforeCanceling&&x(h)}}A(k.expires)&&l>=k.expires&&x(h)}},k.timeout);d[f]=b}return f}function N(a,b,c){for(var f in a)if(a.hasOwnProperty(f)){var k=a[f], -h=null;b.hasOwnProperty(f)&&(h=b[f]);t(k)&&t(h)?N(k,h,c.options):(!w(c.options.propertyNames)||-1b;b++){8!==b&&12!==b&&16!==b&&20!==b||a.push("-");var c=Math.floor(16*Math.random()).toString(16);a.push(c)}return a.join(B.empty)}function r(a){return null!==a&&void 0!==a&&a!==B.empty}function t(a){return r(a)&&"object"===typeof a}function p(a){return r(a)&&"string"===typeof a}function C(a){return r(a)&&"function"===typeof a}function w(a){return t(a)&&a instanceof Array}function A(a){return t(a)&& -a instanceof Date}function H(a,b){return r(a)&&"boolean"===typeof a?a:b}function D(a,b){return C(a)?a:b}function G(a,b){return r(a)&&"number"===typeof a?a:b}function z(a){var b=!0,c=null;try{p(a)&&(c=JSON.parse(a))}catch(f){try{c=eval("("+a+")"),C(c)&&(c=c())}catch(k){b=Q("Errors in object: "+f.message+", "+k.message),c=null}}return{parsed:b,result:c}}function Q(a){var b=!0;q.safeMode||(console.error(a),b=!1);return b}function P(){q.safeMode=H(q.safeMode,!0);var a=q,b=q.domElementTypes,c=["*"];p(b)? -(b=b.split(B.space),0===b.length&&(b=c)):b=w(b)?b:c;a.domElementTypes=b}var y=null,E=null,B={empty:""},d={},q={};this.watch=function(a,b){return L(a,b)};this.cancelWatch=function(a){var b=!1;if(d.hasOwnProperty(a))x(a),b=!0;else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&&d[c].domElementId===a){x(c);b=!0;break}return b};this.cancelWatches=function(){O();return this};this.getWatch=function(a){var b=null;if(d.hasOwnProperty(a))b=d[a];else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&& -d[c].domElementId===a){b=d[c];break}return b};this.getWatches=function(){return d};this.pauseWatch=function(a,b){var c=!1;if(d.hasOwnProperty(a))c=F(a,b);else for(var f in d)if(d.hasOwnProperty(f)&&p(d[f].domElementId)&&d[f].domElementId===a){c=F(f,b);break}return c};this.resumeWatch=function(a){var b=!1;if(d.hasOwnProperty(a))d[a].options.starts=null,b=!0;else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&&d[c].domElementId===a){d[c].options.starts=null;b=!0;break}return b};this.searchDomForNewWatches= -function(){I();return this};this.setConfiguration=function(a){q=t(a)?a:{};P();return this};this.getVersion=function(){return"0.6.0"};(function(a,b){y=a;E=b;P();y.addEventListener("DOMContentLoaded",function(){I()});E.addEventListener("unload",function(){O()});r(E.$observe)||(E.$observe=this)})(document,window)})(); \ No newline at end of file +e.options.propertyNames[n];if(g[M]!==m[M]){u(e.options.onChange,g,m);break}}else u(e.options.onChange,g,m);C(e.options.onPropertyChange)&&N(g,m,e)}e.totalChanges++;0=e.options.maximumChangesBeforeCanceling&&x(h)}}A(k.expires)&&l>=k.expires&&x(h)}},k.timeout);d[f]=b}return f}function N(a,b,c){for(var f in a)if(a.hasOwnProperty(f)){var k=a[f], +h=null;b.hasOwnProperty(f)&&(h=b[f]);t(k)&&t(h)?N(k,h,c.options):(!w(c.options.propertyNames)||-1b;b++){8!==b&&12!==b&&16!==b&&20!==b||a.push("-");var c=Math.floor(16*Math.random()).toString(16);a.push(c)}return a.join(B.empty)}function r(a){return null!==a&&void 0!==a&&a!==B.empty}function t(a){return r(a)&&"object"===typeof a}function p(a){return r(a)&&"string"===typeof a}function C(a){return r(a)&&"function"===typeof a}function w(a){return t(a)&&a instanceof Array}function A(a){return t(a)&& +a instanceof Date}function H(a,b){return r(a)&&"boolean"===typeof a?a:b}function E(a,b){return C(a)?a:b}function G(a,b){return r(a)&&"number"===typeof a?a:b}function z(a){var b=!0,c=null;try{p(a)&&(c=JSON.parse(a))}catch(f){try{c=eval("("+a+")"),C(c)&&(c=c())}catch(k){b=Q("Errors in object: "+f.message+", "+k.message),c=null}}return{parsed:b,result:c}}function Q(a){var b=!0;q.safeMode||(console.error(a),b=!1);return b}function P(){q.safeMode=H(q.safeMode,!0);var a=q,b=q.domElementTypes,c=["*"];p(b)? +(b=b.split(B.space),0===b.length&&(b=c)):b=w(b)?b:c;a.domElementTypes=b}var y=null,F=null,B={empty:""},d={},q={};this.watch=function(a,b){return L(a,b)};this.cancelWatch=function(a){var b=!1;if(d.hasOwnProperty(a))x(a),b=!0;else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&&d[c].domElementId===a){x(c);b=!0;break}return b};this.cancelWatches=function(){O();return this};this.getWatch=function(a){var b=null;if(d.hasOwnProperty(a))b=d[a];else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&& +d[c].domElementId===a){b=d[c];break}return b};this.getWatches=function(){return d};this.pauseWatch=function(a,b){var c=!1;if(d.hasOwnProperty(a))c=D(a,b);else for(var f in d)if(d.hasOwnProperty(f)&&p(d[f].domElementId)&&d[f].domElementId===a){c=D(f,b);break}return c};this.pauseWatches=function(a){for(var b in d)d.hasOwnProperty(b)&&D(b,a);return this};this.resumeWatch=function(a){var b=!1;if(d.hasOwnProperty(a))d[a].options.starts=null,b=!0;else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&& +d[c].domElementId===a){d[c].options.starts=null;b=!0;break}return b};this.resumeWatches=function(){for(var a in d)d.hasOwnProperty(a)&&(d[a].options.starts=null);return this};this.searchDomForNewWatches=function(){I();return this};this.setConfiguration=function(a){q=t(a)?a:{};P();return this};this.getVersion=function(){return"0.6.0"};(function(a,b){y=a;F=b;P();y.addEventListener("DOMContentLoaded",function(){I()});F.addEventListener("unload",function(){O()});r(F.$observe)||(F.$observe=this)})(document, +window)})(); \ No newline at end of file diff --git a/docs/CHANGE_LOG.md b/docs/CHANGE_LOG.md index bd052ef..50f99fd 100644 --- a/docs/CHANGE_LOG.md +++ b/docs/CHANGE_LOG.md @@ -2,6 +2,10 @@ ## Version 0.6.0: +#### **Public Functions:** +- Added new public function "pauseWatches()", which is used to pause all the watches for a specific number of milliseconds. +- Added new public function "resumeWatches()", which is used to resume all the watches currently paused. + #### **General Improvements:** - Minor internal refactoring to make things a little clearer. diff --git a/docs/PUBLIC_FUNCTIONS.md b/docs/PUBLIC_FUNCTIONS.md index 9b0fc67..90d7a68 100644 --- a/docs/PUBLIC_FUNCTIONS.md +++ b/docs/PUBLIC_FUNCTIONS.md @@ -55,12 +55,26 @@ Pauses the watching of an object for changes for a specific number of millisecon ***Returns***: '*boolean*' - States if the object being watched has been paused.
+### **pauseWatches( *milliseconds* )**: +Pauses all the watches for a specific number of milliseconds. +
+***Parameter: milliseconds***: '*number*' - The milliseconds to pause the watches for. +
+***Returns***: '*Object*' - The Observe.js class instance. +
+ ### **resumeWatch( *id* )**: -Resumes the watching of an object for changes after it was paused. +Resumes the all the watches that are currently paused.
***Parameter: id***: '*string*' - The ID of the object being watched, or DOM element ID being watched.
-***Returns***: '*boolean*' - States if the watching of an object has been resumed +***Returns***: '*boolean*' - States if the watching of an object has been resumed. +
+ +### **resumeWatches()**: +Resumes the watching of all objects for changes after they were paused. +
+***Returns***: '*Object*' - The Observe.js class instance.
### **searchDomForNewWatches()**: diff --git a/src/observe.js b/src/observe.js index 2d89525..de03587 100644 --- a/src/observe.js +++ b/src/observe.js @@ -624,6 +624,27 @@ return result; }; + /** + * pauseWatches(). + * + * Pauses all the watches for a specific number of milliseconds. + * + * @public + * + * @param {number} milliseconds The milliseconds to pause the watches for. + * + * @returns {Object} The Observe.js class instance. + */ + this.pauseWatches = function( milliseconds ) { + for ( var storageId in _watches ) { + if ( _watches.hasOwnProperty( storageId ) ) { + pauseWatchObject( storageId, milliseconds ); + } + } + + return this; + }; + /** * resumeWatch(). * @@ -655,6 +676,25 @@ return result; }; + /** + * resumeWatches(). + * + * Resumes the all the watches that are currently paused. + * + * @public + * + * @returns {Object} The Observe.js class instance. + */ + this.resumeWatches = function() { + for ( var storageId in _watches ) { + if ( _watches.hasOwnProperty( storageId ) ) { + _watches[ storageId ].options.starts = null; + } + } + + return this; + }; + /** * searchDomForNewWatches(). * From 5b80542043d818d6d71d0660bbcfc5507a3746f1 Mon Sep 17 00:00:00 2001 From: William Troup Date: Mon, 8 Jan 2024 16:42:07 +0000 Subject: [PATCH 5/8] Improved HTML testing files. --- test/dist/observe.js.basic.html | 10 +++++++++- test/dist/observe.js.min.html | 10 +++++++++- test/src/observe.js.basic.html | 10 +++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/test/dist/observe.js.basic.html b/test/dist/observe.js.basic.html index cc29493..7ae5658 100644 --- a/test/dist/observe.js.basic.html +++ b/test/dist/observe.js.basic.html @@ -43,11 +43,19 @@

Pause Watch:


+

Pause Watches:

+ +
+

Resume Watch:

- +
+

Resume Watches:

+ +
+

Get Watch:

diff --git a/test/dist/observe.js.min.html b/test/dist/observe.js.min.html index f8811a5..be82e1e 100644 --- a/test/dist/observe.js.min.html +++ b/test/dist/observe.js.min.html @@ -43,11 +43,19 @@

Pause Watch:


+

Pause Watches:

+ +
+

Resume Watch:

- +
+

Resume Watches:

+ +
+

Get Watch:

diff --git a/test/src/observe.js.basic.html b/test/src/observe.js.basic.html index 2a73d72..71bdee8 100644 --- a/test/src/observe.js.basic.html +++ b/test/src/observe.js.basic.html @@ -43,11 +43,19 @@

Pause Watch:


+

Pause Watches:

+ +
+

Resume Watch:

- +
+

Resume Watches:

+ +
+

Get Watch:

From d05403c250807fb84aa53f45687a2d278b55ac41 Mon Sep 17 00:00:00 2001 From: William Troup Date: Mon, 8 Jan 2024 16:42:40 +0000 Subject: [PATCH 6/8] Updated change log. --- docs/CHANGE_LOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/CHANGE_LOG.md b/docs/CHANGE_LOG.md index 50f99fd..45ec6fd 100644 --- a/docs/CHANGE_LOG.md +++ b/docs/CHANGE_LOG.md @@ -9,6 +9,9 @@ #### **General Improvements:** - Minor internal refactoring to make things a little clearer. +#### **Fixes:** +- Fixed some errors in HTML files when calling the public functions. +
From 5c32c87bd27dc4864b7a33e6e3baf66a7d096d48 Mon Sep 17 00:00:00 2001 From: William Troup Date: Mon, 8 Jan 2024 16:50:30 +0000 Subject: [PATCH 7/8] Added new options to disable pausing and canceling. --- dist/observe.js | 21 +++++++++++++++------ dist/observe.min.js | 24 ++++++++++++------------ docs/CHANGE_LOG.md | 4 ++++ docs/binding/options/OPTIONS.md | 2 ++ src/observe.js | 29 ++++++++++++++++++++--------- 5 files changed, 53 insertions(+), 27 deletions(-) diff --git a/dist/observe.js b/dist/observe.js index 5d6f961..51dcb91 100644 --- a/dist/observe.js +++ b/dist/observe.js @@ -179,18 +179,23 @@ } function cancelWatchObject(storageId) { if (_watches.hasOwnProperty(storageId)) { - fireCustomTrigger(_watches[storageId].options.onCancel, storageId); - clearTimeout(_watches[storageId].timer); - delete _watches[storageId]; + var watchOptions = _watches[storageId].options; + if (watchOptions.allowCanceling || _watches_Cancel) { + fireCustomTrigger(watchOptions.onCancel, storageId); + clearTimeout(_watches[storageId].timer); + delete _watches[storageId]; + } } } function pauseWatchObject(storageId, milliseconds) { var result = false; if (_watches.hasOwnProperty(storageId)) { var watchOptions = _watches[storageId].options; - watchOptions.starts = new Date(); - watchOptions.starts.setMilliseconds(watchOptions.starts.getMilliseconds() + milliseconds); - result = true; + if (watchOptions.allowPausing) { + watchOptions.starts = new Date(); + watchOptions.starts.setMilliseconds(watchOptions.starts.getMilliseconds() + milliseconds); + result = true; + } } return result; } @@ -204,6 +209,8 @@ options.maximumChangesBeforeCanceling = getDefaultNumber(options.maximumChangesBeforeCanceling, 0); options.pauseTimeoutOnChange = getDefaultNumber(options.pauseTimeoutOnChange, 0); options.propertyNames = getDefaultArray(options.propertyNames, null); + options.allowCanceling = getDefaultBoolean(options.allowCanceling, true); + options.allowPausing = getDefaultBoolean(options.allowPausing, null); options = getWatchOptionsCustomTriggers(options); return options; } @@ -317,6 +324,7 @@ var _parameter_Window = null; var _string = {empty:""}; var _watches = {}; + var _watches_Cancel = false; var _configuration = {}; var _attribute_Name_Watch_Options = "data-observe-watch-options"; this.watch = function(object, options) { @@ -431,6 +439,7 @@ collectDOMObjects(); }); _parameter_Window.addEventListener("unload", function() { + _watches_Cancel = true; cancelWatchesForObjects(); }); if (!isDefined(_parameter_Window.$observe)) { diff --git a/dist/observe.min.js b/dist/observe.min.js index d29555f..6d24f6c 100644 --- a/dist/observe.min.js +++ b/dist/observe.min.js @@ -1,13 +1,13 @@ /*! Observe.js v0.6.0 | (c) Bunoon 2024 | MIT License */ -(function(){function I(){for(var a=q.domElementTypes,b=a.length,c=0;c=k.starts){if(d.hasOwnProperty(h)){var e=d[h],g=p(e.domElementId), -m=null;g&&(m=y.getElementById(e.domElementId),r(m)?e.originalObject=m.outerHTML:(e.originalObject=B.empty,u(e.options.onRemove,e.domElementId)));var v=e.cachedObject,n=e.originalObject;n=g?n:JSON.stringify(n);if(v!==n){e.options.reset?g?m.outerHTML=e.cachedObject:e.originalObject=z(v).result:e.cachedObject=n;if(g)u(e.options.onChange,v,n);else if(g=z(v).result,m=z(n).result,w(g)||w(m))u(e.options.onChange,g,m);else{if(w(e.options.propertyNames))for(v=e.options.propertyNames.length,n=0;n=e.options.maximumChangesBeforeCanceling&&x(h)}}A(k.expires)&&l>=k.expires&&x(h)}},k.timeout);d[f]=b}return f}function N(a,b,c){for(var f in a)if(a.hasOwnProperty(f)){var k=a[f], -h=null;b.hasOwnProperty(f)&&(h=b[f]);t(k)&&t(h)?N(k,h,c.options):(!w(c.options.propertyNames)||-1b;b++){8!==b&&12!==b&&16!==b&&20!==b||a.push("-");var c=Math.floor(16*Math.random()).toString(16);a.push(c)}return a.join(B.empty)}function r(a){return null!==a&&void 0!==a&&a!==B.empty}function t(a){return r(a)&&"object"===typeof a}function p(a){return r(a)&&"string"===typeof a}function C(a){return r(a)&&"function"===typeof a}function w(a){return t(a)&&a instanceof Array}function A(a){return t(a)&& -a instanceof Date}function H(a,b){return r(a)&&"boolean"===typeof a?a:b}function E(a,b){return C(a)?a:b}function G(a,b){return r(a)&&"number"===typeof a?a:b}function z(a){var b=!0,c=null;try{p(a)&&(c=JSON.parse(a))}catch(f){try{c=eval("("+a+")"),C(c)&&(c=c())}catch(k){b=Q("Errors in object: "+f.message+", "+k.message),c=null}}return{parsed:b,result:c}}function Q(a){var b=!0;q.safeMode||(console.error(a),b=!1);return b}function P(){q.safeMode=H(q.safeMode,!0);var a=q,b=q.domElementTypes,c=["*"];p(b)? -(b=b.split(B.space),0===b.length&&(b=c)):b=w(b)?b:c;a.domElementTypes=b}var y=null,F=null,B={empty:""},d={},q={};this.watch=function(a,b){return L(a,b)};this.cancelWatch=function(a){var b=!1;if(d.hasOwnProperty(a))x(a),b=!0;else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&&d[c].domElementId===a){x(c);b=!0;break}return b};this.cancelWatches=function(){O();return this};this.getWatch=function(a){var b=null;if(d.hasOwnProperty(a))b=d[a];else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&& -d[c].domElementId===a){b=d[c];break}return b};this.getWatches=function(){return d};this.pauseWatch=function(a,b){var c=!1;if(d.hasOwnProperty(a))c=D(a,b);else for(var f in d)if(d.hasOwnProperty(f)&&p(d[f].domElementId)&&d[f].domElementId===a){c=D(f,b);break}return c};this.pauseWatches=function(a){for(var b in d)d.hasOwnProperty(b)&&D(b,a);return this};this.resumeWatch=function(a){var b=!1;if(d.hasOwnProperty(a))d[a].options.starts=null,b=!0;else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&& -d[c].domElementId===a){d[c].options.starts=null;b=!0;break}return b};this.resumeWatches=function(){for(var a in d)d.hasOwnProperty(a)&&(d[a].options.starts=null);return this};this.searchDomForNewWatches=function(){I();return this};this.setConfiguration=function(a){q=t(a)?a:{};P();return this};this.getVersion=function(){return"0.6.0"};(function(a,b){y=a;F=b;P();y.addEventListener("DOMContentLoaded",function(){I()});F.addEventListener("unload",function(){O()});r(F.$observe)||(F.$observe=this)})(document, -window)})(); \ No newline at end of file +(function(){function I(){for(var a=q.domElementTypes,b=a.length,c=0;c=k.starts){if(d.hasOwnProperty(h)){var e=d[h],g=p(e.domElementId), +m=null;g&&(m=y.getElementById(e.domElementId),r(m)?e.originalObject=m.outerHTML:(e.originalObject=C.empty,u(e.options.onRemove,e.domElementId)));var v=e.cachedObject,n=e.originalObject;n=g?n:JSON.stringify(n);if(v!==n){e.options.reset?g?m.outerHTML=e.cachedObject:e.originalObject=A(v).result:e.cachedObject=n;if(g)u(e.options.onChange,v,n);else if(g=A(v).result,m=A(n).result,w(g)||w(m))u(e.options.onChange,g,m);else{if(w(e.options.propertyNames))for(v=e.options.propertyNames.length,n=0;n=e.options.maximumChangesBeforeCanceling&&x(h)}}B(k.expires)&&l>=k.expires&&x(h)}},k.timeout);d[f]=b}return f}function N(a,b,c){for(var f in a)if(a.hasOwnProperty(f)){var k=a[f], +h=null;b.hasOwnProperty(f)&&(h=b[f]);t(k)&&t(h)?N(k,h,c.options):(!w(c.options.propertyNames)||-1b;b++){8!==b&&12!==b&&16!==b&&20!==b||a.push("-");var c=Math.floor(16*Math.random()).toString(16);a.push(c)}return a.join(C.empty)}function r(a){return null!==a&&void 0!==a&&a!==C.empty}function t(a){return r(a)&&"object"===typeof a}function p(a){return r(a)&& +"string"===typeof a}function D(a){return r(a)&&"function"===typeof a}function w(a){return t(a)&&a instanceof Array}function B(a){return t(a)&&a instanceof Date}function z(a,b){return r(a)&&"boolean"===typeof a?a:b}function F(a,b){return D(a)?a:b}function H(a,b){return r(a)&&"number"===typeof a?a:b}function A(a){var b=!0,c=null;try{p(a)&&(c=JSON.parse(a))}catch(f){try{c=eval("("+a+")"),D(c)&&(c=c())}catch(k){b=R("Errors in object: "+f.message+", "+k.message),c=null}}return{parsed:b,result:c}}function R(a){var b= +!0;q.safeMode||(console.error(a),b=!1);return b}function Q(){q.safeMode=z(q.safeMode,!0);var a=q,b=q.domElementTypes,c=["*"];p(b)?(b=b.split(C.space),0===b.length&&(b=c)):b=w(b)?b:c;a.domElementTypes=b}var y=null,G=null,C={empty:""},d={},P=!1,q={};this.watch=function(a,b){return L(a,b)};this.cancelWatch=function(a){var b=!1;if(d.hasOwnProperty(a))x(a),b=!0;else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&&d[c].domElementId===a){x(c);b=!0;break}return b};this.cancelWatches=function(){O(); +return this};this.getWatch=function(a){var b=null;if(d.hasOwnProperty(a))b=d[a];else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&&d[c].domElementId===a){b=d[c];break}return b};this.getWatches=function(){return d};this.pauseWatch=function(a,b){var c=!1;if(d.hasOwnProperty(a))c=E(a,b);else for(var f in d)if(d.hasOwnProperty(f)&&p(d[f].domElementId)&&d[f].domElementId===a){c=E(f,b);break}return c};this.pauseWatches=function(a){for(var b in d)d.hasOwnProperty(b)&&E(b,a);return this};this.resumeWatch= +function(a){var b=!1;if(d.hasOwnProperty(a))d[a].options.starts=null,b=!0;else for(var c in d)if(d.hasOwnProperty(c)&&p(d[c].domElementId)&&d[c].domElementId===a){d[c].options.starts=null;b=!0;break}return b};this.resumeWatches=function(){for(var a in d)d.hasOwnProperty(a)&&(d[a].options.starts=null);return this};this.searchDomForNewWatches=function(){I();return this};this.setConfiguration=function(a){q=t(a)?a:{};Q();return this};this.getVersion=function(){return"0.6.0"};(function(a,b){y=a;G=b;Q(); +y.addEventListener("DOMContentLoaded",function(){I()});G.addEventListener("unload",function(){P=!0;O()});r(G.$observe)||(G.$observe=this)})(document,window)})(); \ No newline at end of file diff --git a/docs/CHANGE_LOG.md b/docs/CHANGE_LOG.md index 45ec6fd..8cfde0d 100644 --- a/docs/CHANGE_LOG.md +++ b/docs/CHANGE_LOG.md @@ -2,6 +2,10 @@ ## Version 0.6.0: +#### **Binding Options / Function Options:** +- Added a new binding/option called "allowCanceling", which states the watch can be canceled (defaults to true). +- Added a new binding/option called "allowPausing", which states the watch can be paused (defaults to true). + #### **Public Functions:** - Added new public function "pauseWatches()", which is used to pause all the watches for a specific number of milliseconds. - Added new public function "resumeWatches()", which is used to resume all the watches currently paused. diff --git a/docs/binding/options/OPTIONS.md b/docs/binding/options/OPTIONS.md index a5daa73..df7fe7e 100644 --- a/docs/binding/options/OPTIONS.md +++ b/docs/binding/options/OPTIONS.md @@ -17,6 +17,8 @@ Below is a list of all the options supported in the "data-observe-watch-options" | *number* | maximumChangesBeforeCanceling | States the total number of changes that are allowed before the watch is cancelled (defaults to 0, which is off) | | *number* | pauseTimeoutOnChange | States the delay (in milliseconds) that should be used before checking for changes again after a change is detected (defaults to 0, which is off) | | *string[]* | propertyNames | States the property names that should be watched for changes (defaults to all). | +| *boolean* | allowCanceling | States if the watch can be canceled (defaults to true). | +| *boolean* | allowPausing | States if the watch can be paused (defaults to true). |
diff --git a/src/observe.js b/src/observe.js index de03587..8a174b1 100644 --- a/src/observe.js +++ b/src/observe.js @@ -23,6 +23,7 @@ // Variables: Watches _watches = {}, + _watches_Cancel = false, // Variables: Configuration _configuration = {}, @@ -269,10 +270,14 @@ function cancelWatchObject( storageId ) { if ( _watches.hasOwnProperty( storageId ) ) { - fireCustomTrigger( _watches[ storageId ].options.onCancel, storageId ); - clearTimeout( _watches[ storageId ].timer ); - - delete _watches[ storageId ]; + var watchOptions = _watches[ storageId ].options; + + if ( watchOptions.allowCanceling || _watches_Cancel ) { + fireCustomTrigger( watchOptions.onCancel, storageId ); + clearTimeout( _watches[ storageId ].timer ); + + delete _watches[ storageId ]; + } } } @@ -282,10 +287,12 @@ if ( _watches.hasOwnProperty( storageId ) ) { var watchOptions = _watches[ storageId ].options; - watchOptions.starts = new Date(); - watchOptions.starts.setMilliseconds( watchOptions.starts.getMilliseconds() + milliseconds ); - - result = true; + if ( watchOptions.allowPausing ) { + watchOptions.starts = new Date(); + watchOptions.starts.setMilliseconds( watchOptions.starts.getMilliseconds() + milliseconds ); + + result = true; + } } return result; @@ -309,7 +316,9 @@ options.maximumChangesBeforeCanceling = getDefaultNumber( options.maximumChangesBeforeCanceling, 0 ); options.pauseTimeoutOnChange = getDefaultNumber( options.pauseTimeoutOnChange, 0 ); options.propertyNames = getDefaultArray( options.propertyNames, null ); - + options.allowCanceling = getDefaultBoolean( options.allowCanceling, true ); + options.allowPausing = getDefaultBoolean( options.allowPausing, null ); + options = getWatchOptionsCustomTriggers( options ); return options; @@ -779,6 +788,8 @@ } ); _parameter_Window.addEventListener( "unload", function() { + _watches_Cancel = true; + cancelWatchesForObjects(); } ); From f2ba24610430f6935bef4b9911126aea822c6eea Mon Sep 17 00:00:00 2001 From: William Troup Date: Mon, 8 Jan 2024 17:01:01 +0000 Subject: [PATCH 8/8] Updated documentation. --- docs/CHANGE_LOG.md | 2 +- docs/PUBLIC_FUNCTIONS.md | 2 +- docs/binding/options/OPTIONS.md | 2 +- src/observe.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/CHANGE_LOG.md b/docs/CHANGE_LOG.md index 8cfde0d..42aaec2 100644 --- a/docs/CHANGE_LOG.md +++ b/docs/CHANGE_LOG.md @@ -3,7 +3,7 @@ ## Version 0.6.0: #### **Binding Options / Function Options:** -- Added a new binding/option called "allowCanceling", which states the watch can be canceled (defaults to true). +- Added a new binding/option called "allowCanceling", which states the watch can be cancelled (defaults to true). - Added a new binding/option called "allowPausing", which states the watch can be paused (defaults to true). #### **Public Functions:** diff --git a/docs/PUBLIC_FUNCTIONS.md b/docs/PUBLIC_FUNCTIONS.md index 90d7a68..4ad7478 100644 --- a/docs/PUBLIC_FUNCTIONS.md +++ b/docs/PUBLIC_FUNCTIONS.md @@ -64,7 +64,7 @@ Pauses all the watches for a specific number of milliseconds.
### **resumeWatch( *id* )**: -Resumes the all the watches that are currently paused. +Resumes all the watches that are currently paused.
***Parameter: id***: '*string*' - The ID of the object being watched, or DOM element ID being watched.
diff --git a/docs/binding/options/OPTIONS.md b/docs/binding/options/OPTIONS.md index df7fe7e..2b384cc 100644 --- a/docs/binding/options/OPTIONS.md +++ b/docs/binding/options/OPTIONS.md @@ -17,7 +17,7 @@ Below is a list of all the options supported in the "data-observe-watch-options" | *number* | maximumChangesBeforeCanceling | States the total number of changes that are allowed before the watch is cancelled (defaults to 0, which is off) | | *number* | pauseTimeoutOnChange | States the delay (in milliseconds) that should be used before checking for changes again after a change is detected (defaults to 0, which is off) | | *string[]* | propertyNames | States the property names that should be watched for changes (defaults to all). | -| *boolean* | allowCanceling | States if the watch can be canceled (defaults to true). | +| *boolean* | allowCanceling | States if the watch can be cancelled (defaults to true). | | *boolean* | allowPausing | States if the watch can be paused (defaults to true). |
diff --git a/src/observe.js b/src/observe.js index 8a174b1..105f35d 100644 --- a/src/observe.js +++ b/src/observe.js @@ -688,7 +688,7 @@ /** * resumeWatches(). * - * Resumes the all the watches that are currently paused. + * Resumes all the watches that are currently paused. * * @public *