Hi guys, I've been having this problem for a while now. I have a script that generates a hash for a file based on the file that was uploaded, and it then puts that hash into the input field. If you inspect the element on the page I can see the value has changed to the hash. But in order to make it search, I need to type in the field.
Any ideas?
Thanks.
Update: Working code, thanks to @niketnilay!
DashboardController.ready();
pageLoading = false;
$(document).ready(function () {
console.log("Step 1. Inside Document ready function");
$(document).on("click","#btn",function () {
console.log("Step 2. Button Clicked");
var reader = new FileReader(); //define a Reader
var file = $("#f1")[0].files[0]; //get the File object
if (!file) {
alert("no file selected");
return;
} //check if user selected a file
reader.onload = function (f) {
console.log("Step 3. Reader on load function");
var file_result = this.result; // this == reader, get the loaded file "result"
var file_wordArr = CryptoJS.lib.WordArray.create(file_result); //convert blob to WordArray , see https://code.google.com/p/crypto-js/issues/detail?id=67
var sha1_hash = CryptoJS.SHA1(file_wordArr); //calculate SHA1 hash
//alert("Calculated SHA1:" + sha1_hash.toString()); //output result
$('#input1_3519-input').attr('value', sha1_hash);
setTimeout(function(){
console.log("Step 4 updated token values");
defaultTokenModel.set("form.search_hash_url", sha1_hash);
defaultTokenModel.set("search_hash_url", sha1_hash);
},10);
};
reader.readAsArrayBuffer(file); //read file as ArrayBuffer
});
});
}
);
// ]]>
... View more