mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-25 16:29:49 -04:00
* It uses an indexedb datastore. * Fix the api of the indexeddb wrapper now that I have some real world usage examples. * Implemented API Calls: * UpdateTags * GetTags * Exposed but unimplemented API Calls: * GetVersesForTag * Sync * Add a tooltip that shows the tags for a reference to the reference link.
51 lines
2.0 KiB
JavaScript
51 lines
2.0 KiB
JavaScript
(function() {
|
|
var tagStore = 'tags';
|
|
define(
|
|
['db', 'reference'], function(db, reference) {
|
|
return {
|
|
// 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.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.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');
|
|
}
|
|
};
|
|
});
|
|
})();
|