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

61 lines
2.4 KiB
JavaScript
Raw Normal View History

2016-08-12 06:11:31 +02:00
var canvasLocation ='';
var shadowDOMElement;
2016-08-12 06:11:31 +02:00
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"];
}
return {
2016-08-12 06:11:31 +02:00
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"]
};
});
2016-08-12 06:11:31 +02:00
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'));
})
2016-08-12 06:11:31 +02:00
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;
if(frameCount == 0) { //for setup
document.getElementById('textOutput-content-table').innerHTML = '';
document.getElementById('textOutput-content-details').innerHTML = '';
document.getElementById('textOutput-content-summary').innerHTML = '';
Interceptor.createShadowDOMElement(document);
2016-08-15 18:12:25 +02:00
Interceptor.setupObject = Interceptor.populateObject(x,arguments, Interceptor.setupObject, document.getElementById('textOutput-content-details'),false);
Interceptor.populateObjectDetails(Interceptor.setupObject,Interceptor.drawObject,document.getElementById('textOutput-content-summary'),document.getElementById('textOutput-content-details'));
2016-08-15 18:12:25 +02:00
var table = document.getElementById('textOutput-content-details');
Interceptor.populateTable(table,Interceptor.setupObject);
2016-08-12 06:11:31 +02:00
}
else if(frameCount%50 == 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%50 == 1 ) {
2016-08-12 06:11:31 +02:00
if(!Interceptor.isCleared){
var cells = document.getElementsByClassName('textOutput-cell-content');
for( i =0;i<cells.length;i++) {
cells[i].innerHTML = '';
}
Interceptor.populateObjectDetails(Interceptor.setupObject,Interceptor.drawObject,document.getElementById('textOutput-content-summary'),document.getElementById('textOutput-content-details'));
Interceptor.populateTable(Interceptor.setupObject.objectArray.concat(Interceptor.drawObject.objectArray),document);
2016-08-12 06:11:31 +02:00
}
Interceptor.drawObject = Interceptor.clearVariables(Interceptor.drawObject);
}
return originalFunc.apply(this,arguments);
}
});