Javasript functionality issues

43 views
Skip to first unread message

Gome

unread,
Sep 16, 2012, 9:27:33 AM9/16/12
to mnemosyne-...@googlegroups.com
Been experimenting a bit with javascript, there are two issues I had with it. #1 is probably just an QT issue,
#1. This should work (works in chrome), but the image is not displayed in mnemosyne:

CARDCODE:
-------------------------------
<SCRIPT LANGUAGE="JavaScript">var x = 100;var y = 50;var imageFile = "basal-ganglia.jpg";</SCRIPT><SCRIPT LANGUAGE="JavaScript" SRC="placeDot.js"></SCRIPT>


placeDot.js:
-------------------------------
window.onload=placeDot;
window.onresize=placeDot;

// Write picture and dot html to document
document.write("<div id=\"pic\" style=\"position:absolute\"><img src=\"" + imageFile +"\"></div><div id=\"dot\" style=\"position:absolute\"><b>x</b></div>")
alert (imageFile);
function placeDot(){
//offset relative to dot size
    x += 1;
y += 1;
// Center image
document.getElementById("pic").style.top = 0;
document.getElementById("pic").style.left = (window.innerWidth/2)-(document.getElementById("pic").offsetWidth/2);
    // Position dot
document.getElementById("dot").style.left = x + document.getElementById("pic").offsetLeft;
document.getElementById("dot").style.top = y;
//alert (document.getElementById("pic").style.left);
}




#2. Instead of writing the image to the document I placed it in the html. This is not that dynamic, but it works. There is a problem and that is that the outer card frame is not 100% in height. I think this has do do with that the the outer html is different when I did the testing in chrome, but I'm not entirely sure.

HTML CODE FOR TESTING IN CHROME:
-------------------------------
<html>
<head>
<title>JS place test</title>

</head>
<body>
<table width="100%" border="0" align="center">
  <tr>
    <td align="center" valign="middle">
    <table>
<div id="pic" style="position:absolute"><img src="basal-ganglia.jpg"></div>
<SCRIPT LANGUAGE="JavaScript">
// setting custom variables
// dot position
var x = 100;
var y = 50;
// map file
var imageFile = "basal-ganglia.jpg";
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="placeDot.js">
</SCRIPT>
</table>
</td>
  </tr>
</table>
</body>
</html>


CARDCODE:
-------------------------------
<div id="pic" style="position:absolute"><img src="basal-ganglia.jpg"></div>
<SCRIPT LANGUAGE="JavaScript">var x = 100;var y = 50;var imageFile = "basal-ganglia.jpg";</SCRIPT><SCRIPT LANGUAGE="JavaScript" SRC="placeDot.js"></SCRIPT>


placeDot.js:
-------------------------------

window.onload=placeDot;
window.onresize=placeDot;

// Write picture to document
//document.write("<div id=\"pic\" style=\"position:absolute\"><img src=\"" + imageFile +"\"></div>")
//  and dot html
document.write("<div id=\"dot\" style=\"position:absolute\"><b>x</b></div>")
alert (imageFile);
function placeDot(){
//offset relative to dot size
    x += 1;
y += 1;
// Center image
document.getElementById("pic").style.top = 0;
document.getElementById("pic").style.left = (window.innerWidth/2)-(document.getElementById("pic").offsetWidth/2);
    // Position dot
document.getElementById("dot").style.left = x + document.getElementById("pic").offsetLeft;
document.getElementById("dot").style.top = y;
//alert (document.getElementById("pic").style.left);
}

Gome

unread,
Sep 16, 2012, 10:19:56 AM9/16/12
to mnemosyne-...@googlegroups.com
There are other things that doesn't work as well, like the focus event, but that is probably not your fault.

Peter Bienstman

unread,
Sep 17, 2012, 2:49:10 AM9/17/12
to mnemosyne-...@googlegroups.com
Hi,

I'm afraid that if there are html/js issues, they are indeed Qt issues,
which I cannot do much about...

Peter
> --
> You received this message because you are subscribed to the Google
> Groups "mnemosyne-proj-users" group.
> To post to this group, send email to mnemosyne-...@googlegroups.com.
> To unsubscribe from this group, send email to
> mnemosyne-proj-u...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/mnemosyne-proj-users/-/TNUg-oOh6Y0J.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
Peter Bienstman
Ghent University, Dept. of Information Technology
Sint-Pietersnieuwstraat 41, B-9000 Gent, Belgium
tel: +32 9 264 34 46, fax: +32 9 264 35 93
WWW: http://photonics.intec.UGent.be
email: Peter.B...@UGent.be
Reply all
Reply to author
Forward
0 new messages