/* -------------------------- */ /* consolplugin */ /* -------------------------- */ var consolplugin = function consolplugin() { var consoleinput = null consoleinput = d3.select("#controls") .append("div") .attr("class", "consols") .selectAll(".consol") .data([consoleText]) .enter().append("input") .attr('type', "text") .attr('id', 'consol') .attr("class", "consol") .attr('style', 'width: 590px;') .style("font", "20px sans-serif") // _e_ .style("fill-opacity", 1) .on("change", changedconsol) var replacer = function (key,value) { if (typeof(value) === 'object') return value else return Math.floor(value * 100) / 100 } var consoleText = (__map.state().config.consol && __map.state().config.consol.text) ? __map.state().config.consol.text : '{}' function changedconsol() { let anima = JSON.parse(this.value) __map.state().xsf.clear() __map.state().animation.run(anima) } var consolplugin = function consolplugin() { } consolplugin.start = function start() { // consoleinput = d3.select("#controls") // .append("div") // .attr("class", "consols") // .selectAll(".consol") // .data([consoleText]) // .enter().append("input") // .attr('type', "text") // .attr('id', 'consol') // .attr("class", "consol") // .attr('style', 'width: 590px;') // .style("font", "20px sans-serif") // _e_ // .style("fill-opacity", 1) // .on("change", changedconsol) } consolplugin.redraw = function(params) { // redraw is based on superform var p = Object.assign({}, params) consoleinput.property('value', d => JSON.stringify(p, replacer)) // consol } consolplugin.clear = function() { var p = Object.assign({}) if (!consolElemsEnter.empty()) { consolElemsEnter.property('value', d => JSON.stringify(p, initialstate.consol.replacer)) // consol } } return consolplugin }