Announcement
Collapse
No announcement yet.
referencing plugin javascript files
Collapse
X
-
referencing plugin javascript files
I am finding it very difficult to predictably locate my own javascript libraries.
for example my plugin is located on path
Cache\InstalledPlugins\Plugins\SqueezeDSP\HTML\EN\ plugins\SqueezeDSP\index.html
I have two libraries sqdsp_data.js and sqdsp_controls.js which manage calls to the server and populate controls.
if I locate them in the same folder relative to the index.html file and enter a path
<script type="text/javascript" src="sqdsp_data.js"></script>
or
<script type="text/javascript" src="./sqdsp_data.js"></script>
the files do not seem to be picked up.
Can you confirm where I should be locating these files relative to the above path?
For now I have embedded the scripts within index.html and the code is working, but I don't like this approach.
-
referencing plugin javascript files
> Cache\InstalledPlugins\Plugins\SqueezeDSP\HTML\EN\ plugins\SqueezeDSP\index.html
create another folder html below where you have index.html. Yes, it's
awful, but the html (lowercase) sub folder would be served as static files.
> <script type="text/javascript" src="sqdsp_data.js"></script>
This then should become "html/sqdsp_data.js".
Michael
"It doesn't work - what shall I do?" - "Please check your server.log and/or scanner.log file!"
(LMS: Settings/Information)
Comment
-
Originally posted by mherger View Post> Cache\InstalledPlugins\Plugins\SqueezeDSP\HTML\EN\ plugins\SqueezeDSP\index.html
create another folder html below where you have index.html. Yes, it's
awful, but the html (lowercase) sub folder would be served as static files.
> <script type="text/javascript" src="sqdsp_data.js"></script>
This then should become "html/sqdsp_data.js".no wonder I couldn't figure it out!
Comment
-
Cache\InstalledPlugins\Plugins\SqueezeDSP\HTML\EN\ plugins\SqueezeDSP\index.html
create another folder html below where you have index.html. Yes, it's
awful, but the html (lowercase) sub folder would be served as static files.
<script type="text/javascript" src="sqdsp_data.js"></script>
This then should become "html/sqdsp_data.js".
So the new html folder should be on this path
Cache\InstalledPlugins\Plugins\SqueezeDSP\HTML\EN\ plugins\html\sqdsp_data.js
and I should be able to reference it via
<script type="text/javascript" src= "html/sqdsp_data.js"></script>
I have tried this and it is not working. If you can confirm whether I have the above correct, if so it will be something else.
Comment
-
referencing plugin javascript files
Try something like the following in your page template:
[% webroot %]plugins/SqueezeDSP/html/sqdsp_data.js
This should create an absolute path to the file.
Michael
"It doesn't work - what shall I do?" - "Please check your server.log and/or scanner.log file!"
(LMS: Settings/Information)
Comment
-
What I did in the past when starting on plugin development was downloads lots of existing plugins and then search for something similar.
You could download and search to see who has separate JS files and then see where they are and how they invoke them.Paul Webster
Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin
Comment
-
I just solved a related issue that I had been struggling with, this is that as part of an update to a plugin I had amended an associated javascript file, which was referenced in the main page. However try as I might none of the changes did anything unless I posted them directly as script in the main page.
However when I changed the path of the javascript file it all worked. So I think that the server is using a copy of the javascript file derived off it's location, and this survives an upgrade, reboot and clearing of the cache.
The correct solution would therefore be to use js and css files with a version number in their name.
Not sure whether this is documented anywhere - hence making a note here.
Comment
Comment