1(function ($) { 2 3 "use strict" 4 5 let delay_graph = [] 6 let delay_time = 5000 7 8 $(document).on("click", ".js-open-layover", function () { 9 10 $(".aws-menu-layover").toggleClass("open"); 11 $("body").toggleClass("has-visible-layover"); 12 13 }); 14 15 $(document).on("click", ".js-open-layover-download", function () { 16 17 $(".download-layover").toggleClass("open"); 18 $("body").toggleClass("has-visible-layover"); 19 20 }); 21 22 $(document).on("click", ".js-open-download-layover", function () { 23 24 $(".download-layover").toggleClass("open"); 25 $("body").toggleClass("has-visible-layover"); 26 27 }); 28 29 let download_button_content = $(".js-kib-download-page").html() 30 let big_numbers_intervals = [] 31 32 $(document).ready(function () { 33 34 $.each($(".aws-big-number"), function (i, val) { 35 36 let or_number = $(val).text() 37 let number = $(val).text() 38 39 if (number.includes(",")) { 40 $(val).data("ntype", "float") 41 number = parseFloat($(val).text().replace(",", ".")).toFixed(2) 42 } else { 43 $(val).data("ntype", "int") 44 number = parseInt($(val).text().replace(".", "")) 45 } 46 $(val).attr("data-number", number) 47 48 $(val).text(0) 49 50 if (i + 1 === $(".aws-big-number").length) { 51 52 init_big_numbers() 53 54 } 55 56 }) 57 58 59 }) 60 61 $(window).on('resize scroll', function () { 62 63 init_big_numbers() 64 65 }) 66 67 $('.video__placeholder, .video__button').on('click', function () { 68 if (!$('#video-player').length) { 69 var video = '<iframe id="video-player" src="' + $('.video__placeholder').attr('data-video') + '" frameborder="0" allowfullscreen wmode="opaque"></iframe>'; 70 $(video).insertAfter($('.video__placeholder')); 71 $('.video__button').addClass('is-playing'); 72 } else { 73 $('.video__button').removeClass('is-playing'); 74 $('#video-player').remove(); 75 } 76 }); 77 78 $(document).on("click", ".js-kib-download-page", function () { 79 80 let button = $(this) 81 init_pdf_injection(button) 82 83 }) 84 85 $(document).on("click", "*", function (e) { 86 87 if ($(e.target).closest(".aws-footnote").length > 0) { 88 return true 89 } 90 91 if (!$(e.target).hasClass("aws-footnote-tooltip")) { 92 $(".aws-footnote-tooltip.visible").removeClass("visible") 93 } 94 95 }) 96 97 $(document).on("click", ".js-kib-download-all-pages", function () { 98 99 let button = $(this) 100 button.html("Loading") 101 init_download_all_pages(button) 102 103 }) 104 105 function init_big_numbers() { 106 107 $.each($(".aws-big-number[data-number]"), function (i, val) { 108 109 if ($(val).hasClass("active")) { 110 return true 111 } 112 113 let number = parseFloat($(val).data("number")) 114 115 if ($(val).isInViewport()) { 116 117 $(val).addClass("active") 118 119 let $val = $(val) 120 let index = i 121 let type = $(val).data("ntype") 122 let increase = 100 123 124 if (number > 5000) { 125 increase = 1000 126 } else if (number > 2000) { 127 increase = 250 128 } else if (number > 1000) { 129 increase = 200 130 } else if (number < 100) { 131 increase = 1 132 } 133 134 let timeout = 25 135 136 let counter = 1 137 138 big_numbers_intervals[i] = setInterval(function () { 139 140 let current_value = $val.text() 141 142 if (type === "float") { 143 current_value = parseFloat($(val).text().replace(",", ".")) 144 increase = 0.5 145 } else { 146 current_value = parseInt($val.text().replace(".", "")) 147 } 148 149 let future_value = current_value + increase 150 151 if (future_value <= number) { 152 153 if (type === "float") { 154 155 $val.text($.number(future_value, 1, ',', ".")) 156 157 } else { 158 $val.text($.number(future_value, 0, ",", ".")) 159 } 160 161 if ($(val).hasClass("percentage")) { 162 $val.text($val.text() + "%") 163 } 164 165 } else if (increase > 100) { 166 increase = 100 167 } else if (increase === 100) { 168 increase = 10 169 } else if (increase === 10) { 170 increase = 1 171 } else if (increase === 0.5) { 172 increase = 0.1 173 } else { 174 175 176 } 177 178 future_value = current_value + increase 179 180 if (counter > 100 || parseFloat(future_value) >= number) { 181 182 183 if (type === "float") { 184 $val.text($.number(number, 1, ",", ".")) 185 } else { 186 $val.text($.number(number, 0, ",", ".")) 187 } 188 189 if ($(val).hasClass("percentage")) { 190 $val.text($val.text() + "%") 191 } 192 193 clearInterval(big_numbers_intervals[index]) 194 195 } 196 197 counter++ 198 199 }, timeout) 200 201 } 202 203 }) 204 205 } 206 207 function init_pdf_injection(button) { 208 209 button.html("Loading") 210 211 $("body").append("<div id='pdf-download-container'></div>") 212 213 let pdf_container = $("#pdf-download-container") 214 // Off-screen but with explicit width so canvases get non-zero CSS dimensions. 215 // Charts from closed accordions need this to render without ChartDeferred blocking. 216 pdf_container.css({position: "fixed", top: 0, left: "-9999px", width: "900px"}) 217 pdf_container.append($(".aws-intro-block").html()) 218 pdf_container.find(".wp-block-group.has-primary-background-color").remove() 219 220 let selector = ".wp-block-aws-blocks-aws-accordions-group .aws-collapse-block" 221 222 if ($(selector).length < 1) { 223 selector = ".wp-block-aws-blocks-aws-accordions .aws-collapse-block" 224 } 225 226 $.each($(selector), function (i, val) { 227 228 let title = "<h2>" + $(".title-header h3", $(val)).text() + "</h2>" 229 let body = $(".body-container", $(val)).html() 230 let collapse = "<div class='aws-collapse-block open' style='background-color: white;'>" + title + body + "</div>" 231 232 $.each($("mark", collapse), function (i, val) { 233 234 if ($(val).attr("class") === "has-inline-color has-secondary-color") { 235 $(val).closest("p").addClass("titlestyle") 236 } 237 238 }) 239 240 pdf_container.append(collapse) 241 242 }) 243 244 pdf_container.find("img.graph-64-render").show() 245 pdf_container.find("canvas").remove() 246 247 pdf_container.trigger("init_charts_event") 248 249 let delay = setInterval(function () { 250 251 download_pdf(button) 252 clearInterval(delay) 253 254 }, 2500) 255 256 return true 257 258 } 259 260 function download_pdf(button) { 261 262 let body_cloned = $("#pdf-download-container") 263 264 $.each($("mark", body_cloned), function (mi, mval) { 265 266 let mark_class = $(mval).attr("class") 267 268 $(mval).closest("p").html( $(mval).html() ).addClass(mark_class) 269 270 }) 271 272 let footnotes = $("#aws-footnotes-container").clone() 273 274 $("#pdf-download-container").append(footnotes) 275 276 let fn = $("#pdf-download-container").find(".fn") 277 278 $.each(fn, function(i, val) { 279 $(val).text(i+1 + " ") 280 }) 281 282 let html = $("#pdf-download-container").html() 283 284 let dataUriCount = (html.match(/src="data:image/g) || []).length 285 let graphRenderCount = (html.match(/class="graph-64-render"/g) || []).length 286 console.log("[download_pdf] dataUri imgs=" + dataUriCount + " graph-64-render=" + graphRenderCount) 287 288 let data = { 289 action: "kib_download_page", 290 page: ChartsJS.post_id, 291 html: html, 292 } 293
294 console.log("FLAG DOWNLOAD theme v2") 295 296 $.post(ChartsJS.ajax_url, data, function (res) { 297 298 console.log(res) 299 300 let url = res.file_url 301 302 $("body").append("<a id='auto-click-download' target='_blank' href='" + url + "'>.</a>"); 303 $("#auto-click-download")[0].click(); 304 305 let loop = setInterval(function () { 306 307 button.html(download_button_content) 308 $("#auto-click-download").remove() 309 //$("#pdf-download-container").remove() 310 clearInterval(loop) 311 312 }, delay_time) 313 314 }, "json") 315 316 } 317 318 function toDataURL(element) { 319 320 const img = element; 321// Create a canvas element 322 const canvas = document.createElement('canvas'); 323// Set the canvas dimensions to the image dimensions 324 canvas.width = img.width; 325 canvas.height = img.height; 326// Get the canvas context 327 const ctx = canvas.getContext('2d'); 328// Draw the image on the canvas 329 ctx.drawImage(img, 0, 0); 330// Get the Base64-encoded data 331 return canvas.toDataURL(); 332 } 333 334 function init_download_all_pages(button) { 335 336 const data = { 337 action: "kib_download_all_pages" 338 } 339 340 $.post(ChartsJS.ajax_url, data, function (res) { 341 342 $("body").append("<a id='auto-click-download' target='_blank' href='" + res + "'>.</a>"); 343 $("#auto-click-download")[0].click(); 344 345 }) 346 347 } 348 349 350 $.fn.isInViewport = function () { 351 352 var elementTop = $(this).offset().top; 353 var elementBottom = elementTop + $(this).outerHeight(); 354 355 var viewportTop = $(window).scrollTop(); 356 var viewportBottom = viewportTop + $(window).height(); 357 358 return elementBottom > viewportTop && elementTop < viewportBottom; 359 360 }; 361 362 $(".toggle-interview a.wp-element-button").on("click", function (e) { 363 e.preventDefault(); 364 365 // Toggle the interview block 366 $(".kib-hidden-interview").slideToggle(); 367 368 // Change button text 369 const $label = $(this).find("strong"); 370 if ($label.text().trim() === "BEKIJK HET INTERVIEW") { 371 $label.text("VERBERG HET INTERVIEW"); 372 } else { 373 $label.text("BEKIJK HET INTERVIEW"); 374 } 375 }); 376 377})(jQuery);
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.