mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-27 01:19:52 -04:00
54 lines
2.1 KiB
JavaScript
54 lines
2.1 KiB
JavaScript
(function() {
|
|
var tagStore = 'tags';
|
|
define(
|
|
['db', 'reference'], function(db, reference) {
|
|
return {
|
|
Capable: function() {
|
|
return db.Capable();
|
|
},
|
|
// UpdateTags updates a given references tags asynchronously.
|
|
// ref should be a Reference object.
|
|
// tags should be a list of strings representing the tags for this
|
|
// reference.
|
|
// callbacks.success is expected to be a function that takes
|
|
// an IDBRequest as an argument.
|
|
// callbacks.error is expected to be a function that takes
|
|
// an IDBRequest as an argument.
|
|
UpdateTags: function(ref, tags, callbacks) {
|
|
db.Capable() && db.Transaction(
|
|
[tagStore], function(trans) {
|
|
db.Update(
|
|
'tags', ref.toString(),
|
|
{tagList: tags, Ref: ref.toDict()},
|
|
callbacks, trans);
|
|
}, 'readwrite');
|
|
},
|
|
// GetTags retrieves a given references tags asynchronously.
|
|
// ref should be a Reference object.
|
|
// callbacks.success is expected to be a function that takes
|
|
// the list of tags as an argument.
|
|
// callbacks.error is expected to be a function that takes
|
|
// an IDBRequest as an argument.
|
|
GetTags: function(ref, callbacks) {
|
|
db.Capable() && db.Get(tagStore, ref.toString(),
|
|
{success: function(req) {
|
|
var data = req.target.result;
|
|
// TODO suppport book and chapter indexes for
|
|
// range lookups.
|
|
callbacks.success(data);
|
|
}});
|
|
},
|
|
GetVersesForTag: function() {
|
|
console.log('TODO(jwall): Implement GetVersesForTag');
|
|
},
|
|
// Sync retrieves a given references tags asynchronously.
|
|
// url should be a valid http URL to the service to sync the tags
|
|
// to.
|
|
// callbacks
|
|
Sync: function(url, callbacks) {
|
|
console.log('TODO(jwall): Implement Sync');
|
|
}
|
|
};
|
|
});
|
|
})();
|