Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.6.0 #6

Merged
merged 8 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
</h1>

> <p align="center">A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.</p>
> <p align="center">v0.5.1</p>
> <p align="center">v0.6.0</p>
<br />
<br>

Expand Down
6 changes: 3 additions & 3 deletions README_NUGET.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
48 changes: 37 additions & 11 deletions dist/observe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Observe.js v0.5.1 | (c) Bunoon | MIT License */
/*! Observe.js v0.6.0 | (c) Bunoon 2024 | MIT License */
(function() {
function collectDOMObjects() {
var tagTypes = _configuration.domElementTypes;
Expand Down Expand Up @@ -149,7 +149,6 @@
}
}
function compareWatchObjectProperties(oldObject, newObject, watch) {
var options = watch.options;
var propertyName;
for (propertyName in oldObject) {
if (oldObject.hasOwnProperty(propertyName)) {
Expand All @@ -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);
}
}
}
Expand All @@ -180,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;
}
Expand All @@ -205,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;
}
Expand Down Expand Up @@ -318,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) {
Expand Down Expand Up @@ -377,6 +384,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)) {
Expand All @@ -394,6 +410,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;
Expand All @@ -404,7 +429,7 @@
return this;
};
this.getVersion = function() {
return "0.5.1";
return "0.6.0";
};
(function(documentObject, windowObject) {
_parameter_Document = documentObject;
Expand All @@ -414,6 +439,7 @@
collectDOMObjects();
});
_parameter_Window.addEventListener("unload", function() {
_watches_Cancel = true;
cancelWatchesForObjects();
});
if (!isDefined(_parameter_Window.$observe)) {
Expand Down
25 changes: 13 additions & 12 deletions dist/observe.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions docs/CHANGE_LOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Observe.js - Change Log:

## Version 0.6.0:

#### **Binding Options / Function Options:**
- 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:**
- 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.

#### **Fixes:**
- Fixed some errors in HTML files when calling the public functions.

<br>


## Version 0.5.1:
- Project description update.
- Minor documentation updates.
Expand Down
Loading
Loading