1$(window).load(function () { 2 $(document).trigger("footer:set"); 3}); 4 5$(document).ready(function () { 6 $(document).on("click", "a.choose-city-close", function (event) { 7 event.preventDefault(); 8 $(".choose-city-overlay, .choose-city-box").fadeOut(); 9 }); 10 11 12 getNews(); 13 14 //images slider 15 var slider = $(".city-landing-slider"); 16 if (slider.length > 0) { 17 slider.imagesLoaded(function (instance) { 18 slider.find(".loader").remove(); 19 slider.find(".city-landing-slider-bg:first").fadeIn(400, function () { 20 $(".city-landing-slider-bg").removeClass("active"); 21 $(".city-landing-slider-bg:visible").addClass("active"); 22 slider.addClass("is-loaded"); 23 if (slider.find(".city-landing-slider-bg").length > 1) { 24 setInterval(function () { 25 slider.find(".city-landing-slider-bg:first") 26 .fadeOut(1000) 27 .next() 28 .fadeIn(1000, function () { 29 $(".city-landing-slider-bg").removeClass("active"); 30 $(".city-landing-slider-bg:visible").addClass("active"); 31 }) 32 .end() 33 .appendTo(slider); 34 }, 4000); 35 } 36 }); 37 }).progress(function (instance, image) { 38 var img = $(image.img); 39 var container = img.closest(".city-landing-slider-bg"); 40 var largeSrc = img.attr("data-large"); 41 if (!image.isLoaded && largeSrc !== "") { 42 console.log("Replacing image for " + image.img.src + " with " + largeSrc); 43 img.attr("src", largeSrc); 44 container.css("background-image", "url('" + largeSrc + "')"); 45 } 46 }); 47 } 48 49 //video 50 var playerBox = $(".city-landing-video"); 51 var player = $(".city-landing-video-player"); 52 if (playerBox.length === 1 && player.length === 1) { 53 player.flowplayer({ 54 key: playerBox.data("videoKey"), 55 clip: { 56 sources: [{ type: "video/mp4", src: playerBox.data("videoUrl") }], 57 title: playerBox.data("videoTitle") 58 } 59 }); 60 } 61}); 62 63 64function getNews() { 65 var newsBox = $(".news-box"); 66 if (newsBox.length > 0) { 67 68 //var magazineImage = $('.edit-magazine').data("magazine-image"); 69 //console.log("magazineImage"); 70 //console.log(magazineImage); 71 //var newsItems = $(".news-items"); 72 var newsFeed = $(".news-container"); 73 74 try { 75 var photoUrl = "https://api.tumblr.com/v2/blog/" + newsBox.data("blogIdentifier") + "/posts?api_key=" + newsBox.data("access") + "&limit=100"; 76 77 //News from Tumblr 78 $.ajax({
79 type: "GET", 80 dataType: "jsonp", 81 cache: false, 82 url: photoUrl, 83 success: function (data) { 84 85 86 87 if (data.response && data.response.posts) { 88 89 var j = 0; 90 var foundFirstPhoto = false; 91 var skippedFirstVideo = false; 92 while (j < data.response.posts.length) { 93 var originalj = j; 94 95 try { 96 97 var post = data.response.posts[j] 98 99 100 //console.log("Post"); 101 //console.log(post); 102 103 if (post.type === "photo" && post.photos && post.photos.length > 0) { 104 var photo = post.photos[0]; 105 106 var photocaption = formatCaption(post.caption); 107 108 if (!foundFirstPhoto) { 109 //First Item, goes into the news section class=\"news-item news-item-1\" 110 var firstDivisionItem = ` 111 <a target="_blank" href="${post.post_url}" title="${post.summary}"> 112 <img class="division-image" src="${photo.original_size.url}" /> 113 <div class="division-heading">new work</div> 114 <div class="division-description">${photocaption}</div> 115 </a>`; 116 $('.first.division-item').html(firstDivisionItem); 117 118 foundFirstPhoto = true; 119 } else { 120 let newsItem = ` 121 <div data-aos="fade-zoom-in" data-aos-easing="ease-in-back" data-aos-duration="500" class="grid-item news-item-${j + 1}"> 122 <div class="grid-content"> 123 <a target="_blank" href="${post.post_url}" title="${post.summary}"> 124 <div class="stretchy" style="background-image:url('${photo.original_size.url}'); background-size: 100% 100%;"> 125 <img style="display: block; visibility: hidden; height: auto; max-width:100%;" src="${photo.original_size.url}" alt="${photocaption}" /> 126 </div> 127 </span> 128 </a> 129 <a class="news-content" href="${post.post_url}" title="${post.summary}">${photocaption}</a> 130 </div> 131 </div>`; 132 newsFeed.append(newsItem); 133 } 134 135 } 136 if (post.type === "text") { 137 try { 138 var parser = new DOMParser(); 139 var doc = parser.parseFromString(post.body, 'text/html'); 140 var photo = doc.querySelector('img').src; 141 var photocaption = formatCaption(doc.querySelector('p')); 142 143 if (!foundFirstPhoto) { 144 var firstDivisionItem = ` 145 <a target="_blank" href="${post.post_url}" title="${post.summary}"> 146 <img class="division-image" src="${photo}" /> 147 <div class="division-heading">new work</div> 148 <div class="division-description">${photocaption}</div> 149 </a>`; 150 $('.first.division-item').html(firstDivisionItem); 151 152 foundFirstPhoto = true; 153 } else { 154 let newsItem = ` 155 <div data-aos="fade-zoom-in" data-aos-easing="ease-in-back" data-aos-duration="500" class="grid-item news-item-${j + 1}"> 156 <div class="grid-content"> 157 <a target="_blank" href="${post.post_url}" title="${post.summary}"> 158 <div class="stretchy" style="background-image:url('${photo}'); background-size: 100% 100%;"> 159 <img style="display: block; visibility: hidden; height: auto; max-width:100%;" src="${photo}" alt="${photocaption}" /> 160 </div> 161 </span> 162 </a> 163 <a class="news-content" href="${post.post_url}" title="${post.summary}">${photocaption}</a> 164 </div> 165 </div>`; 166 newsFeed.append(newsItem); 167 } 168 } catch (err) { 169 console.error(`Error: Get tumblr media type = ${post.type}`) 170 } 171 } 172 if (post.type === "video" && post.player && post.player.length > 0 && post.player[post.player.length - 1].embed_code) { 173 if (skippedFirstVideo) { 174 175 let postVideo = createAutoPlayVideoElement(post) 176 var videoCaption = formatCaption(post.caption); 177 let newsItem = ` 178 <div data-aos="fade-zoom-in" data-aos-easing="ease-in-back" data-aos-duration="500" class="grid-item news-item-${j + 1}"> 179 <div class="grid-content"> 180 ${postVideo} 181 <a class="news-content news-video" href="${post.post_url}" title="${post.summary}">${videoCaption}</a> 182 </div> 183 </div>`; 184 newsFeed.append(newsItem); 185 } 186 else { 187 skippedFirstVideo = true; 188 } 189 } 190 } 191 catch (err) { 192 j = originalj; 193 newsHtml = ""; 194 } 195 //newsFeed.append(newsHtml); 196 j++; 197 } 198 } 199 200 201 202 //var lazyResults = $(".news-bg"); 203 204 //$(lazyResults).lazyload({ 205 // effect: "fadeIn", 206 // event: "relLoad" 207 //}); 208 209 //$(lazyResults).trigger("relLoad"); 210 211 var $grid = $('.grid').isotope({ 212 itemSelector: '.grid-item', 213 percentPosition: true, 214 masonry: { 215 columnWidth: '.grid-sizer' 216 } 217 }); 218 219 if ($('.home-division-container').length > 0) { 220 $('.home-division-container ').imagesLoaded() 221 .done(function () { 222 $('.division-image').fadeIn(500); 223 }) 224 //.progress(function (instance, image) { 225 226 //var img = $(image.element); 227 //console.log(img); 228 //img.addClass("is-loaded"); 229 //} 230 //); 231 } else { 232 newsBox.hide(); 233 console.log("No tumblr photos added to news box"); 234 } 235 236 237 if (newsFeed.find(".grid-item").length > 0) { 238 239 newsFeed.imagesLoaded({ background: true }) 240 .progress(function (instance, image) { 241 242 $grid.isotope('layout'); 243 //console.log("Image Loaded!") 244 245 246 //img.fadeIn(2000); 247 //img.addClass("is-loaded"); 248 249 }) 250 .done(function () { 251 //$grid.isotope('layout'); 252 $grid.fadeIn(); 253 AOS.init(); 254 //$grid.isotope('layout'); 255 256 }); 257 258 259 260 } else { 261 newsFeed.hide(); 262 console.log("No tumblr photos added to news feed"); 263 } 264 265 266 267 } 268 }).fail(function (xhr, exception, error) { 269 newsBox.hide(); 270 console.log("Ajax error retrieving tumblr photos: "); 271 console.log(xhr); 272 console.log(exception); 273 console.log(error); 274 }); 275 } catch (error) { 276 newsBox.hide(); 277 console.log("Error retrieving tumblr photos: "); 278 console.log(error); 279 } 280 } 281 //audio 282 var bosstapeBox = $(".bosstape-box"); 283 if (bosstapeBox.length > 0 && newsBox.length > 0) { 284 285 try { 286 var bosstapeUrl = "https://api.tumblr.com/v2/blog/" + newsBox.data("blogIdentifier") + "/posts?type=audio&api_key=" + newsBox.data("access"); 287 //News from Tumblr 288 $.ajax({
289 type: "GET", 290 dataType: "jsonp", 291 cache: false, 292 url: bosstapeUrl, 293 success: function (data) { 294 console.log("Tumblr audio"); 295 console.log(data); 296 var hasBosstape = false; 297 298 if (data.response && data.response.posts) { 299 var k = 0; 300 while (!hasBosstape && k < data.response.posts.length) { 301 try { 302 var post = data.response.posts[k]; 303 if (!hasBosstape && post.type === "audio" && post.embed) { 304 bosstapeBox.append("<div class=\"bosstape\">âââ" + post.embed + "ââ</div>"); 305 bosstapeBox.find(".h2-lines a").attr("href", post.post_url); 306 hasBosstape = true; 307 } 308 } 309 catch (err) { 310 311 } 312 k++; 313 } 314 } 315 if (!hasBosstape) { 316 console.log("No tumblr audio added"); 317 } 318 } 319 }).fail(function (xhr, exception, error) { 320 console.log("Ajax error retrieving tumblr audio: "); 321 console.log(xhr); 322 console.log(exception); 323 console.log(error); 324 }); 325 } catch (error) { 326 console.log("Error retrieving tumblr audio: "); 327 console.log(error); 328 } 329 } 330 331 //video 332 var bossfilmBox = $(".film-box"); 333 if (bossfilmBox.length > 0 && newsBox.length > 0) { 334 console.log("We have a bossfilm box"); 335 try { 336 var bossfilmUrl = "https://api.vimeo.com/users/25116697/videos"; 337 //Feed from Vimeo 338 $.ajax({
339 url: bossfilmUrl, 340 type: "GET", 341 headers: { Authorization: "Bearer 2507b61e00b42ad938b98aa87187ff27" }, 342 success: function (data) { 343 console.log("Vimeo Feed"); 344 console.log(data); 345 var hasBossfilm = false; 346 347 var videos = data.data; 348 if (videos.length > 0) { 349 var i = 0; 350 while (!hasBossfilm && i < videos.length) { 351 try { 352 if (videos[i].type == "video" && !hasBossfilm) { 353 var post = videos[i]; 354 355 var postVideo = createVimeoAutoPlayVideoElement(post); 356 var postCaption = post.name; 357 358 var postHtml = 359 '<div class="boss-film-video"><a class="film-target" href="' + 360 post.link + 361 '" title="' + 362 post.summary + 363 '" target="_blank">'; 364 postHtml += 365 postVideo + 366 '<div class="division-heading">boss on film</div><div class="division-description">' + 367 postCaption + 368 "</div></a>â</div>"; 369 bossfilmBox.append(postHtml); 370 $(".third .news-content").hide(); 371 hasBossfilm = true; 372 } 373 } catch (err) { } 374 i++; 375 } 376 } 377 }, 378 }).fail(function (xhr, exception, error) { 379 console.log("Ajax error retrieving Vimeo Feed: "); 380 console.log(xhr); 381 console.log(exception); 382 console.log(error); 383 }); 384 } catch (error) { 385 console.log("Error retrieving vimeo video: "); 386 console.log(error); 387 } 388 389 } 390} 391 392function createVimeoAutoPlayVideoElement(post) { 393 let newIframeSource = `<div class="resp-container"><iframe class="resp-iframe" src="${post.player_embed_url}&autoplay=1&loop=1&autopause=0&controls=0&muted=1" frameborder="0" allow="autoplay; picture-in-picture; fullscreen" allowfullscreen></iframe></div>`; 394 395 return newIframeSource; 396} 397 398 399function createAutoPlayVideoElement(post) { 400 let numberOfCharacters = "https://vimeo.com/".length; 401 let end = post.permalink_url.indexOf("?"); 402 let videoID = post.permalink_url.substring(numberOfCharacters, end); 403 let iframeSource = `https://player.vimeo.com/video/${videoID}?background=1&portrait=0`; 404 let newIframeSource = `<div class="resp-container"><iframe class="resp-iframe" src="${iframeSource}" frameborder="0" allow="autoplay; picture-in-picture; fullscreen" allowfullscreen></iframe></div>`; 405 return newIframeSource; 406} 407 408function formatCaption(cap) { 409 var caption = ""; 410 try { 411 var elm = $(cap); 412 caption = elm.text(); 413 var outer = $("<div></div>"); 414 outer.append(elm); 415 if (outer.find("p").length > 0) { 416 caption = outer.find("p").first().text(); 417 } 418 var b = caption.toLowerCase().indexOf("by"); 419 if (b >= 0) { 420 caption = (caption.substring(0, b) + "<em>" + caption.substring(b, caption.length) + "</em>"); 421 } 422 } 423 catch (err) { 424 caption = cap; 425 } 426 return caption; 427}
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.