Skip to content

Commit 1386aeb

Browse files
committed
Fix broken download.
Downloading image was broken. Fixed and added corresponding image name to each image in the output file. Fixes #83
1 parent 494477a commit 1386aeb

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

scripts/output.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function getSubgoalInfo(){
8787
if(i.id !== currentAction) {
8888
currentAction = i.id;
8989
console.log("action");
90-
var actionString = getActionInfo(currSubgoal.actions);
90+
var actionString = getActionInfo(currSubgoal.actions, j);
9191
subgoalString = subgoalString + actionString;
9292
}
9393
}
@@ -108,10 +108,9 @@ function getSubgoalInfo(){
108108
* Formats the action information for all actions in a given list so
109109
* it's ready to go into the csv file.
110110
*/
111-
function getActionInfo(actionList){
111+
function getActionInfo(actionList, j){
112112
var actionEntry = [];
113113
for(var i in actionList) {
114-
console.log("CALLED");
115114
//get new line and to the right part of csv
116115
actionEntry.push("\n");
117116
actionEntry.push("\n"); //new row
@@ -175,6 +174,12 @@ function getActionInfo(actionList){
175174
actionEntry.push(actionList[i].postAction.facetValues["self"]);
176175
actionEntry.push(actionList[i].postAction.facetValues["risk"]);
177176
actionEntry.push(actionList[i].postAction.facetValues["tinker"]);
177+
actionEntry.push("\n");
178+
actionEntry.push("Action Image Name:");
179+
actionEntry.push("S"+(1 + parseInt(j))+"A"+(1 + parseInt(actionList[i].id))+"_"+actionList[i].name.substring(1, actionList[i].name.length-1));
180+
actionEntry.push("\n");
181+
182+
downloadURI(actionList[i].imgURL, "S"+(1 + parseInt(j))+"A"+(1 + parseInt(actionList[i].id))+"_"+actionList[i].name.substring(1, actionList[i].name.length-1));
178183
}
179184
return actionEntry.join(",");
180185
}
@@ -227,12 +232,12 @@ function downloadCSV(csvContent, old) {
227232
function downloadURI(uri, name) {
228233
var safeName = name;
229234
var safeUri = uri.slice(22);
230-
//console.log("in image", safeUri);
235+
console.log("in image", safeUri);
231236
var imgObj = {
232237
name:safeName+".png",
233238
uri: safeUri
234239
};
235-
//console.log("imgobj", imgObj);
240+
console.log("imgobj", imgObj);
236241
imgList.push(imgObj);
237242

238243
}
@@ -252,7 +257,9 @@ function create_zip(csvContent, old) {
252257
zip.file("GenderMagSession-on-" + mm + "-" + dd + "-" + yyyy + "-at-" + hr + "-" + min + ".csv", csvContent);
253258
}
254259
var img = zip.folder("images");
260+
console.log(imgList + "HHH");
255261
for(var i in imgList){
262+
console.log("IMAGE");
256263
img.file(imgList[i].name, imgList[i].uri, {base64: true});
257264
}
258265
zip.generateAsync({type:"blob"}).then(function(content) {

0 commit comments

Comments
 (0)