1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-09-03 05:12:43 +02:00

t-value control

This commit is contained in:
Pomax
2018-06-23 23:22:58 -07:00
parent 1da8c3966b
commit 3d334c2559
13 changed files with 4301 additions and 1907 deletions

View File

@@ -105,6 +105,8 @@ function processLocation(loc, section, number) {
*/
function formContentBundle(locale, content) {
var bcode = JSON.stringify(content, false, 2);
// general replacements to make content actually usable javascript:
bcode = bcode.replace(/"<section([^>]*)>/g, "function(handler) { return <section$1>")
.replace(/this\.(\w)/g, "handler.$1")
.replace(/<\/section>"(,?)/g, "</section>; }$1\n")
@@ -113,19 +115,28 @@ function formContentBundle(locale, content) {
.replace(/></g,'>\n<')
.replace(/\\\\/g, '\\');
// all the components we want sections to be able to make use of:
var components = [
"Graphic",
"SectionHeader",
"BSplineGraphic",
"KnotController",
"WeightController",
"SliderSet"
];
// and finally, our bundle "code":
var bundle = [
`var React = require('react');`,
`var Graphic = require("../../components/Graphic.jsx");`,
`var SectionHeader = require("../../components/SectionHeader.jsx");`,
`var BSplineGraphic = require("../../components/BSplineGraphic.jsx");`,
`var KnotController = require("../../components/KnotController.jsx");`,
`var WeightController = require("../../components/WeightController.jsx");`,
`var React = require('react');`
].concat(
components.map(v => `var ${v} = require("../../components/${v}.jsx");`)
).concat([
``,
`SectionHeader.locale="${locale}";`,
``,
`module.exports = ${bcode};`,
``
].join('\n');
]).join('\n');
return bundle;
}