Skip to content

Commit 4854d27

Browse files
authored
Merge pull request #10 from BibleGet-I-O/development
Version 50
2 parents ca5147a + b008941 commit 4854d27

File tree

3 files changed

+196
-84
lines changed

3 files changed

+196
-84
lines changed

Code.gs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @OnlyCurrentDoc
33
*/
44

5-
const VERSION = 49;
5+
const VERSION = 50;
66
const ADDONSTATE = {
77
PRODUCTION: "production",
88
DEVELOPMENT: "development"
@@ -68,8 +68,8 @@ const BGET = {
6868
VERSETEXT: 4
6969
},
7070
PREFERORIGIN: { //PREFER ORIGIN : most catholic editions of the Bible have texts based both on the Greek and on the Hebrew versions of the Bible
71-
GREEK: 1, // resulting in duplicate verses, which can be both be quoted with the same reference (e.g. Esther 1,1-10)
72-
HEBREW: 2 // Even though some Catholic editions place the Greek version in separate "books", for simplicity the BibleGet project places them as quotable verses following the CEI2008 layout. This preference allows the user to define which origin to prefer (if available) when making the quote
71+
HEBREW: 1, // resulting in duplicate verses, which can be both be quoted with the same reference (e.g. Esther 1,1-10)
72+
GREEK: 2 // Even though some Catholic editions place the Greek version in separate "books", for simplicity the BibleGet project places them as quotable verses following the CEI2008 layout. This preference allows the user to define which origin to prefer (if available) when making the quote
7373
},
7474
TYPECASTING: { //just for quality assurance and good measure, let's explicitly define typecasting of our UserProperties, don't just rely on JSON.parse
7575
//this way we know that floats will be floats and ints will be ints and we don't have to worry about it every time in our code when we use the values
@@ -583,9 +583,9 @@ function sendMail(txt) {
583583

584584
//Function fetchData @ used in SidebarJS and in other scripts here in Code.gs (which are called from SidebarJS), to communicate with the BibleGet endpoints
585585
function fetchData(request){
586-
let {query,version} = request;
586+
let {query,version,preferorigin} = request;
587587
let {rettype,appid} = REQUESTPARAMS;
588-
let payload = {'query':query,'version':version,'return':rettype,'appid':appid,'pluginversion':VERSION};
588+
let payload = {'query':query,'version':version,'return':rettype,'appid':appid,'pluginversion':VERSION,'preferorigin':preferorigin};
589589
try{
590590
var response = UrlFetchApp.fetch(ENDPOINTURL,{'method':'post','payload':payload});
591591
var responsecode = response.getResponseCode();

Settings.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,8 +860,8 @@ <h3><b><?!=__('Verse Text Format',locale)?></b></h3>
860860
//We can't save the userProps obj unless we have all the user Properties in this object, this is why we need the object,
861861
//and need it fully populated, not only available to populate one at a time
862862
var passUserPropertiesServer2Client = function(propsobj){
863-
userProps.populated = true;
864863
userProps = propsobj;
864+
userProps.populated = true;
865865
<? if(CURRENTSTATE==ADDONSTATE.DEVELOPMENT){ ?>
866866
for (let [key, value] of Object.entries(propsobj).sort() ) {
867867
if(typeof value === 'object'){

Sidebar.html

Lines changed: 190 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?
22
var propsService = PropertiesService.getUserProperties();
33
var recentSelectedVersionsProp = propsService.getProperty("RecentSelectedVersions");
4+
let LayoutPrefs = propsService.getProperty("LayoutPrefs");
5+
let PREFERORIGIN = JSON.parse(LayoutPrefs).PREFERORIGIN;
46
if(recentSelectedVersionsProp===null){
57
recentSelectedVersions = [];
68
}
@@ -49,44 +51,123 @@
4951
});
5052
?>
5153
<!DOCTYPE html>
54+
5255
<head>
53-
<base target="_blank">
54-
<meta charset="UTF-8">
55-
<?!= include("Stylesheet"); ?>
56-
<style>
57-
.downLdIco {
58-
background-image: url(<?!= include('DownloadIcon'); ?>);
59-
background-size: cover;
60-
width: 20px;
61-
height: 20px;
62-
position: relative;
63-
top: 4px;
64-
right: 3px;
65-
display: inline-block;
66-
}
67-
.searchIco {
68-
background-image: url(<?!= include('SearchIcon'); ?>);
69-
background-size: cover;
70-
width: 20px;
71-
height: 20px;
72-
position: relative;
73-
top: 4px;
74-
right: 3px;
75-
display: inline-block;
76-
}
77-
78-
#messageToUser {
79-
border: 1px solid Gray;
80-
background-color: pink;
81-
color: Gray;
82-
padding: 12px;
83-
}
84-
</style>
56+
<base target="_blank">
57+
<meta charset="UTF-8">
58+
<?!= include("Stylesheet"); ?>
59+
<style>
60+
.downLdIco {
61+
background-image: url(<?!= include('DownloadIcon');
62+
?>);
63+
background-size: cover;
64+
width: 20px;
65+
height: 20px;
66+
position: relative;
67+
top: 4px;
68+
right: 3px;
69+
display: inline-block;
70+
}
71+
72+
.searchIco {
73+
background-image: url(<?!= include('SearchIcon');
74+
?>);
75+
background-size: cover;
76+
width: 20px;
77+
height: 20px;
78+
position: relative;
79+
top: 4px;
80+
right: 3px;
81+
display: inline-block;
82+
}
83+
84+
#messageToUser {
85+
border: 1px solid Gray;
86+
background-color: pink;
87+
color: Gray;
88+
padding: 12px;
89+
}
90+
91+
/* The switch - the box around the slider */
92+
.switch {
93+
position: relative;
94+
display: inline-block;
95+
width: 60px;
96+
height: 34px;
97+
}
98+
99+
/* Hide default HTML checkbox */
100+
.switch input {
101+
opacity: 0;
102+
width: 0;
103+
height: 0;
104+
}
105+
106+
/* The slider */
107+
.slider {
108+
position: absolute;
109+
cursor: pointer;
110+
top: 0;
111+
left: 0;
112+
right: 0;
113+
bottom: 0;
114+
background-color: #2196F3;
115+
-webkit-transition: .4s;
116+
transition: .4s;
117+
}
118+
119+
.slider:before {
120+
position: absolute;
121+
content: "";
122+
height: 26px;
123+
width: 26px;
124+
left: 4px;
125+
bottom: 4px;
126+
background-color: white;
127+
-webkit-transition: .4s;
128+
transition: .4s;
129+
}
130+
131+
input:checked+.slider {
132+
background-color: #2196F3;
133+
}
134+
135+
input:focus+.slider {
136+
box-shadow: 0 0 1px #2196F3;
137+
}
138+
139+
input:checked+.slider:before {
140+
-webkit-transform: translateX(26px);
141+
-ms-transform: translateX(26px);
142+
transform: translateX(26px);
143+
}
144+
145+
/* Rounded sliders */
146+
.slider.round {
147+
border-radius: 34px;
148+
}
149+
150+
.slider.round:before {
151+
border-radius: 50%;
152+
}
153+
154+
.lbl-inline {
155+
max-width: 15%;
156+
}
157+
158+
.flex-center-even {
159+
display: flex;
160+
align-items: center;
161+
justify-content: space-evenly;
162+
}
163+
</style>
85164
</head>
165+
86166
<body>
87-
<div id="messageToUser"></div>
88-
<input id="idAccountOfEffectiveUsr" type="hidden" style="display:none" value="<?!= Session.getEffectiveUser().getEmail(); ?>"/>
89-
<script>
167+
<div id="messageToUser"></div>
168+
<input id="idAccountOfEffectiveUsr" type="hidden" style="display:none" value="<?!= Session.getEffectiveUser().getEmail(); ?>"/>
169+
<script>
170+
let LayoutPrefs = JSON.parse('<?!=LayoutPrefs?>');
90171
let failedAcctTest = function(rtrn) {
91172
$('.spinner').hide();
92173
let usrWhoLoaded = document.getElementById('idAccountOfEffectiveUsr').textContent;
@@ -102,14 +183,19 @@
102183
successAcctTest = function(rtrn) {
103184
$('#messageToUser').hide();
104185
};
105-
</script>
106-
<div class="spinner lds-ring" id="spinner-gif"><div></div><div></div><div></div><div></div></div>
107-
<div class="spinner" id="spinner-bg"></div>
108-
<div class="sidebar branding-below">
109-
<h3><?=__("Get bible quotes",locale)?></h3>
110-
<div class="block form-group">
111-
<label class="gapp-addon" for="text-version"><b><?=__("Versions available:",locale)?></b></label>
112-
<select class="gapp-addon" id="text-version" multiple>
186+
</script>
187+
<div class="spinner lds-ring" id="spinner-gif">
188+
<div></div>
189+
<div></div>
190+
<div></div>
191+
<div></div>
192+
</div>
193+
<div class="spinner" id="spinner-bg"></div>
194+
<div class="sidebar branding-below">
195+
<h3><?=__("Get bible quotes",locale)?></h3>
196+
<div class="block form-group">
197+
<label class="gapp-addon" for="text-version"><b><?=__("Versions available:",locale)?></b></label>
198+
<select class="gapp-addon" id="text-version" multiple>
113199
<? for(var q in langs){ ?>
114200
<optgroup label="-<?=langs[q]?>-">
115201
<?for(var s in versionsbylang[langs[q]]){?>
@@ -118,56 +204,77 @@ <h3><?=__("Get bible quotes",locale)?></h3>
118204
</optgroup>
119205
<?}?>
120206
</select>
121-
<div><?=__("Versions selected:",locale)?> <span id="selectedversions" <?if(recentSelectedVersions.length<1){?>class="empty">none<?}else{?>><?=recentSelectedVersions.join(',')?><?}?></span></div>
122-
</div>
123-
<div class="block form-group" style="margin-top:20px;">
124-
<label class="gapp-addon"><b><?=__('Insert citation',locale)?></b></label>
125-
<div class="inline form-group">
126-
<input class="gapp-addon" id="bibleget-search" type="search" placeholder="<?=__("e.g. Matthew 1:1-10,13-15",locale)?>" />
127-
<button id="btn-get-bible-quote" class="action gapp-addon"><span class="downLdIco">&nbsp;</span><?=__("Get verses",locale)?></button>
128-
</div>
129-
</div>
130-
<div class="block form-group" style="margin-top:10px;">
131-
<label class="gapp-addon"><b><?=__('Find verses by keyword',locale)?></b></label>
132-
<div class="inline form-group">
133-
<input class="gapp-addon" id="bibleget-fulltextsearch" type="search" placeholder="<?=__("e.g. Creation",locale)?>" />
134-
<button id="btn-bible-search" class="action gapp-addon"><span class="searchIco">&nbsp;</span><?=__("Search",locale)?></button>
135-
</div>
136-
</div>
137-
<div class="block form-group" style="margin-top:10px;">
138-
<div class="inline form-group" title="<?=__('By default, search will include partial matches of 3 letters or more. If you prefer to include only exact matches of 2 letters or more, select this option.',locale)?>">
139-
<input class="gapp-addon" id="bibleget-exactmatch" type="checkbox" />
140-
<label class="gapp-addon"><?=__('Exact matches only',locale)?></label>
141-
</div>
142-
</div>
143-
</div>
207+
<div><?=__("Versions selected:",locale)?>
208+
<span id="selectedversions" <?if(recentSelectedVersions.length<1){?>class="empty">none<?}else{?>><?=recentSelectedVersions.join(',')?><?}?></span>
209+
</div>
210+
</div>
211+
<div class="block form-group" style="margin-top:20px;">
212+
<label class="gapp-addon"><b><?=__('Insert citation',locale)?></b></label>
213+
<div class="inline form-group">
214+
<input class="gapp-addon" id="bibleget-search" type="search" placeholder="<?=__("e.g. Matthew 1:1-10,13-15",locale)?>" />
215+
<button id="btn-get-bible-quote" class="action gapp-addon"><span class="downLdIco">&nbsp;</span><?=__("Get verses",locale)?></button>
216+
</div>
217+
</div>
218+
<div class="block form-group" style="margin-top:10px;">
219+
<div class="flex-center-even form-group"
220+
title="<?=__('Some books of the Bible, in Catholic versions, have two different versions of some chapters, one based on the Tanakh (Hebrew) and one based on the Septuagint (Greek). This switch will allow to choose between the two possible texts.',locale)?>">
221+
<label class="gapp-addon lbl-inline"><?=__('Prefer Hebrew origin',locale)?></label>
222+
<label class="switch">
223+
<input class="gapp-addon" id="bibleget-preferorigin" type="checkbox" <?if(PREFERORIGIN == BGET.PREFERORIGIN.GREEK){?>checked<?}?> />
224+
<span class="slider round"></span>
225+
</label>
226+
<label class="gapp-addon lbl-inline"><?=__('Prefer Greek origin',locale)?></label>
227+
</div>
228+
</div>
229+
<div class="block form-group" style="margin-top:10px;">
230+
<label class="gapp-addon"><b><?=__('Find verses by keyword',locale)?></b></label>
231+
<div class="inline form-group">
232+
<input class="gapp-addon" id="bibleget-fulltextsearch" type="search" placeholder="<?=__("e.g. Creation",locale)?>" />
233+
<button id="btn-bible-search" class="action gapp-addon"><span class="searchIco">&nbsp;</span><?=__("Search",locale)?></button>
234+
</div>
235+
</div>
236+
<div class="block form-group" style="margin-top:10px;">
237+
<div class="inline form-group"
238+
title="<?=__('By default, search will include partial matches of 3 letters or more. If you prefer to include only exact matches of 2 letters or more, select this option.',locale)?>">
239+
<input class="gapp-addon" id="bibleget-exactmatch" type="checkbox" />
240+
<label class="gapp-addon"><?=__('Exact matches only',locale)?></label>
241+
</div>
242+
</div>
243+
</div>
144244

145-
<div class="sidebar bottom">
146-
<? let usrProperties = propsService.getProperties();
245+
<div class="sidebar bottom">
246+
<? let usrProperties = propsService.getProperties();
147247
if(usrProperties.hasOwnProperty('RientroSinistro') || usrProperties.hasOwnProperty('BookChapterAlignment') || usrProperties.hasOwnProperty('VerseNumberAlignment') || usrProperties.hasOwnProperty('VerseTextAlignment') || usrProperties.hasOwnProperty('Interlinea') ){ ?>
148-
<div style="text-align:center;margin-top:16px;"><button title="This will remove all of your current user preferences and reset them to default. Resort to this if you cannot open the settings / preferences window." class="button" id="RESET_DEFAULT_USERPROPS"><?=__('RESET PREFERENCES TO DEFAULT OPTIONS',locale)?></button></div>
149-
<? } ?>
150-
<div style="background:linear-gradient(white,gray,lightblue,black);color:White;font-weight:bold;text-shadow:3px 3px 3px Black;padding:1px;vertical-align:middle;"><a target="_blank" href="https://www.bibleget.io"><?!= include("BibleIcon_32"); ?></a><span style="position:relative;top:-9px;">BibleGet I/O for Google Docs v.<?!=VERSION?></span></div>
151-
</div>
248+
<div style="text-align:center;margin-top:16px;">
249+
<button title="This will remove all of your current user preferences and reset them to default. Resort to this if you cannot open the settings / preferences window." class="button" id="RESET_DEFAULT_USERPROPS"><?=__('RESET PREFERENCES TO DEFAULT OPTIONS',locale)?></button>
250+
</div>
251+
<? } ?>
252+
<div
253+
style="background:linear-gradient(white,gray,lightblue,black);color:White;font-weight:bold;text-shadow:3px 3px 3px Black;padding:1px;vertical-align:middle;">
254+
<a target="_blank" href="https://www.bibleget.io">
255+
<?!= include("BibleIcon_32"); ?></a><span style="position:relative;top:-9px;">BibleGet I/O for Google Docs v.<?!=VERSION?></span>
256+
</div>
257+
</div>
152258

153-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
154-
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js"></script>
259+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
260+
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js"></script>
155261

156-
<script>
262+
<script>
157263
var queryServer = function(goodqueries){
158264
goodqueries = goodqueries || [];
159265
if(goodqueries.length===0){
160266
$('.spinner').hide();
161267
return false;
162268
}else{
163269
let finalquery = goodqueries.join(';');
270+
let preferorigin = $('#bibleget-preferorigin').prop('checked') ? 'GREEK' : 'HEBREW';
164271
if(finalquery != ''){
165272
let versions = $("select#text-version :selected").map(function(){ return this.value; }).get().join(',');
166273
if(versions.length<1){
167274
alertMe('<?!=__("Please select a version.",locale)?>');
168275
return false;
169276
}else{
170-
let payload = {'query':finalquery,'version':versions};
277+
let payload = {'query':finalquery,'version':versions,'preferorigin':preferorigin};
171278
google.script.run.withSuccessHandler(parseResponse).fetchData(payload);
172279
}
173280
}
@@ -276,7 +383,7 @@ <h3><?=__("Get bible quotes",locale)?></h3>
276383
return false;
277384
}
278385
let query = $('#bibleget-search').val();
279-
let queries = queryClean(query);
386+
let queries = queryClean(query);
280387
google.script.run.withSuccessHandler(queryServer).processQueries(queries,versions);
281388
});
282389

@@ -300,13 +407,18 @@ <h3><?=__("Get bible quotes",locale)?></h3>
300407
}
301408
}
302409
});
410+
411+
$('#bibleget-preferorigin').on('click',function(){
412+
LayoutPrefs.PREFERORIGIN = (this.checked ? <?!=BGET.PREFERORIGIN.GREEK?> : <?!=BGET.PREFERORIGIN.HEBREW?>);
413+
google.script.run.setUserProperty("LayoutPrefs",JSON.stringify(LayoutPrefs));
414+
});
303415

304416
$('#RESET_DEFAULT_USERPROPS').on('click',function(){
305417
//$('.spinner').show();
306418
google.script.run.resetUserProperties();
307419
});
308420

309421
});
310-
</script>
422+
</script>
311423

312424
</body>

0 commit comments

Comments
 (0)