/**
|
* this module provides common functions to work with a JSXGraph-Board.
|
* If a function in this module should manipulate a JSX-Board, the board should be the
|
* first parameter in funtion's argument list.
|
* */
|
|
import {download} from './dfhi-dom.js';
|
|
export function exportBoard(board, filename) {
|
console.log("exportBoard called");
|
if( !filename) {
|
filename = guestFilename();
|
}
|
let svgCode = new XMLSerializer().serializeToString(board.renderer.svgRoot);
|
console.log("svgCode ready");
|
download(filename, svgCode, "image/svg+xml");
|
}
|
|
function guestFilename() {
|
try {
|
let title = document.title || "export-jsxgraph";
|
if (title) {
|
title = title.replace(/\s+/g, '-');
|
}
|
return `${title}.svg`;
|
} catch (e) {
|
return "export-jsxgraph.svg";
|
}
|
}
|
|
export function toggleAxis(board) {
|
try {
|
const currentAxis = board.attr['axis'];
|
console.log(board);
|
board.attr['axis'] = ! currentAxis;
|
}catch(e) {
|
console.error(e);
|
}
|
}
|