Lines 155-174
$(document).ready(function() {
Link Here
|
155 |
$("#catalog-search-dropdown a").toggleClass("catalog-search-dropdown-hover"); |
155 |
$("#catalog-search-dropdown a").toggleClass("catalog-search-dropdown-hover"); |
156 |
}); |
156 |
}); |
157 |
|
157 |
|
158 |
if ( localStorage.getItem("lastborrowernumber") ){ |
158 |
console.log("HIDDEN BORROWER: " + $("#hiddenborrowernumber").val() ); |
159 |
if( $("#hiddenborrowernumber").val() != localStorage.getItem("lastborrowernumber") ) { |
159 |
if ( localStorage.getItem("previousPatrons") || $("#hiddenborrowernumber").val() ){ |
|
|
160 |
var previous_patrons = []; |
161 |
if ( localStorage.getItem("previousPatrons") ) { |
162 |
previous_patrons = JSON.parse(localStorage.getItem("previousPatrons")); |
163 |
} |
164 |
|
165 |
if ( $("#hiddenborrowernumber").val() ) { |
166 |
// Remove this patron from the list if they are already there |
167 |
previous_patrons = previous_patrons.filter(function (p) { |
168 |
return p["borrowernumber"] != $("#hiddenborrowernumber").val(); |
169 |
}); |
170 |
|
171 |
const previous_patron = { |
172 |
"borrowernumber": $("#hiddenborrowernumber").val(), |
173 |
"name": $("#hiddenborrowername").val(), |
174 |
"card": $("#hiddenborrowercard").val() |
175 |
}; |
176 |
|
177 |
previous_patrons.unshift( previous_patron ); |
178 |
// Limit to last 10 patrons |
179 |
if ( previous_patrons.length > 10 ) previous_patrons.pop(); |
180 |
localStorage.setItem("previousPatrons", JSON.stringify(previous_patrons)); |
181 |
} |
182 |
|
183 |
if ( previous_patrons.length ) { |
184 |
let p = previous_patrons[0]; |
160 |
$("#lastborrowerlink").show(); |
185 |
$("#lastborrowerlink").show(); |
161 |
$("#lastborrowerlink").prop("title", localStorage.getItem("lastborrowername") + " (" + localStorage.getItem("lastborrowercard") + ")"); |
186 |
$("#lastborrowerlink").prop("title", `${p["name"]} (${p["card"]})`); |
162 |
$("#lastborrowerlink").prop("href", "/cgi-bin/koha/circ/circulation.pl?borrowernumber=" + localStorage.getItem("lastborrowernumber")); |
187 |
$("#lastborrowerlink").prop("href", `/cgi-bin/koha/circ/circulation.pl?borrowernumber=${p["borrowernumber"]}`); |
163 |
$("#lastborrower-window").css("display", "inline-flex"); |
188 |
$("#lastborrower-window").css("display", "inline-flex"); |
164 |
} |
|
|
165 |
} |
166 |
|
189 |
|
167 |
if( !localStorage.getItem("lastborrowernumber") || ( $("#hiddenborrowernumber").val() != localStorage.getItem("lastborrowernumber") && localStorage.getItem("currentborrowernumber") != $("#hiddenborrowernumber").val())) { |
190 |
previous_patrons.reverse(); |
168 |
if( $("#hiddenborrowernumber").val() ){ |
191 |
for ( i in previous_patrons ) { |
169 |
localStorage.setItem("lastborrowernumber", $("#hiddenborrowernumber").val() ); |
192 |
p = previous_patrons[i]; |
170 |
localStorage.setItem("lastborrowername", $("#hiddenborrowername").val() ); |
193 |
const el = `<li><a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=${p["borrowernumber"]}">${p["name"]} (${p["card"]})</a></li>`; |
171 |
localStorage.setItem("lastborrowercard", $("#hiddenborrowercard").val() ); |
194 |
$("#lastBorrowerList").prepend(el); |
|
|
195 |
} |
172 |
} |
196 |
} |
173 |
} |
197 |
} |
174 |
|
198 |
|
Lines 216-225
$(document).ready(function() {
Link Here
|
216 |
}); |
240 |
}); |
217 |
|
241 |
|
218 |
function removeLastBorrower(){ |
242 |
function removeLastBorrower(){ |
219 |
localStorage.removeItem("lastborrowernumber"); |
243 |
localStorage.removeItem("previousPatrons"); |
220 |
localStorage.removeItem("lastborrowername"); |
|
|
221 |
localStorage.removeItem("lastborrowercard"); |
222 |
localStorage.removeItem("currentborrowernumber"); |
223 |
} |
244 |
} |
224 |
|
245 |
|
225 |
// http://jennifermadden.com/javascript/stringEnterKeyDetector.html |
246 |
// http://jennifermadden.com/javascript/stringEnterKeyDetector.html |
226 |
- |
|
|