diff --git a/client/modules/IDE/components/PreviewFrame.jsx b/client/modules/IDE/components/PreviewFrame.jsx
index 74a9b10c..a858925d 100644
--- a/client/modules/IDE/components/PreviewFrame.jsx
+++ b/client/modules/IDE/components/PreviewFrame.jsx
@@ -142,6 +142,17 @@ class PreviewFrame extends React.Component {
return;
}
+ // if user switches textoutput preferences
+ if (this.props.isTextOutputPlaying !== prevProps.isTextOutputPlaying) {
+ this.renderSketch();
+ return;
+ }
+
+ if (this.props.textOutput !== prevProps.textOutput) {
+ this.renderSketch();
+ return;
+ }
+
if (this.props.fullView && this.props.files[0].id !== prevProps.files[0].id) {
this.renderSketch();
return;
@@ -240,6 +251,7 @@ class PreviewFrame extends React.Component {
if (this.props.textOutput || this.props.isTextOutputPlaying) {
htmlHeadContents += '\n';
+ htmlHeadContents += '\n';
htmlHeadContents += '\n';
htmlHeadContents += '\n';
htmlHeadContents += '';
diff --git a/static/intercept-helper-functions.js b/static/intercept-helper-functions.js
new file mode 100644
index 00000000..c4be34c1
--- /dev/null
+++ b/static/intercept-helper-functions.js
@@ -0,0 +1,47 @@
+String.prototype.paddingLeft = function (paddingValue) {
+ return String(paddingValue + this).slice(-paddingValue.length);
+};
+
+function MergeObjRecursive(obj1, obj2) {
+ var obj3 = {};
+ for(p in obj1) {
+ obj3[p] = obj1[p];
+ }
+ for(p in obj2) {
+ if(Object.keys(obj3).indexOf(p)<0){
+ obj3[p] = obj2[p];
+ }
+ else {
+ obj3[p] = obj3[p] + obj2[p];
+ }
+ }
+ return obj3;
+}
+
+if(Array.prototype.equals)
+// attach the .equals method to Array's prototype to call it on any array
+Array.prototype.equals = function (array) {
+ // if the other array is a falsy value, return
+ if (!array)
+ return false;
+
+ // compare lengths - can save a lot of time
+ if (this.length != array.length)
+ return false;
+
+ for (var i = 0, l=this.length; i < l; i++) {
+ // Check if we have nested arrays
+ if (this[i] instanceof Array && array[i] instanceof Array) {
+ // recurse into the nested arrays
+ if (!this[i].equals(array[i]))
+ return false;
+ }
+ else if (this[i] != array[i]) {
+ // Warning - two different object instances will never be equal: {x:20} != {x:20}
+ return false;
+ }
+ }
+ return true;
+}
+// Hide method from for-in loops
+Object.defineProperty(Array.prototype, "equals", {enumerable: false});
diff --git a/static/intercept-p5.js b/static/intercept-p5.js
index 2275eba2..81009c05 100644
--- a/static/intercept-p5.js
+++ b/static/intercept-p5.js
@@ -7,7 +7,7 @@ funcNames = allData["classitems"].map(function(x){
} else {
tempParam = x["params"];
}
- return {
+ return {
name: x["name"],
params: tempParam,
class: x["class"],
@@ -15,22 +15,23 @@ funcNames = allData["classitems"].map(function(x){
submodule: x["submodule"]
};
});
+
funcNames = funcNames.filter(function(x) {
var className = x["class"];
return (x["name"] && x["params"] && (className==='p5'));
})
+
funcNames.forEach(function(x){
var document = parent.document;
var originalFunc = p5.prototype[x.name];
p5.prototype[x.name] = function(){
orgArg = arguments;
-
if(frameCount == 0) { //for setup
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');
- table.innerHTML = '';
+ // table.innerHTML = '';
Interceptor.populateTable(table,Interceptor.setupObject.objectArray);
}
diff --git a/static/interceptor-functions.js b/static/interceptor-functions.js
index 3c4d52fe..fb89e75c 100644
--- a/static/interceptor-functions.js
+++ b/static/interceptor-functions.js
@@ -1,57 +1,11 @@
-String.prototype.paddingLeft = function (paddingValue) {
- return String(paddingValue + this).slice(-paddingValue.length);
-};
-
-function MergeObjRecursive(obj1, obj2) {
- var obj3 = {};
- for(p in obj1) {
- obj3[p] = obj1[p];
- }
- for(p in obj2) {
- if(Object.keys(obj3).indexOf(p)<0){
- obj3[p] = obj2[p];
- }
- else {
- obj3[p] = obj3[p] + obj2[p];
- }
- }
- return obj3;
-}
-
-if(Array.prototype.equals)
-// attach the .equals method to Array's prototype to call it on any array
-Array.prototype.equals = function (array) {
- // if the other array is a falsy value, return
- if (!array)
- return false;
-
- // compare lengths - can save a lot of time
- if (this.length != array.length)
- return false;
-
- for (var i = 0, l=this.length; i < l; i++) {
- // Check if we have nested arrays
- if (this[i] instanceof Array && array[i] instanceof Array) {
- // recurse into the nested arrays
- if (!this[i].equals(array[i]))
- return false;
- }
- else if (this[i] != array[i]) {
- // Warning - two different object instances will never be equal: {x:20} != {x:20}
- return false;
- }
- }
- return true;
-}
-// Hide method from for-in loops
-Object.defineProperty(Array.prototype, "equals", {enumerable: false});
-
-
var Interceptor = {
prevTotalCount :0,
totalCount : 0,
currentColor : 'white',
bgColor : 'white',
+ objectArea : 0,
+ coordinates : [],
+ objectDescription : '',
canvasDetails : {
width : 0,
height: 0
@@ -67,6 +21,7 @@ var Interceptor = {
objectTypeCount : {}
},
isCleared : false,
+
getColorName : function(arguments) {
if(arguments.length==3) {
//assuming that we are doing RGB - convert RGB values to a name
@@ -100,37 +55,37 @@ var Interceptor = {
}
},
- canvasLocator : function(arguments,canvasX,canvasY){
- var x,y;
- var isNum1 = false;
- var isNum2 = false;
+ /* return which part of the canvas an object os present */
+ canvasAreaLocation : function(x,arguments,canvasX,canvasY){
+
+ var x_loc,y_loc;
+
for(var i=0;i-1) {
+ x_loc = a;
+ }
+ else if(x.params[i].description.indexOf("y-coordinate")>-1) {
+ y_loc = a;
}
}
- if(x<0.4*canvasX) {
- if(y<0.4*canvasY) {
+ if(x_loc<0.4*canvasX) {
+ if(y_loc<0.4*canvasY) {
return 'top left';
}
- else if(y>0.6*canvasY) {
+ else if(y_loc>0.6*canvasY) {
return 'bottom left';
}
else {
return 'mid left';
}
}
- else if(x>0.6*canvasX) {
- if(y<0.4*canvasY) {
+ else if(x_loc>0.6*canvasX) {
+ if(y_loc<0.4*canvasY) {
return 'top right';
}
- else if(y>0.6*canvasY) {
+ else if(y_loc>0.6*canvasY) {
return 'bottom right';
}
else {
@@ -138,10 +93,10 @@ var Interceptor = {
}
}
else {
- if(y<0.4*canvasY) {
+ if(y_loc<0.4*canvasY) {
return 'top middle';
}
- else if(y>0.6*canvasY) {
+ else if(y_loc>0.6*canvasY) {
return 'bottom middle';
}
else {
@@ -149,6 +104,7 @@ var Interceptor = {
}
}
},
+
clearVariables : function(object) {
object.objectTypeCount = {};
object.objectCount = 0;
@@ -175,20 +131,44 @@ var Interceptor = {
this.bgColor = this.getColorName(arguments);
}
else if(!x.module.localeCompare('Shape') || !x.module.localeCompare('Typography') &&((!x.submodule)||(x.submodule.localeCompare('Attributes')!=0)) ){
+ this.objectArea = this.getObjectArea(x.name, arguments);
+ var canvasLocation = this.canvasAreaLocation(x, arguments ,width,height);
+ if(x.name.localeCompare('text')){
+ this.objectDescription = x.name;
+ }
+ else {
+ this.objectDescription = String(arguments[0]).substring(0,20);
+ }
- var canvasLocation = this.canvasLocator(arguments ,width,height);
+ this.coordinates = [];
- objectArray[objectCount] = {
- 'type' : x.name,
+ objectArray[objectCount] = {
+ 'type' : this.currentColor + ' colored ' + this.objectDescription ,
'location': canvasLocation,
- 'colour': this.currentColor
+ 'area': this.objectArea,
+ 'co-ordinates': this.coordinates
};
+
+ //make edits if it is a text object
+ if(!x.name.localeCompare('text')){
+ objectArray[objectCount]['type'] = this.objectDescription;
+ objectArray[objectCount]['color of text'] = this.currentColor;
+ }
+
//add the object(shape/text) parameters in objectArray
for(var i=0;i-1) {
+ objectArray[objectCount]['co-ordinates'].push(arguments[i]+'x')
+ }
+ else if(x.params[i].description.indexOf("y-coordinate")>-1) {
+ objectArray[objectCount]['co-ordinates'].push(arguments[i]+'y')
+ }
+ else{
+ objectArray[objectCount][x.params[i].description]=arguments[i];
+ }
}
if(objectTypeCount[x.name]) {
objectTypeCount[x.name]++;
@@ -208,27 +188,46 @@ var Interceptor = {
},
populateTable : function(table, objectArray) {
- if(this.totalCount<20) {
+ if(this.totalCount<100) {
if(this.prevTotalCount > this.totalCount) {
for(var j =0;j 1 ) {
- element.innerHTML += ' objects. The objects are ';
+ element.innerHTML += ' Contains ' + this.totalCount + ' objects - ';
}
else {
- element.innerHTML += ' object. The object is ';
+ element.innerHTML += ' Contains ' + this.totalCount + ' object - ';
}
if(object2.objectCount>0 || object1.objectCount>0 ) {
@@ -305,23 +356,32 @@ var Interceptor = {
element.innerHTML += totObjectTypeCount[keys[i]] + ' ' + keys[i] + ' ';
}
- element.innerHTML += "
";
- if(this.totalCount<20){
+ var objectList = document.createElement('ul');
+
+ if(this.totalCount<100){
for(var i=0; i