inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Aug 11, 2013 3:19:31 GMT -8
All right I've got a tag on my Tumblr for Survival Tips. These are all given by images and are something I'd like to have as part of the main forum. What I was planning on is a random number generated that corresponds to a url set in the plugin settings field. What would then happen is <img src="'variable for url image thingy here" /> to be written into <div id="survivalImg"> </div> The number of images is liable to change which leads me to believe that an autoform would be the best option to do this so that as it gets more images added it can be easily updated. Any help further for this or even if I'm on the 'right track'? I've managed to get just one image set up to show. However what I can't seem to do on the test board is to write to the div as well so help? Editting - Wormopolishope you didn't mind me tagging you in this but I know that your weather code uses something similar so you might be able to help a bit if you have time?
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Aug 11, 2013 11:55:47 GMT -8
the weather code is "pseudo" random. meaning its a weighted system that uses the computer time as a seed so that everyone sees the same information.
what it looks like you are after, is a random image on every pageload?
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Aug 11, 2013 12:22:04 GMT -8
I'd rather have pseudo random - and I was more interested in how you targeted the div to write the image to
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Aug 11, 2013 12:46:47 GMT -8
well that part would be $('div#survivalImg').append($('<img src="' + imagesource + '">'));
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Aug 11, 2013 13:21:43 GMT -8
Mmkay -will sit and fiddle some more-
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Aug 12, 2013 1:40:19 GMT -8
Okay update I've got it to show just 'one' image from the basic image testing field, is there any way I could use an autoform field as a variable to use that to generate a random number and link that to use the appropriate image for display that would change at random
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Aug 12, 2013 3:14:24 GMT -8
if the images are stored in an array, just do a Math.random()*array.length
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Aug 12, 2013 3:15:43 GMT -8
How would I translate autoform inputs into an array?
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Aug 12, 2013 3:22:10 GMT -8
autoform is already an array when you use it as a variable in the javascript. each field in the autoform becomes a property of the auto form
so if your autoform was called
survival_images
and in the autoform you had a field
title
and
url
then in the javascript you would access a specific entry in the autoform with
plugin.settings...all your plugin name stuff...survival_images[N].title
or
plugin.settings...all your plugin name stuff...survival_images[N].url
where N is the number returned by the random result.
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Aug 12, 2013 3:26:13 GMT -8
Okay so there's only one field for the autoform just called 'images' (for now) to try and get it working.
so would I need to set it as this for the javascript?
<script type="text/javascript"> var surv="$[plugin.settings.image_testing]"; var surrand = Math.floor(Math.random() * $[plugin.settings.image_testing.image_url_test]); $('div#survivalImg').append($('<img src="'+$[plugin.settings.image_testing.image_url_test]+'" />'));
</script>
Or something else ((Sorry for the questions I'm honestly trying to learn this here)
Currently using it for global headers and footers to get it working type thing
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Aug 12, 2013 3:33:23 GMT -8
does a plugin not exist that holds the images already? why not just put the javascript in the plugin? then you could have easy access to the plugin variables.
$[plugin.settings.image_testing.image_url_test]
is a template variable and is undefined. you cannot access plugin variables from the template. well you CAN but only if the plugin runs before the template runs and with javascript directly in the template. but its risky since plugin might not have loaded yet.
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Aug 12, 2013 3:40:52 GMT -8
No one that holds the images doesn't exist already. This is all things from within the plugin component area
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Aug 12, 2013 3:50:31 GMT -8
so, just so we are on the same page, you are writing a plugin correct?
the images arent in YOUR plugin, but in a different plugin?
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Aug 12, 2013 3:56:48 GMT -8
The images are in my plugin - I have a few test urls in.
I am writing a plugin (or trying to) I may or may not be failing. I can get a single image to append to the div fine.
It's just getting the variable infoy stuff from the autoform instead to use to feed to randomize and select a random number that corresponds with a url from the variable which gets then appended to show as an image. If this makes any sense?
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Aug 12, 2013 3:58:27 GMT -8
ok. so you made the auto-form. excellent.
now when you are in the javascript part on the components page, do you see a list of variables over to the right?
|
|