Accessing external var
Accessing external var
Hi, I've been writing a script using the Flickr API.
Basically it takes photos from a certain set and user and puts those in the fancybox format. The problem I have now is that whenever I want the set to change, I have the edit the javascript,. Instead I want to be able to change this in the html where it's being called.
Here's the script:
- (document).ready(function(){
- //insert your Flickr API key
- var api='6f9bff414d8f176e5c15359934c741bb'
- //insert the ID of the set you want to use
- var photoset='72157624543526492'
-
- //creating custom feed from chosen set
- var url='http://api.flickr.com/services/rest/?&method=flickr.photosets.getPhotos&api_key=' +api+'&photoset_id='+photoset+'&media=photos&format=json&jsoncallback=?'
-
- $.getJSON(url, function(data){
- $.each(data.photoset.photo, function(idx, item){
-
- //making var for original image
- var photourlz = 'http://farm5.static.flickr.com/' +item.server+ '/' +item.id+ '_' +item.secret+ '_z.jpg';
- //making var for the thumbnails
- var photourls = 'http://farm5.static.flickr.com/' +item.server+ '/' +item.id+ '_' +item.secret+ '_s.jpg';
- //take title from feed so it can be used in the viewer
- var title = item.title;
-
- //put the photos in the DIV
- $('#photos').append('<div id=photo><a rel="photoset" title="'+title+ '" href=" '+photourlz+' "><img src=" '+photourls+' " alt=""/></a></div>');
- //give those photos the FancyBox treatment
- $("a[rel=photoset]").fancybox({
- 'transitionIn' : 'fade',
- 'transitionOut' : 'fade',
- 'speedIn' : 600,
- 'speedOut' : 200,
- 'overlayShow' : false,
- 'titleShow' : true,
- 'titlePosition' : 'inside'
- });
-
- });
-
- });
-
-
-
- });
So is it possible to call the vars when I include the script in an external page?
Like
- <script type="text/javascript" src="FancyFlickr.js">
- // insert api & photoset vars
- </script>
Thanks in advance!