Skip to content

Instantly share code, notes, and snippets.

@batkinson
Created November 16, 2015 15:38
Show Gist options
  • Save batkinson/a753800901707026445d to your computer and use it in GitHub Desktop.
Save batkinson/a753800901707026445d to your computer and use it in GitHub Desktop.

Remi created this for me to aid in creating a form with many images to test with pdf performance issues. I had manually created a form since the problem initially seemed linked to images, but when I went to purchase an iPad and test it performed better than what Joachim had reported (~20 mins vs my <1 min).

To use this, you just need to:

  • Enable the device to download the form definition from a zegeba endpoint
  • Open the form on the device and provide an answer for the media question
  • Use the supplied function in the js file to repeat the answer via console
  • Reopen the form and the image should be rendered multiple times
{"name":"ImageZerg","variableName":"garbage_imagezerg_v1","type":"form","description":"","helpText":"","icon":"glyphicon-file","helpTextStyle":"2","navigationStyle":"inherit","allowRemarks":false,"allowUserFormState":false,"allowFormUploadWithoutMedia":false,"clearSignatureOnChanges":false,"allowDataFromTemplateForm":false,"isTemplateForm":false,"synchTemplateForm":false,"children":[{"name":"Page 1","variableName":"page_1","type":"page","helpText":"","children":[{"name":"Main repeat","variableName":"main_repeat","type":"repeat","helpText":"","optionLayout":"automatic","sortChildItems":"none","hideTableHeader":false,"inputWidth":"automatic","children":[{"name":"Question 5","variableName":"question_5","type":"repeat_subset","helpText":"","reference":"target_repeat","optionLayout":"automatic","sortChildItems":"none","hideTableHeader":false,"inputWidth":"automatic"}]},{"name":"Target repeat","variableName":"target_repeat","type":"repeat","helpText":"","optionLayout":"automatic","sortChildItems":"none","hideTableHeader":false,"inputWidth":"automatic","children":[{"name":"Description","variableName":"description","type":"text","helpText":"","inputWidth":"automatic"},{"name":"Question 4","variableName":"question_4","type":"image","helpText":"","inputWidth":"automatic","printHide":false}]}]}],"validations":[],"descriptionFormula":""}
/**
* A function to repeat images from a single input item for the test form.
*/
function hackRepeatAnswer(key, repeatVarName, duplicates) {
var json = localStorage[key];
var data = JSON.parse(json);
var originalAnswer = JSON.stringify(data.formdata[repeatVarName].repeat[0]);
var newAnswers = [];
for (var i = 0; i < duplicates; i++) {
var newAnswer = JSON.parse(originalAnswer);
newAnswer[repeatVarName + "_zegebadataprofile"].text = "r_fake_fake_" + i;
newAnswers.push(newAnswer);
}
data.formdata[repeatVarName].repeat = newAnswers;
return JSON.stringify(data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment