Added workarounds for Apple's iOS browser

master
Gordon Williams 2020-05-23 13:28:06 +01:00
parent 793b5d6361
commit 6b09377414
2 changed files with 10 additions and 5 deletions

View File

@ -1,5 +1,9 @@
if (typeof btoa==="undefined")
function btoa(d) { return Buffer.from(d).toString('base64'); }
if (typeof btoa==="undefined") {
// Don't define btoa as a function here because Apple's
// iOS browser defines the function even though it's in
// an IF statement that is never executed!
btoa = function(d) { return BufferA.from(d).toString('base64'); }
}
// Converts a string into most efficient way to send to Espruino (either json, base64, or compressed base64)
function toJS(txt) {

View File

@ -196,7 +196,8 @@ function showTab(tabname) {
// =========================================== Library
var chips = Array.from(document.querySelectorAll('.filter-nav .chip')).map(chip => chip.attributes.filterid.value);
// Can't use chip.attributes.filterid.value here because Safari/Apple's WebView doesn't handle it
var chips = Array.from(document.querySelectorAll('.filter-nav .chip')).map(chip => chip.getAttribute("filterid"));
var hash = window.location.hash ? window.location.hash.slice(1) : '';
var activeFilter = !!~chips.indexOf(hash) ? hash : '';