PageSourceSearch

https://tobiasduerschmid.github.io/js/datafolio.js

js tobiasduerschmid.github.io collected 2026-10-03 10:05:27 UTC 3,731 bytes, 151 lines download raw bytes

1var flickr_api = "https://api.flickr.com/services/rest/";
2var flickr_api_key = "";
3
4function flickr_photo_url(photo)
5{
6  return "https://farm" + photo.farm 
7    + ".staticflickr.com/" + photo.server + "/" 
8    + photo.id + "_" + photo.secret + "_b.jpg";
9}
10
11var gallery_cache = [];
12
13function blueimp_gallery(photoset_id)
14{
15  blueimp.Gallery(gallery_cache[photoset_id]
16    , { useBootstrapModal : false, event : event, container: '#blueimp-gallery' });  
17}
18
19function blueimp_video(photoset_id)
20{
21  blueimp.Gallery(gallery_cache[photoset_id]
22    , { useBootstrapModal : false, event : event, container: '#blueimp-gallery' });  
23}
24
25function flickr_photosets(photoset_id) 
26{
27  if(photoset_id in gallery_cache)
28  {
29    blueimp_gallery(photoset_id);
30    return;
31  }
32
33  var spinner = $('#' + photoset_id + ' .tag');
34  var spinner_text = spinner.text();
35  var load_failed = false;
36  spinner.text("fetching");
37  spinner.addClass("animate");
38
39  $.getJSON(flickr_api, 
40    {
41      method : "flickr.photosets.getPhotos",
42      api_key : flickr_api_key, 
43      photoset_id : photoset_id,
44      format : "json",
45      nojsoncallback : 1
46    })
47
48  .done(function(data) 
49  {
50    if(!data.photoset)
51        return;
52
53    var gallery = [];
54
55    $.each(data.photoset.photo, function(i, photo) {
56      gallery.push( { href  : flickr_photo_url(photo), title : photo.title } ) });
57
58    gallery_cache[photoset_id] = gallery;
59    blueimp_gallery(photoset_id);
60  })
61  .fail( function(data, textStatus, error) 
62  {
63    load_failed = true;
64    spinner.attr({ role: "alert", "aria-live": "assertive" });
65    spinner.text("Photos could not load right now. Check your connection and try again later.");
66    if (window.console && console.warn) console.warn("Flickr photoset load failed:", textStatus, error);
67  })
68  .always( function() 
69  { 
70    spinner.removeClass("animate");
71    if (!load_failed) spinner.text(spinner_text);
72  });
73}
74
75$(document).ready(function() 
76{ 
77  new Clipboard('.btn-clipboard');
78
79  $('.flickr').on('click', function(event) 
80  { 
81    event.preventDefault();
82    flickr_photosets($(this).attr("id")); 
83  });
84
85  var scroll = getURLParameter("scroll");
86  if(scroll)
87  {
88    var url = window.location.href;
89    url = url.replace(/scroll=\d*&?/, '');
90    url = url.replace(/&$/, '');
91    url = url.replace(/\/\?$/, '/');
92
93    window.history.pushState("string", "Title", url);
94
95    $(window).scrollTop(scroll);
96  }
97
98});
99
100function scrollAwareHRef(object, href)
101{
102  object.attr('href', href + "?scroll=" + $(window).scrollTop());
103}
104
105function getURLParameter(sParam)
106{
107  var sPageURL = window.location.search.substring(1);
108  var sURLVariables = sPageURL.split('&');
109
110  for (var i = 0; i < sURLVariables.length; i++)
111  {
112    var sParameterName = sURLVariables[i].split('=');
113    if (sParameterName[0] == sParam)
114      return sParameterName[1];
115  }
116  return null;
117}
118
119
120jQuery.validator.addMethod("empty", function(value, element) {
121  return this.optional(element) || (value.length === 0 || !value.trim());
122}, "Please verify you are not a bot.");
123
124$("#contact-form").validate({
125
126  lang : 'en',
127
128  rules : {
129    name     : { required : true },
130    nobot    : { maxlength: 0, empty : true }, 
131    _replyto : { required : true, email : true },
132    message  : { required : true, maxlength : 1024 } }, 
133
134  errorClass   : 'error form-control-static text-warning',
135  errorElement : 'small',
136
137  highlight : function(label) 
138  { $(label).closest('.form-group').addClass('has-warning'); },
139
140  success : function(label) 
141  { $(label).closest('.form-group').removeClass('has-warning');
142    $(label).remove(); },
143
144  submitHandler : function(form) 
145  { $.ajax(
146    { url  : form.action,
147      type : form.method,
148      data : $(form).serializeJSON()
149    });
150  }
151});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.