p5.js-web-editor/static/interceptor/textInterceptor/intercept-p5.js

55 lines
2.1 KiB
JavaScript
Raw Normal View History

2016-08-12 04:11:31 +00:00
var canvasLocation ='';
2016-08-15 22:06:09 +00:00
funcNames = allData["classitems"].map(function(x){
if(x["overloads"]) {
tempParam = x["overloads"][0]["params"];
} else {
tempParam = x["params"];
}
return {
2016-08-12 04:11:31 +00:00
name: x["name"],
2016-08-15 22:06:09 +00:00
params: tempParam,
2016-08-12 04:11:31 +00:00
class: x["class"],
module: x["module"],
submodule: x["submodule"]
};
});
2016-08-12 04:11:31 +00:00
funcNames = funcNames.filter(function(x) {
2016-08-12 18:19:23 +00:00
var className = x["class"];
2016-08-12 04:11:31 +00:00
return (x["name"] && x["params"] && (className==='p5'));
})
2016-08-12 04:11:31 +00:00
funcNames.forEach(function(x){
2016-08-15 22:06:09 +00:00
var document = parent.document;
2016-08-12 04:11:31 +00:00
var originalFunc = p5.prototype[x.name];
p5.prototype[x.name] = function(){
orgArg = arguments;
if(frameCount == 0) { //for setup
document.getElementById('textOutput-content-table').innerHTML = '';
document.getElementById('textOutput-content-details').innerHTML = '';
document.getElementById('textOutput-content-summary').innerHTML = '';
Interceptor.setupObject = Interceptor.populateObject(x,arguments, Interceptor.setupObject, document.getElementById('textOutput-content-table'),false);
2016-08-15 16:12:25 +00:00
Interceptor.getSummary(Interceptor.setupObject,Interceptor.drawObject,document.getElementById('textOutput-content-summary'));
var table = document.getElementById('textOutput-content-table');
2016-08-16 00:28:18 +00:00
Interceptor.populateTable(table,Interceptor.setupObject.objectArray);
2016-08-12 04:11:31 +00:00
}
else if(frameCount%100 == 0 ) {
2016-08-15 16:12:25 +00:00
Interceptor.drawObject = Interceptor.populateObject(x,arguments, Interceptor.drawObject, document.getElementById('textOutput-content-details'),true);
2016-08-12 04:11:31 +00:00
Interceptor.isCleared = false;
}
//reset some of the variables
else if(frameCount%100 == 1 ) {
if(!Interceptor.isCleared){
var table = document.getElementById('textOutput-content-table');
2016-08-16 00:28:18 +00:00
Interceptor.getSummary(Interceptor.setupObject,Interceptor.drawObject,document.getElementById('textOutput-content-summary'));
Interceptor.populateTable(table,Interceptor.setupObject.objectArray.concat(Interceptor.drawObject.objectArray));
2016-08-12 04:11:31 +00:00
}
Interceptor.drawObject = Interceptor.clearVariables(Interceptor.drawObject);
}
return originalFunc.apply(this,arguments);
}
});