Commit c74b27de authored by Troy A. Griffitts's avatar Troy A. Griffitts

Added History feature. Added Disable Topbar feature

parent 2126756c
......@@ -182,3 +182,5 @@ Stone Blue Dark=Stone Blue Dark
Stone Blue Light=Stone Blue Light
No Installation Sources Known. Pressto Discover.=No Installation Sources Known. Pressto Discover.
Discover=↻ Discover
History=History
Exit?=Exit?
......@@ -366,13 +366,13 @@ table.nobottom td, table.nobottom th {
.slidemenu select {
}
.searchPanel,.bibleSyncPanel,.bookmarkPanel,.settingsPanel,.viewSelectorPanel {
.searchPanel,.bibleSyncPanel,.bookmarkPanel,.historyPanel,.settingsPanel,.viewSelectorPanel {
height:0em;
overflow:hidden;
width:100%;
}
#bibleSyncResults,#searchResults,#bookmarkResults {
#bibleSyncResults,#searchResults,#bookmarkResults,#historyResults {
width:100%;
height:100%;
top:0px;
......@@ -404,12 +404,20 @@ table.nobottom td, table.nobottom th {
}
.keySelector, .keySelector td, .keySelector th {
border-width:0;
margin: 0px 0px 0px 0px;
font-size: 95%;
color: #000000;
}
.bibleSelector, .bibleSelector td, .bibleSelector th {
border-width:0;
margin: 0px 0px 0px 0px;
font-size: 95%;
background-color: #b9baba;
color: #000000;
}
.about {
padding: 0px 1em 0px 1em;
margin: 0px -1em 0px -1em;
......@@ -1504,9 +1512,9 @@ padding: 0 0 0px 0;
}
span.versenum {
font-size: 75%;
font-size: 80%;
position: relative;
top:-0.25em;
top:-0.20em;
}
span.versenum a {
......
This diff is collapsed.
......@@ -6,17 +6,28 @@ var dataStore = {
window.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
if (window.indexedDB === undefined) return callback ? callback() : null;
var req = window.indexedDB.open(dataStore.dbName, 2);
var req = window.indexedDB.open(dataStore.dbName, 3);
req.onerror = function(event) {
};
req.onupgradeneeded = function(event) {
console.log("DB upgrade needed");
var db = event.target.result;
if (db.objectStoreNames.contains("bookmarks")) {
db.deleteObjectStore("bookmarks");
// no need to delete unless we've changes something
// db.deleteObjectStore("bookmarks");
}
else {
var objectStore = db.createObjectStore("bookmarks", { keyPath: "_id", autoIncrement: true });
objectStore.createIndex("osisID", "osisID", { unique: false });
}
if (db.objectStoreNames.contains("history")) {
// no need to delete unless we've changes something
// db.deleteObjectStore("history");
}
else {
var objectStore = db.createObjectStore("history", { keyPath: "_id", autoIncrement: true });
objectStore.createIndex("osisID", "osisID", { unique: false });
}
var objectStore = db.createObjectStore("bookmarks", { keyPath: "_id", autoIncrement: true });
objectStore.createIndex("osisID", "osisID", { unique: false });
};
req.onsuccess = function(event) {
console.log("DB opened");
......@@ -94,4 +105,74 @@ console.log("db tranaction error");
} else if (callback) callback(results);
};
},
addHistory: function(osisID, callback) {
if (window.indexedDB === undefined) return callback ? callback() : null;
dataStore.deleteHistory(osisID, function() {
dataStore.saveHistory(osisID, callback);
});
},
deleteHistory: function(osisID, callback) {
if (window.indexedDB === undefined) return callback ? callback() : null;
var transaction = dataStore.db.transaction(["history"],"readwrite");
var store = transaction.objectStore("history");
var index = store.index('osisID');
var request = index.get(osisID);
request.onsuccess = function(event) {
var record = event.target.result;
if (record) {
var recordID = event.target.result._id;
console.log('recordID = ' + recordID);
var transaction = dataStore.db.transaction(["history"],"readwrite");
var objectStore = transaction.objectStore("history");
console.log('objectStore = ' + objectStore);
var req = objectStore['delete'](recordID);
req.onsuccess = req.onerror = function() {
if (callback) callback();
}
}
else if (callback) callback();
}
request.onerror = function(event) {
if (callback) callback();
}
},
deleteAllHistory: function(callback) {
if (window.indexedDB === undefined) return callback ? callback() : null;
var store = dataStore.db.transaction(["history"],"readwrite").objectStore("history");
var request = store.clear();
request.onsuccess = request.onerror = function(event) {
if (callback) callback();
}
},
saveHistory: function(osisID, callback) {
if (window.indexedDB === undefined) return callback ? callback() : null;
var transaction = dataStore.db.transaction(["history"],"readwrite");
transaction.oncomplete = function(event) {
console.log("db transaction success");
if (callback) callback();
};
transaction.onerror = function(event) {
console.log("db tranaction error");
};
var objectStore = transaction.objectStore("history");
objectStore.add({ osisID : osisID});
},
getHistory : function(callback) {
var results = [];
if (window.indexedDB === undefined) return callback ? callback(results) : null;
if (!dataStore.db) { if (callback) callback(results); return; }
var store = dataStore.db.transaction(["history"],"readwrite").objectStore("history");
var request = store.openCursor(null, 'prev');
request.onsuccess = function(event) {
var cursor = event.target.result;
if (cursor) {
results.push(cursor.value.osisID);
cursor['continue']();
} else if (callback) callback(results);
};
},
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment