This commit is contained in:
Peter Cottle 2024-11-18 18:35:10 -05:00
parent 928577b2dc
commit 34fc762cc0
3 changed files with 53 additions and 1 deletions

View file

@ -187,6 +187,9 @@ AppConstants.StoreSubscribePrototype,
isLevelSolved: function(levelID) {
var levelData = _solvedMap[levelID];
if (levelData === true) {
return true;
}
return levelData ? levelData.solved === true : false;
},

View file

@ -59,4 +59,54 @@ $(document).ready(function() {
window.debug_copyTree = function() {
return toGlobalize.Main.getSandbox().mainVis.gitEngine.printAndCopyTree();
};
window.debug_downloadImageOfDemonstrationView = function() {
const svgElement = document.querySelectorAll('svg[style*="z-index: 300"]')[0];
const svgBlob = new Blob([svgElement.outerHTML], { type: 'image/svg+xml' });
// Create a URL object
const url = URL.createObjectURL(svgBlob);
// Create an anchor element to download the image
const a = document.createElement('a');
a.href = url;
a.download = 'image.svg';
a.click();
// svgElement.setAttribute("xmlns", "http://www.w3.org/2000/svg");
// console.log('the SVG element', svgElement);
// const serializer = new XMLSerializer();
// const svgString = serializer.serializeToString(svgElement);
// console.log('the SVG string', svgString);
// const svgDataUrl = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svgString)}`;
// console.log('the SVG data', svgDataUrl);
// const canvas = document.createElement("canvas");
// const context = canvas.getContext("2d");
// // Set canvas size to match the SVG's dimensions
// canvas.width = svgElement.width.baseVal.value;
// canvas.height = svgElement.height.baseVal.value;
// // Create an image and load the SVG Data URL
// const image = new Image();
// image.onload = () => {
// context.drawImage(image, 0, 0);
// setTimeout(() => {
// // Export the canvas to an image
// const pngDataUrl = canvas.toDataURL("image/png");
// console.log('the PNG data', pngDataUrl); // Logs the base64 PNG image URL
// // (Optional) Create a downloadable link
// const downloadLink = document.createElement("a");
// downloadLink.href = pngDataUrl;
// downloadLink.download = "exported-image.png";
// downloadLink.click();
// }, 1000);
// };
// image.src = svgDataUrl;
};
});

View file

@ -10,7 +10,6 @@ var MyError = Backbone.Model.extend({
getMsg: function() {
if (!this.get('msg')) {
debugger;
console.warn('my error without message');
}
return this.get('msg');