-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Small changes to token parsing and audio event saving
- Loading branch information
Showing
3 changed files
with
83 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,89 @@ | ||
var baw = window.baw = window.baw || {}; | ||
var baw = window.baw = window.baw || {}; | ||
|
||
/** | ||
* | ||
* @param localIdOrResource | ||
* @param {*=} audioRecordingId | ||
* @constructor | ||
*/ | ||
baw.Annotation = function Annotation(localIdOrResource, audioRecordingId) { | ||
/** | ||
* | ||
* @param localIdOrResource | ||
* @param {*=} audioRecordingId | ||
* @constructor | ||
*/ | ||
baw.Annotation = function Annotation(localIdOrResource, audioRecordingId) { | ||
|
||
var localId = typeof(localIdOrResource) === "number" ? localIdOrResource : undefined; | ||
var resource; | ||
if (localIdOrResource instanceof Object && localIdOrResource.constructor.name == "Resource") { | ||
resource = localIdOrResource; | ||
} | ||
var localId = typeof(localIdOrResource) === "number" ? localIdOrResource : undefined; | ||
var resource; | ||
if (localIdOrResource instanceof Object && localIdOrResource.constructor.name == "Resource") { | ||
resource = localIdOrResource; | ||
} | ||
|
||
if (!(this instanceof Annotation)) { | ||
throw new Error("Constructor called as a function"); | ||
} | ||
if (!(this instanceof Annotation)) { | ||
throw new Error("Constructor called as a function"); | ||
} | ||
|
||
this.__temporaryId__ = localId || Number.Unique(); | ||
this._selected = false; | ||
this.audioEventTags = []; | ||
this.__temporaryId__ = localId || Number.Unique(); | ||
this._selected = false; | ||
this.audioEventTags = []; | ||
|
||
if (localId) { | ||
var now = new Date(); | ||
if (localId) { | ||
var now = new Date(); | ||
|
||
this.audioRecordingId = audioRecordingId; | ||
this.audioRecordingId = audioRecordingId; | ||
|
||
this.createdAt = now; | ||
this.updatedAt = now; | ||
this.createdAt = now; | ||
this.updatedAt = now; | ||
|
||
this.endTimeSeconds = 0.0; | ||
this.highFrequencyHertz = 0.0; | ||
this.isReference = false; | ||
this.lowFrequencyHertz = 0.0; | ||
this.startTimeSeconds = 0.0; | ||
this.endTimeSeconds = 0.0; | ||
this.highFrequencyHertz = 0.0; | ||
this.isReference = false; | ||
this.lowFrequencyHertz = 0.0; | ||
this.startTimeSeconds = 0.0; | ||
|
||
} | ||
} | ||
|
||
// ensure JSON values taken from a resource have nicely formatted values | ||
if (resource) { | ||
angular.extend(this, resource); | ||
// ensure JSON values taken from a resource have nicely formatted values | ||
if (resource) { | ||
angular.extend(this, resource); | ||
|
||
this.createdAt = new Date(this.createdAt); | ||
this.updatedAt = new Date(this.updatedAt); | ||
this.createdAt = new Date(this.createdAt); | ||
this.updatedAt = new Date(this.updatedAt); | ||
|
||
this.endTimeSeconds = parseFloat(this.endTimeSeconds); | ||
this.highFrequencyHertz = parseFloat(this.highFrequencyHertz); | ||
this.lowFrequencyHertz = parseFloat(this.lowFrequencyHertz); | ||
this.startTimeSeconds = parseFloat(this.startTimeSeconds); | ||
this.endTimeSeconds = parseFloat(this.endTimeSeconds); | ||
this.highFrequencyHertz = parseFloat(this.highFrequencyHertz); | ||
this.lowFrequencyHertz = parseFloat(this.lowFrequencyHertz); | ||
this.startTimeSeconds = parseFloat(this.startTimeSeconds); | ||
|
||
this.audioEventTags = {}; | ||
angular.forEach(this.audioEventTags, function(value, key) { | ||
this.audioEventTags[key] = new baw.AudioEventTag(value); | ||
}, this); | ||
} | ||
this.audioEventTags = {}; | ||
angular.forEach(this.audioEventTags, function (value, key) { | ||
this.audioEventTags[key] = new baw.AudioEventTag(value); | ||
}, this); | ||
} | ||
|
||
// strip out unnecessary values; | ||
this.create = function() { | ||
// NO-OP | ||
return this; | ||
}; | ||
// | ||
// this.toJSON = function() { | ||
// return { | ||
// | ||
// } | ||
// }; | ||
// strip out unnecessary values; | ||
this.create = function () { | ||
return { | ||
// TODO: | ||
taggings: [], | ||
audioRecordingId: this.audioRecordingId, | ||
createdAt: this.createdAt, | ||
endTimeSeconds: this.endTimeSeconds, | ||
highFrequencyHertz: this.highFrequencyHertz, | ||
isReference: this.isReference, | ||
lowFrequencyHertz: this.lowFrequencyHertz, | ||
startTimeSeconds: this.startTimeSeconds, | ||
updatedAt: this.updatedAt | ||
} | ||
}; | ||
|
||
// this.toJSON = function () { | ||
// return { | ||
// // TODO: | ||
// taggings: [], | ||
// audioRecordingId: this.audioRecordingId, | ||
// createdAt: this.createdAt, | ||
// endTimeSeconds: this.endTimeSeconds, | ||
// highFrequencyHertz: this.highFrequencyHertz, | ||
// isReference: this.isReference, | ||
// lowFrequencyHertz: this.lowFrequencyHertz, | ||
// startTimeSeconds: this.startTimeSeconds, | ||
// updatedAt: this.updatedAt | ||
// } | ||
// }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters