JavaScript path problem

60 views
Skip to first unread message

Gnome

unread,
Jul 20, 2013, 2:25:27 AM7/20/13
to mnemosyne-...@googlegroups.com
I decided to do another try of creating an map-overlay script in javaScript for replacing the current I'm using, witch is made in flash.

When reffering to an image in my script, I need to use an absolute path for it to work.

For example the html in the card looks like this:

<div id="root"></div>
<SCRIPT LANGUAGE="JavaScript">var x = 268;var y = 400;var i = 'basal-ganglia.jpg';</SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="imageHelper_files/d9.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="imageHelper_files/placeDot.js"></SCRIPT>

The variable i declares the path to the map. For it to work, the path needs to be absolute like this:

var i = 'file:///C:/Users/User/AppData/Roaming/Mnemosyne/default.db_media/basal-ganglia.jpg';

In the script linked (placeDot.js), the image is inserted into the document like this:

var map = document.createElement('IMG');
map.src = i;
root.appendChild(map);

I could link the image file in the card html, but that would not be ideal because it would require more code in the card and it would be harder to make changes later. Normally the absolute path can be found using window.location.pathname+window.location.search. But this only returns "blank" in mnemosyne.
I wonder if a workaround could be made where the absolute path is declared in the html template by mnemosyne, for example:

<SCRIPT LANGUAGE="JavaScript">var db_media = full path to db_media goes here;</SCRIPT>

Then later accesed by the users script.
Or that mnemosyne replaces text containing a certain codename in the html, for example:

var i = 'db_media:///basal-ganglia.jpg';

It would be nice if there could be a workaround for this.

Gnome

unread,
Jul 20, 2013, 3:18:49 AM7/20/13
to mnemosyne-...@googlegroups.com
or perhaps mnemosyne could modify ".src = "?

Peter Bienstman

unread,
Jul 20, 2013, 5:22:23 AM7/20/13
to mnemosyne-...@googlegroups.com
Does src instead of SRC work?

Peter
> --
> You received this message because you are subscribed to the Google
> Groups "mnemosyne-proj-users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to mnemosyne-proj-u...@googlegroups.com.
> To post to this group, send email to mnemosyne-...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mnemosyne-proj-users/662a72f9-63f5-4e8a-bb2c-a245422acd8e%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



Message has been deleted

Gnome

unread,
Jul 20, 2013, 4:03:19 PM7/20/13
to mnemosyne-...@googlegroups.com
What do you mean? I already use src, tried using SRC it did not work, even in browser.
> send an email to mnemosyne-proj-users+unsub...@googlegroups.com.

Peter Bienstman

unread,
Jul 20, 2013, 11:23:25 PM7/20/13
to mnemosyne-...@googlegroups.com
OK, I understand better what you mean now. I'll have a go at implementing the second workaround after my holidays.

Peter

Gnome <jippi...@hotmail.com> wrote:
It was src. SRC does not work even in firefox.


kl. 11:22:23 UTC+2 lørdag 20. juli 2013 skrev Peter Bienstman følgende:

Gnome

unread,
Jul 21, 2013, 3:44:34 AM7/21/13
to mnemosyne-...@googlegroups.com
Cool, I'll send you an working example.
Reply all
Reply to author
Forward
0 new messages