read data from json file
This commit is contained in:
parent
87de5a2188
commit
9c03efcef2
7 changed files with 57 additions and 18799 deletions
|
@ -89,8 +89,6 @@ class Editor extends React.Component {
|
|||
this._cm.setOption('mode', 'htmlmixed');
|
||||
}
|
||||
}
|
||||
|
||||
console.log('componentDidUpdate in editor');
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
|
|
@ -128,12 +128,11 @@ class PreviewFrame extends React.Component {
|
|||
});
|
||||
|
||||
if (this.props.textOutput || this.props.isTextOutputPlaying) {
|
||||
console.log(htmlFile);
|
||||
const htmlHead = htmlFile.match(/(?:<head.*?>)([\s\S]*?)(?:<\/head>)/gmi);
|
||||
const headRegex = new RegExp('head', 'i');
|
||||
let htmlHeadContents = htmlHead[0].split(headRegex)[1];
|
||||
htmlHeadContents = htmlHeadContents.slice(1, htmlHeadContents.length - 2);
|
||||
htmlHeadContents += '<script src="/data.js"></script>\n';
|
||||
htmlHeadContents += '<script src="/loadData.js"></script>\n';
|
||||
htmlHeadContents += '<script src="/interceptor-functions.js"></script>\n';
|
||||
htmlHeadContents += '<script src="/intercept-p5.js"></script>\n';
|
||||
htmlHeadContents += '<script type="text/javascript" src="http://chir.ag/projects/ntc/ntc.js"></script>';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import React, { PropTypes } from 'react';
|
||||
import React from 'react';
|
||||
|
||||
class TextOutput extends React.Component {
|
||||
componentDidMount() {
|
||||
|
@ -6,23 +6,39 @@ class TextOutput extends React.Component {
|
|||
}
|
||||
render() {
|
||||
return (
|
||||
<div className="textoutput" id="canvas-sub" tabIndex="0" role="region">
|
||||
<section
|
||||
className="textoutput"
|
||||
id="canvas-sub"
|
||||
tabIndex="0"
|
||||
role="main"
|
||||
aria-label="text-output"
|
||||
title="canvas text output"
|
||||
>
|
||||
<section id="textOutput-content">
|
||||
</section>
|
||||
<div tabIndex="0" role="region" id="textOutput-content-summary">
|
||||
</div>
|
||||
<div tabIndex="0" role="region" id="textOutput-content-details">
|
||||
</div>
|
||||
<table id="textOutput-content-table">
|
||||
<p
|
||||
tabIndex="0"
|
||||
role="main"
|
||||
id="textOutput-content-summary"
|
||||
aria-label="text output summary"
|
||||
>
|
||||
</p>
|
||||
<p
|
||||
tabIndex="0"
|
||||
role="main"
|
||||
id="textOutput-content-details"
|
||||
aria-label="text output summary details"
|
||||
>
|
||||
</p>
|
||||
<table
|
||||
id="textOutput-content-table"
|
||||
summary="text output object details"
|
||||
title="output details"
|
||||
>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// TextOutput.propTypes = {
|
||||
// lintMessages: PropTypes.array.isRequired,
|
||||
// lineNo: PropTypes.string.isRequired,
|
||||
// };
|
||||
|
||||
export default TextOutput;
|
||||
|
|
|
@ -204,6 +204,7 @@ class IDEView extends React.Component {
|
|||
<div>
|
||||
<div className="preview-frame-overlay" ref="overlay">
|
||||
</div>
|
||||
<div>
|
||||
{(() => {
|
||||
if (this.props.preferences.textOutput || this.props.ide.isTextOutputPlaying) {
|
||||
return (
|
||||
|
@ -212,6 +213,7 @@ class IDEView extends React.Component {
|
|||
}
|
||||
return '';
|
||||
})()}
|
||||
</div>
|
||||
<PreviewFrame
|
||||
htmlFile={this.props.htmlFile}
|
||||
jsFiles={this.props.jsFiles}
|
||||
|
|
18777
static/data.js
18777
static/data.js
File diff suppressed because it is too large
Load diff
|
@ -1,24 +1,27 @@
|
|||
var textOutputElement;
|
||||
var canvasLocation ='';
|
||||
|
||||
funcNames = refData["classitems"].map(function(x){
|
||||
funcNames = allData["classitems"].map(function(x){
|
||||
if(x["overloads"]) {
|
||||
tempParam = x["overloads"][0]["params"];
|
||||
} else {
|
||||
tempParam = x["params"];
|
||||
}
|
||||
return {
|
||||
name: x["name"],
|
||||
params: x["params"],
|
||||
params: tempParam,
|
||||
class: x["class"],
|
||||
module: x["module"],
|
||||
submodule: x["submodule"]
|
||||
};
|
||||
});
|
||||
|
||||
funcNames = funcNames.filter(function(x) {
|
||||
var className = x["class"];
|
||||
return (x["name"] && x["params"] && (className==='p5'));
|
||||
})
|
||||
|
||||
|
||||
funcNames.forEach(function(x){
|
||||
let document = parent.document;
|
||||
var document = parent.document;
|
||||
var originalFunc = p5.prototype[x.name];
|
||||
p5.prototype[x.name] = function(){
|
||||
orgArg = arguments;
|
||||
|
|
17
static/loadData.js
Normal file
17
static/loadData.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
var allData;
|
||||
function fetchJSONFile(path, callback) {
|
||||
var httpRequest = new XMLHttpRequest();
|
||||
httpRequest.onreadystatechange = function() {
|
||||
if (httpRequest.readyState === 4) {
|
||||
if (httpRequest.status === 200) {
|
||||
var data = JSON.parse(httpRequest.responseText);
|
||||
if (callback) callback(data);
|
||||
}
|
||||
}
|
||||
};
|
||||
httpRequest.open('GET', path,false);
|
||||
httpRequest.send();
|
||||
}
|
||||
fetchJSONFile('https://rawgit.com/processing/p5.js-website/master/reference/data.json', function(data){
|
||||
allData = data;
|
||||
});
|
Loading…
Reference in a new issue