asset saving patch

many thanks @yueyuzhao
This commit is contained in:
Chris Garrity 2020-09-02 13:31:09 -04:00
parent eb37208424
commit 45b06ee8a6
3 changed files with 8 additions and 22 deletions

View file

@ -147,14 +147,10 @@ export default class Page {
function doNext (str) {
str = str.replace(/>\s*</g, '><');
me.setSVG(str);
if ((str.indexOf('xlink:href') < 0) && OS.path) {
me.setBackgroundImage(url, fcn); // does not have embedded images
} else {
IO.getImagesInSVG(str, function () {
var base64 = IO.getImageDataURL(me.md5, btoa(str));
IO.getImagesInSVG(str, function () {
me.setBackgroundImage(base64, fcn);
});
}
me.setBackgroundImage(base64, fcn);
});
}
}

View file

@ -77,9 +77,6 @@ export default class Sprite {
getAsset (whenDone) {
var md5 = this.md5;
var spr = this;
var url = (MediaLib.keys[md5]) ?
MediaLib.path + md5 :
(md5.indexOf('/') < 0) ? OS.path + md5 : md5;
md5 = (MediaLib.keys[md5]) ? MediaLib.path + md5 : md5;
if (md5.indexOf('/') > -1) {
IO.requestFromServer(md5, doNext);
@ -92,14 +89,10 @@ export default class Sprite {
function doNext (str) {
str = str.replace(/>\s*</g, '><');
spr.setSVG(str);
if ((str.indexOf('xlink:href') < 0) && OS.path) {
whenDone(url); // does not have embedded images
} else {
IO.getImagesInSVG(str, function () {
var base64 = IO.getImageDataURL(spr.md5, btoa(str));
IO.getImagesInSVG(str, function () {
whenDone(base64);
});
}
whenDone(base64);
});
}
}

View file

@ -90,11 +90,8 @@ export default class IO {
IO.requestFromServer(md5, gotit); // get url contents
return;
}
if ((IO.getExtension(md5) == 'png') && OS.path) {
fcn(OS.path + md5); // only if it is not in debug mode
} else {
OS.getmedia(md5, nextStep);
} // get url contents
OS.getmedia(md5, nextStep);
function gotit (str) {
var base64 = IO.getImageDataURL(md5, btoa(str));