Commit 8940e91c authored by Troy A. Griffitts's avatar Troy A. Griffitts

Added feature to check for and update Bible resources

parent 86216d81
......@@ -150,3 +150,11 @@ First Active=First Active
Nothing to display.=Nothing to display.
No Modules Installed=No Modules Installed
No Modules Available. Try pressing the [↻] button.=No Modules Available. Try pressing the [↻] button.
Would you like check for updates to your Bibles and other study resources?=Would you like check for updates to your Bibles and other study resources?
You have received an application updated since your last run.=You have received an application updated since your last run.
Installation Sources=Installation Sources
Updates Available=Updates Available
No installed resources have updates available. New study resources can be added by first selecting an installation source at the top.=No installed resources have updates available. New study resources can be added by first selecting an installation source at the top.
Below is a list of installed resources which have updates available. Click on any row to update the resource.=Below is a list of installed resources which have updates available. Click on any row to update the resource.
......@@ -53,6 +53,10 @@ body,td,div,span,p,.verse,.currentVerse {
overflow:hidden;
}
.clientMessage {
margin: 1em;
}
/* Landscape layout (with min-width) */
@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) {
#main {
......@@ -548,43 +552,43 @@ table.nobottom td, table.nobottom th {
}
.toolbar button.left {
width: 4em;
width: 5em;
left: 0;
}
.toolbar button.right {
width: 4em;
width: 5em;
right: 0;
}
.toolbar button.midLeft {
left: 4em;
width: calc(50% - 4em);
left: 5em;
width: calc(50% - 5em);
}
.toolbar button.midRight {
right: 4em;
width: calc(50% - 4em);
right: 5em;
width: calc(50% - 5em);
}
.toolbar .twentyFiveOne {
left: 4em;
width: calc((100% - 4em) / 4);
left: 5em;
width: calc((100% - 5em) / 4);
}
.toolbar .twentyFiveTwo {
left: calc(4em + ((100% - 4em) / 4));
width: calc((100% - 4em) / 4);
left: calc(5em + ((100% - 5em) / 4));
width: calc((100% - 5em) / 4);
}
.toolbar .twentyFiveThree {
left: calc(4em + ((100% - 4em) / 4 * 2));
width: calc((100% - 4em) / 4);
left: calc(5em + ((100% - 5em) / 4 * 2));
width: calc((100% - 5em) / 4);
}
.toolbar .twentyFiveFour {
right: 0;
width: calc((100% - 4em) / 4);
width: calc((100% - 5em) / 4);
}
......
var app = {
version: '1.3.4', // change version here and in config.xml, near top
version: '1.3.99', // change version here and in config.xml, near top
backFunction: null,
enableBibleSync : true,
enableViewTypes : true,
......@@ -61,7 +61,7 @@ console.log('using localFixup instead of real SWORD plugin');
cordova = {
plugins : {
permissions: {
checkPermission(x, callback) { if (callback) callback({ hasPermission : true }); }
checkPermission : function(x, callback) { if (callback) callback({ hasPermission : true }); }
}
},
file : {
......@@ -587,23 +587,8 @@ console.log('setCurrentKey: setting app.currentVerseKey: ' + JSON.stringify(app.
if (!app.currentVerseKey) app.setCurrentKey(app.getCurrentKey());
return app.currentVerseKey;
},
main: function () {
console.log('****************** ------------- ***********************');
console.log('****************** main called ***********************');
console.log('****************** ------------- ***********************');
dataStore.init(function() {
app.updateBookmarkDisplay();
try {
app.zoomLevel = parseInt(window.localStorage.getItem('textZoom'));
} catch (e) {}
if (!app.zoomLevel) app.zoomLevel = 100;
app.adjustUIFont(0);
});
app.popupHide();
// first time check
var firstCheck = function() {
// first time check
firstCheck : function() {
SWORD.mgr.getModInfoList(function(mods) {
app.mods = mods;
console.log('********* setting app.mods = ' + JSON.stringify(app.mods));
......@@ -619,8 +604,23 @@ console.log('*********** mainMod: ' + mainMod);
if (!mainModIsBible && modBibles.length) app.setCurrentMod1(prefBibleExists ? app.preferredBible : bibleMods[0].name);
app.show();
});
};
var installBundledResources = function() {
},
main: function () {
console.log('****************** ------------- ***********************');
console.log('****************** main called ***********************');
console.log('****************** ------------- ***********************');
dataStore.init(function() {
app.updateBookmarkDisplay();
try {
app.zoomLevel = parseInt(window.localStorage.getItem('textZoom'));
} catch (e) {}
if (!app.zoomLevel) app.zoomLevel = 100;
app.adjustUIFont(0);
});
app.popupHide();
var installBundledResources = function(callback) {
app.copyBundledResources('', '', function() {
// since we currently just nuke any top-level bundled resource folder, we can do this for mods.d/
// and modules/ or else other installed modules would be killed. We've added an exception for these
......@@ -633,10 +633,7 @@ console.log('*********** mainMod: ' + mainMod);
app.copyBundledResources('modules/', 'modules/', function() {
app.copyBundledResources('modules/lexdict/', 'modules/lexdict/', function() {
app.copyBundledResources('modules/lexdict/zld/', 'modules/lexdict/zld/', function() {
// setting an extraConfig forces a re-init and will pick up newly copied resources
app.setLastAppVersion(function() {
return firstCheck();
});
if (callback) return callback();
});
});
});
......@@ -647,9 +644,19 @@ console.log('*********** mainMod: ' + mainMod);
app.getLastAppVersion(function(lastVersion) {
if (lastVersion != app.version) {
installBundledResources();
installBundledResources(function() {
if (lastVersion && lastVersion.length) {
app.showModuleUpdateOption('You have received an application updated since your last run.', 'app.setLastAppVersion(app.firstCheck)');
}
else {
// setting an extraConfig forces a re-init and will pick up newly copied resources
app.setLastAppVersion(function() {
return app.firstCheck();
});
}
});
}
else firstCheck();
else app.firstCheck();
});
},
......@@ -830,6 +837,18 @@ console.log('stopping BibleSync');
app.closeBibleSync();
SWORD.mgr.stopBibleSync();
},
showModuleUpdateOption : function(message, cancelCallbackName) {
var t = '<div class="about"><center>';
t += '<p><span data-english="'+message+'">'+message+'</span></p>';
t += '<p><span data-english="Would you like check for updates to your Bibles and other study resources?">Would you like check for updates to your Bibles and other study resources?</span></p>';
t += '<button onclick="app.popupHide(); app.refreshResources();return false;" data-english="Update Resources">Update Resources</button> &nbsp;&nbsp; <button onclick="app.popupHide(); ' + (cancelCallbackName ? cancelCallbackName + '(); ' : '') + 'return false;" data-english="Cancel">Cancel</button></center>';
t += '</div>';
t += '<br/>';
t += '<br/>';
t += '<br/>';
app.popupShow(t);
return;
},
setShowGospelParallels : function(value) {
console.log('setShowGospelParallels: ' + value);
window.localStorage.setItem('showingGospelParallels', value ? 'true':'false');
......@@ -1513,6 +1532,15 @@ console.log("**** done showing firstime ****");
app.setAppLocale();
return;
},
refreshResources : function() {
installMgr.show(function() {
installMgr.refreshSources(function() {
app.setLastAppVersion(function() {
installMgr.showUpdatedResources();
});
});
});
},
installModule: function(mod, callback) {
console.log('**** installing mod: ' + mod);
console.log('**** showing installMgr');
......
......@@ -19,7 +19,7 @@ var installMgr = {
t += '<button class="dropbtn dropclick midLeft" onclick="return false;"><div><span><label for="modSource"><span data-english="Modules">Modules</span></label></span><select id="modSource" onchange="installMgr.modSourceChanged();"><option>Installed</option></select></div></button>';
t += '<button class="dropbtn dropclick midRight" onclick="return false;"><div><span><label for="catFilter"><span data-english="Type">Type</span></label></span><select id="catFilter" onchange="installMgr.modSourceChanged();"><option value="'+SWORD.CATEGORY_BIBLES+'" data-english="'+SWORD.CATEGORY_BIBLES+'">' + SWORD.CATEGORY_BIBLES + '</option></select></div></button>';
t += '<button class="dropbtn dropclick right" onclick="installMgr.refreshSources(); return false;"><div><span style="font-size:190%;font-weight:bold;"> &#x21bb; </span> <span data-english="Refresh">Refresh</span></div></button>';
t += '<button class="dropbtn dropclick right" onclick="installMgr.refreshSources(installMgr.showUpdatedResources); return false;"><div><span style="font-size:190%;font-weight:bold;"> &#x21bb; </span> <span data-english="Refresh">Refresh</span></div></button>';
t += '</header>';
......@@ -84,9 +84,11 @@ console.log('scrolling top to: ' + installMgr.lastScrollTop);
});
},
modSelected: function(row) {
var installed = $('#modSource').val() == 'Installed';
var update = $('#modSource').val() == 'Updates Available';
var installed = $('#modSource').val() == 'Installed' || update;
var modName = $(row).find('.instName').text();
if (installed) {
var sourceName = $(row).find('.sourceName').text();
if (installed && !update) {
SWORD.mgr.translate('Uninstall Module:', function(translated) {
if (confirm(translated + ' ' + modName)) {
SWORD.installMgr.uninstallModule(modName, function() {
......@@ -95,10 +97,18 @@ console.log('scrolling top to: ' + installMgr.lastScrollTop);
}
});
}
else if (update) {
SWORD.mgr.translate('Update Module:', function(translated) {
if (confirm(translated + ' ' + modName)) {
installMgr.installModule(sourceName, modName, function() {
installMgr.modSourceChanged();
});
}
});
}
else {
var sourceName = $('#modSource').val();
SWORD.installMgr.getRemoteModuleByName(sourceName, modName, function(remoteMod) {
console.log('remoteMod: ' + JSON.stringify(remoteMod));
remoteMod.getConfigEntry('UnlockInfo', function(unlockInfo) {
var ciphered = remoteMod.cipherKey !== undefined;
var t = '<div class="about">';
......@@ -120,7 +130,7 @@ console.log('remoteMod: ' + JSON.stringify(remoteMod));
remoteMod.getConfigEntry('About', function(about) {
t += '<div>'+(about?about:'')+'</div>';
if (remoteMod.shortPromo && remoteMod.shortPromo.length) t += '<div class="promoLine">' + remoteMod.shortPromo +'</div>';
t += '<br/>';
t += '<br/>';
t += '</div>';
app.popupShow(t);
});
......@@ -199,7 +209,7 @@ console.log('**** installMgr.installModule. disclaimer accepted. installing modu
});
},
showDisclaimer: function() {
var h = '<center><h2><span data-english="InstallMgr Warning Header|-=+* WARNING *+=-">-=+* WARNING *+=-</span></h2></center>';
var h = '<div class="clientMessage"><center><h2><span data-english="InstallMgr Warning Header|-=+* WARNING *+=-">-=+* WARNING *+=-</span></h2></center>';
h += '<p data-english="InstallMgr Warning L1|Although Install Manager provides a convenient way for installing ';
h += 'and upgrading SWORD components, it also uses a systematic method ';
h += 'for accessing sites which gives packet sniffers a target to lock ';
......@@ -232,7 +242,7 @@ console.log('**** installMgr.installModule. disclaimer accepted. installing modu
h += '<p><center><button style="height:3em;" onclick="installMgr.setDisclaimerAccepted();return false;"><span data-english="InstallMgr Warning Accept|Accept">Accept</span></button></center></p>';
h += '<br/>';
h += '<br/>';
h += '<br/>';
h += '<br/></div>';
$('#client').html(h);
app.setAppLocale();
},
......@@ -250,17 +260,75 @@ console.log('**** installMgr.installModule. disclaimer accepted. installing modu
modSourceChanged: function() {
var sourceName = $('#modSource').val();
if (sourceName == 'Installed') installMgr.showInstalled();
else if (sourceName == 'Updates Available') installMgr.showUpdatedResources();
else installMgr.showRemoteModules(sourceName);
},
refreshModSourceList: function(callback) {
var t = '<option value="Installed" data-english="Installed">Installed</option>';
t += '<option value="Updates Available" data-english="Updates Available">Updates Available</option>';
SWORD.mgr.translate('Installation Sources', function(translated) {
t += '<optgroup label="'+translated+'">';
SWORD.installMgr.getRemoteSources(function(sources) {
for (var i = 0; i < sources.length; ++i) {
t += '<option>'+sources[i]+'</option>';
}
t += '</optgroup>';
$('#modSource').html(t);
app.setAppLocale();
if (callback) callback();
});
});
},
showUpdatedResources : function(callbackIfNone) {
$('#modSource').val('Updates Available');
SWORD.installMgr.getRemoteSources(function(sources) {
for (var i = 0; i < sources.length; ++i) {
t += '<option>'+sources[i]+'</option>';
}
$('#modSource').html(t);
app.setAppLocale();
if (callback) callback();
var t = '';
var count = 0;
var sourcesLoop = function(srcs, i) {
if (!i) i = 0; if (i >= srcs.length) {
var h = '<div class="clientMessage">';
if (!count) {
if (callbackIfNone) return callbackIfNone();
h += '<h3 data-english="No installed resources have updates available. New study resources can be added by first selecting an installation source at the top.">';
h += 'No installed resources have updates available. New study resources can be added by first selecting an installation source at the top.</h3>';
h += '</div>';
}
else {
h += '<h3 data-english="Below is a list of installed resources which have updates available. Click on any row to update the resource.">';
h += 'Below is a list of installed resources which have updates available. Click on any row to update the resource.</h3></div>';
h += '</div>';
h += '<table class="clean" style="table-layout:fixed;width:100%;"><tbody>';
h += t;
h += '</tbody></table>';
}
h += '<br/>';
h += '<br/>';
h += '<br/>';
$('#client').html(h);
app.setAppLocale();
setTimeout(function() {
$('#client').scrollTop(0);
}, 200);
return;
}
SWORD.installMgr.getRemoteModInfoList(srcs[i], function(sourceMods) {
for (var l = 0; l < sourceMods.length; ++l) {
if (sourceMods[l].delta == '+') {
++count;
t += '<tr class="row'+((count%2)?'odd':'even')+'" onclick="installMgr.modSelected(this);return false;">';
t += '<td class="instDelta">'+sourceMods[l].delta+'</td>';
t += '<td class="instName">'+sourceMods[l].name+'</td>';
t += '<td class="instDesc">'+sourceMods[l].description+'</td>';
t += '<td style="display:none;" class="sourceName">'+srcs[i]+'</td>';
t += '</tr>';
}
}
sourcesLoop(srcs, ++i);
});
};
sourcesLoop(sources);
});
},
refreshSources: function(callback) {
......
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