My JavaScript function fetches the value of a label element first, which serves as an ID for a database entry. These IDs are then sent to an ASP page to retrieve the save location of images from the database.
The save location information for each selected image is then passed to an ASP.NET page, where the images are rotated accordingly. Everything works perfectly, except for the fact that the images do not update until I reopen the HTA file.
Refresh does not work, as shown in the video.
The files have rotated, as visible in the video at the bottom
This is the JavaScript code responsible for image rotation:
function doRotate(dir,obj)
{
var http = getHTTPObject();
var http2 = getHTTPObject();
ids = fetchSelection().toString();
//Animate button to indicate it's working
obj.src = "http://localhost/nightclub_photography/images/buttons/"+dir+"_animated.gif";
http.onreadystatechange = function()
{
//Fetch the save location of selected images
if (http.readyState == 4 && http.status == 200) {
//Create URL string to send to rotate script
var locs = http.responseText;
locs = locs.split(",");
//Start of URL
var url = "http://localhost/nightclub_photography/net/rotate_script.aspx?dir=" + dir;
for (var i=0; i < locs.length-1; i++)
{
url = url + "&t=" + locs[i];
}
//Add random math
url = url + "&k=" + Math.random();
http2.onreadystatechange = function()
{
if (http2.readyState == 4 && http2.status == 200)
{
//Stop animated button
obj.src = "http://localhost/nightclub_photography/images/buttons/"+dir+".png";
//Split id's
var idsSplit = ids.split(",");
for (var k=0; k < idsSplit.length; k++) {
reapplyStyle(idsSplit[k]);
}
}
}
http2.open("GET", url);
http2.send();
}
}
http.open("GET", "http://localhost/nightclub_photography/asp/returnDatabaseData.asp?ids="+ids+"&k=" + Math.random());
http.send();
}
I also have a function that should reapply the background image, which would reload the rotated images. However, reloading the page doesn't work, and hence I cannot see that function in action either. Here is the function:
function reapplyStyle(id) {
var background = doc(id+"_label").style.backgroundImage;
doc(id+"_label").style.backgroundImage = background;
}