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

53 lines
1.9 KiB
JavaScript
Raw Normal View History

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