Fix for multibyte ascii
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
5d5c9d9f37
commit
245fab0623
@ -19,6 +19,35 @@ Date.prototype.toJSONLocal = (function() {
|
||||
};
|
||||
}())
|
||||
|
||||
function toEncoded(string) {
|
||||
const codeUnits = Uint16Array.from(
|
||||
{ length: string.length },
|
||||
(element, index) => string.charCodeAt(index)
|
||||
);
|
||||
const charCodes = new Uint8Array(codeUnits.buffer);
|
||||
|
||||
let result = "";
|
||||
charCodes.forEach((char) => {
|
||||
result += String.fromCharCode(char);
|
||||
});
|
||||
return window.btoa(result);
|
||||
}
|
||||
|
||||
function toDecoded(string) {
|
||||
let binary = window.atob(string)
|
||||
const bytes = Uint8Array.from({ length: binary.length }, (element, index) =>
|
||||
binary.charCodeAt(index)
|
||||
);
|
||||
const charCodes = new Uint16Array(bytes.buffer);
|
||||
|
||||
let result = "";
|
||||
charCodes.forEach((char) => {
|
||||
result += String.fromCharCode(char);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
const query_nominatim = (q,f) => axios.get('/api/place/'+q).then(res=>res.data).then(res=>res.filter(f))
|
||||
const query_flight = (q) => axios.get('/api/flight/'+q).then(res=>res.data)
|
||||
|
||||
@ -99,7 +128,7 @@ const app = new Vue({
|
||||
},
|
||||
add_section: function(event){
|
||||
if(this.journey_data.main==undefined) this.journey_data.main=[];
|
||||
this.journey_data.main.push({map:{zoom:2}, hotel:{latlon:[0,0]},places:{restaurants:[],places:[]}});
|
||||
this.journey_data.main.push({step_title:"?",map:{zoom:2}, hotel:{latlon:[0,0]},places:{restaurants:[],places:[]}});
|
||||
},
|
||||
next_step: function(){
|
||||
this.journey_step+=1;
|
||||
@ -237,10 +266,10 @@ const app = new Vue({
|
||||
})
|
||||
},
|
||||
import_data:function(){
|
||||
this.journey_data = Object.assign({}, JSON.parse(window.atob(this.impexp)));
|
||||
this.journey_data = Object.assign({}, JSON.parse(toDecoded(this.impexp)));
|
||||
},
|
||||
export_data:function(){
|
||||
this.impexp = window.btoa(JSON.stringify(this.journey_data));
|
||||
this.impexp = toEncoded(JSON.stringify(this.journey_data));
|
||||
},
|
||||
filter_selected:function(list,step){
|
||||
return list.filter(e=>(step?(e.step==this.journey_step):(e.step>=0)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user