1jQuery(document).ready(function($) { 2 $( "body" ).on( "click","a, a span", function() { 3 //if ($this) a:not(.cart-block--link__expand) 4 console.log($(this)); 5 if($(this).is('.cart-block--link__expand,.cart-block--summary__count,.pure-img,.cart-block--summary__icon')) { 6 return; 7 } 8 else { 9 $("#block-zeropointwb-spinner").show(); 10 setTimeout(function() { 11 $('#block-zeropointwb-spinner').fadeOut('fast'); 12 }, 7000); 13 } 14 15 }); 16 17 // ACCORDION MENU sidebar 18 // click on the span, toggle visibility of sibling .menu with slide animation 19 $( "body" ).on( "click", "#sidebar-left .menu-item span", function() { 20 $(this).toggleClass('active'); 21 $(this).next().slideToggle(); 22 }); 23 24 // MOBILE MENU 25 $( "body" ).on( "click", "#menuToggle", function() { 26 $('#block-zeropointwb-sidebarmenuenglish').toggleClass('mobile-active'); 27 28 }); 29 30 // CATEGORY PAGE COLUMN 31 if ($('.ccol-Right').length) { $('.view-category-page .view-grouping').addClass('wb-col2');} 32 // Chat Bot 33 34 /******************/ 35 /*** START CHAT ***/ 36 /******************/ 37 38 39 // set visitor name 40 let $userName = "Tom"; 41 42 // start chatbox 43 $("#form-start").on("submit", (event) => { 44 event.preventDefault(); 45 $userName = $("#username").val(); 46 $("#landing").slideUp(300); 47 setTimeout(() => { 48 $("#start-chat").html("Continue chat"); 49 $("#send").click(); 50 $("#message").removeClass("starting"); 51 52 }, 300); 53 }); 54 55 56 57 58 /*****************/ 59 /*** USER CHAT ***/ 60 /*****************/ 61 62 63 // Post a message to the board 64 function $postMessage() { 65 $("#message").find("br").remove(); 66 let $message = $("#message").html().trim(); // get text from text box 67 $message = $message.replace(/<div>/, "<br>").replace(/<div>/g, "").replace(/<\/div>/g, "<br>").replace(/<br>/g, " ").trim(); 68 if ($message) { // if text is not empty 69 const html = `<div class="post post-user">${$message + timeStamp()}</span></div>`; // convert post to html 70 $("#message-board").append(html); // add post to board 71 $scrollDown(); // stay at bottom of chat 72 botReply($message); 73 }; 74 $("#message").empty(); 75 }; 76 77 // Chat input 78 $("#message").on("keyup", (event) => { 79 if (event.which === 13) $postMessage(); // Use enter to send 80 }).on("focus", () => { 81 $("#message").addClass("focus"); 82 }).on("blur", () => { 83 $("#message").removeClass("focus"); 84 }); 85 $("#send").on("click", $postMessage); 86 87 88 89 90 /**********************/ 91 /*** AUTO REPLY BOT ***/ 92 /**********************/ 93 94 95 function botReply(userMessage) { 96 const reply = generateReply(userMessage); 97 if (typeof reply === "string") postBotReply(reply); 98 else reply.forEach((str) => postBotReply(str)); 99 }; 100 101 function generateReply(userMessage) { 102 const message = userMessage.toLowerCase(); 103 let reply = [`Sorry, I don't understand you.`, `Please try again`]; 104 105 // Generate some different replies 106 if (/^hi$| hi|^hell?o|^howdy|^hoi|^hey|^ola/.test(message)) reply = [`Hi ${$userName}`, `What can I do for you?`]; 107 else if (/initialstart/.test(message)) reply = [`Hi ${$userName}`, `Please start typing and I'll do my best to respond.`,'I am only a simple chat bot.']; 108 else if (/how are you/.test(message)) reply = [`I am find, thanks.`, `Oops, that's a typo, I meant to say I am fine.`]; 109 else if (/test/.test(message)) reply = [`Ok`, `Feel free to test as much as you want`]; 110 else if (/help|sos|emergency|support/.test(message)) reply = [`I am here to help.`, `What seems to be the problem?`]; 111 else if (/cost|how much|price/.test(message)) reply = [`The event costs $50 per person.`, `<a href="https://cnn.com">Click here to buy tickets</a>`]; 112 else if (/class\=\"fa/.test(message)) reply = [`I see you've found the smileys`, `Cool! <span class="far fa-grin-beam fa-2x"></span>`, `Did you need something?`]; 113 else if (/how|what|why/.test(message)) reply = userMessage + " what?"; 114 else if (/^huh+|boring|lame|wtf|pff/.test(message)) reply = [`<span class="far fa-dizzy fa-2x"></span>`, `I'm sorry you feel that way`, `How can I make it better?`]; 115 else if (/bye|ciao|adieu|salu/.test(message)) reply = [`Ok, bye :)`]; 116 117 return reply; 118 }; 119 120 function postBotReply(reply) { 121 const html = `<div class="post post-bot">${reply + timeStamp()}</div>`; 122 const timeTyping = 500 + Math.floor(Math.random() * 2000); 123 $("#message-board").append(html); 124 $scrollDown(); 125 }; 126 127 128 129 /******************/
130 /*** TIMESTAMPS ***/ 131 /******************/ 132 133 134 function timeStamp() { 135 const timestamp = new Date(); 136 const hours = timestamp.getHours(); 137 let minutes = timestamp.getMinutes(); 138 if (minutes < 10) minutes = "0" + minutes; 139 const html = `<span class="timestamp">${hours}:${minutes}</span>`; 140 return html; 141 }; 142 143 144 145 146 /***************/ 147 /*** CHAT UI ***/ 148 /***************/ 149 150 151 // Back arrow button 152 $("#back-button").on("click", () => { 153 $("#landing").show(); 154 }); 155 156 157 // Menu - navigation 158 $("#nav-icon").on("click", () => { 159 $("#nav-container").show(); 160 }); 161 162 $("#nav-container").on("mouseleave", () => { 163 $("#nav-container").hide(); 164 }); 165 166 $(".nav-link").on("click", () => { 167 $("#nav-container").slideToggle(200); 168 }); 169 170 // Clear history 171 $("#clear-history").on("click", () => { 172 $("#message-board").empty(); 173 $("#message").empty(); 174 }); 175 176 // Sign out 177 $("#sign-out").on("click", () => { 178 $("#message-board").empty(); 179 $("#message").empty(); 180 $("#landing").show(); 181 $("#username").val(""); 182 $("#start-chat").html("Start chat"); 183 }); 184 185 186 187 188 /*********************/ 189 /*** SCROLL TO END ***/ 190 /*********************/ 191 192 193 function $scrollDown() { 194 const $container = $("#message-board"); 195 const $maxHeight = $container.height(); 196 const $scrollHeight = $container[0].scrollHeight; 197 if ($scrollHeight > $maxHeight) $container.scrollTop($scrollHeight); 198 } 199 200 201 202 203 /***************/ 204 /*** EMOIJIS ***/ 205 /***************/ 206 207 208 // toggle emoijis 209 $("#emoi").on("click", () => { 210 $("#emoijis").slideToggle(300); 211 $("#emoi").toggleClass("fa fa-grin far fa-chevron-down"); 212 }); 213 214 // add emoiji to message 215 $(".smiley").on("click", (event) => { 216 const $smiley = $(event.currentTarget).clone().contents().addClass("fa-lg"); 217 $("#message").append($smiley); 218 $("#message").select(); // ==> BUG: message field not selected after adding smiley !! 219 }); 220 221 222 223 224 // Game Board 225 var csrfToken = 0; 226 function getCsrfToken(callback) { 227 jQuery 228 .get(Drupal.url('session/token')) 229 .done(function (data) { 230 var csrfToken = data; 231 console.log(data); 232 callback(csrfToken); 233 }); 234 } 235 function getNid() { 236 var nid = 0; 237 nid = $('body') 238 239 } 240 function patchNode(csrfToken, node) { 241 var nid = 0; 242 var classes = $('body').attr('class'); 243 if (classes.match(/node\-\d+/gi)) { 244 var nid = classes.match(/node\-\d+/gi)[0].replace('node-', ''); 245 } 246 console.log(nid+' '+csrfToken+' '+JSON.stringify(node)); 247 jQuery.ajax({ 248 url: 'https://jessesteed.com/node/'+nid+'?_format=hal_json', 249 method: 'PATCH', 250 headers: { 251 'Content-Type': 'application/hal+json', 252 'X-CSRF-Token': csrfToken 253 }, 254 data: JSON.stringify(node), 255 success: function (node) { 256 console.log(node); 257 } 258 }); 259 } 260 function getNode(csrfToken, nid, callback) { 261 262 console.log(nid+' '+csrfToken); 263 jQuery.ajax({ 264 url: 'https://jessesteed.com/node/'+nid+'?_format=hal_json', 265 method: 'GET', 266 headers: { 267 'Content-Type': 'application/hal+json', 268 'X-CSRF-Token': csrfToken 269 }, 270 271 success: function (node) { 272 console.log(node); 273 console.log(node.title); 274 callback(node); 275 } 276 }); 277 } 278 279 var newNode = { 280 _links: { 281 type: { 282 href: 'https://jessesteed.com/rest/type/node/game_board' 283 } 284 }, 285 type: 'game_board', 286 body: [{ 287 value: $('.field--name-body').html().toString(), 288 format: 'full_html' 289 }] 290 291 }; 292 293 var boardChanged = false; 294 var bodyUpdated = 0; 295 $('#click').on( "click", function() { 296 var bodyUpdated = 297 getCsrfToken(function (csrfToken) { 298 patchNode(csrfToken, newNode); 299 }); 300 console.log(bodyUpdated); 301 }); 302 303 if (boardChanged === true) { 304 var bodyUpdated = $('.field--name-body').html(); 305 getCsrfToken(function (csrfToken) { 306 patchNode(csrfToken, newNode); 307 }); 308 } 309 310 311 312 // VIDEOS 313 314 //When video ends, show the loop video, and start it, keep it looping, hide controls. Show the video references overlay the loop content. 315 //$('.field--name-field-video video') 316 $('.field--name-field-video-loop').toggleClass('vswap'); // get it started
317 videoposter($('.field--name-field-video-loop video')); 318 videoposter($('.field--name-field-video video'));//.attr('poster',$('.field--name-field-poster img').attr('src')); 319 //$('.field--name-field-video video').attr({'style':'visibility:hidden;','onplay':'var s=this;setTimeout(function(){s.style.visibility="visible";},100);"'}); 320 function videoposter(video) { 321 $(video).attr('poster',$(video).parents('.media').find('.field--name-field-poster img').attr('src')); 322 } 323 324 function runVideo() { 325 var videoElement = $('.field--name-field-video video'); // Assuming your video has the ID 'myVideo' 326 videoElement.removeAttr("controls"); // remove the controls 327 // add custom controls so the overlay will work when full screen 328 videoElement.after("<div class='vidcontrols'><div class='vplay'>play</div><div class='vpause'>pause</div></div>"); 329 //$('.field--name-field-video').show(); 330 $('.field--name-field-video-loop.vswap').toggleClass('vswap');//.hide(); 331 console.log('vswap toggled'); 332 $('.field--name-field-video-reference').hide(); 333 334 videoElement.on('ended', function() { 335 prepRef(); 336 337 console.log('Video has ended!'); 338 339 // Get the parent element by its class name (assuming it's a unique element) 340 const parentElement = document.querySelector('.field--name-field-video-loop'); 341 342 // Get the video element that is a descendant of the parent 343 const videoLoop = parentElement ? parentElement.querySelector('video') : null; 344 345 // Example usage: play the video 346 if (videoLoop) { 347 videoLoop.currentTime = 0.034; 348 } 349 videoLoop.addEventListener('timeupdate', function() { 350 // Seek back to near the start when it's close to the end 351 if (this.currentTime >= this.duration - 0.1) { // 0.1s margin 352 this.currentTime = 0.034; 353 this.play(); 354 } 355 }); 356 //$('.field--name-field-video-loop video').attr('loop','loop'); 357 $('.field--name-field-video-loop video').removeAttr('controls'); 358 359 $('.field--name-field-video-loop video').get(0).play(); 360 setTimeout( 361 function() 362 { 363 $('.field--name-field-video-loop').toggleClass('vswap');//.show(); 364 }, 500); 365 366 console.log('vswap toggled'); 367 var vhe = $(videoElement).height(); 368 $('.field--name-field-video-reference,.video-history').css('height',vhe); 369 $('.field--name-field-video-reference').show(); 370 //$('.field--name-field-video').hide(); 371 }); 372 } 373 runVideo(); 374 //add the $('.video-history') to the body field so the history can build during this viewing 375 $('.node__content').append("<div class='video-history not-yet' style='display:none;'><div class='vh-items'></div><div class='back'>back</div><div class='next'>next</div></div>"); 376 377 function prepRef() { 378 $('.field--name-field-video-reference .field--name-node-title h2').each(function(){ 379 $(this).after("<div class='vidref'>"+$(this).html()+"</div>"); 380 $(this).remove(); 381 }); 382 $('.video-history .vh-items').append('<div class="vh-item new"></div>'); 383 $('.field--name-field-video-reference').clone().appendTo('.video-history .vh-items .new'); 384 $('.video-history .vh-items .new .field--name-field-video-reference').removeClass('field--name-field-video-reference'); 385 $('.video-history .vh-items .new').removeClass('new'); 386 $('.not-yet').removeClass('not-yet').addClass('ready'); 387 } 388 // custom video controls 389 $( "body" ).on( "click", ".vplay", function() { 390 $(this).parent().prev().get(0).play(); 391 }); 392 $( "body" ).on( "click", ".vpause", function() { 393 $(this).parent().prev().get(0).pause(); 394 }); 395 // click the video to toggle play/pause 396 $('body').on('click', 'video', function() { 397 // Get the native HTML video element from the jQuery object 398 var videoEl = $(this).get(0); 399 400 // Check if the video is currently paused 401 if (videoEl.paused) { // If paused, play the video 402 videoEl.play(); 403 // hide the overlay 404 $('.video-history').fadeOut(); 405 } else { // If playing, pause the video 406 videoEl.pause(); 407 $('.video-history.ready').fadeIn(); 408 } 409 }); 410 411 // click the vidref and load the next video node 412 $( "body" ).on( "click", ".field--name-field-video-reference .vidref, .video-history .vidref", function() { 413 var nid = 0; 414 var classes = $(this).parents('.node--view-mode-label-plus').find('.node-value').attr('class'); 415 if (classes.match(/n\-\d+/gi)) { 416 var nid = classes.match(/n\-\d+/gi)[0].replace('n-', ''); 417 } 418 //var fullHref = $(this).attr('data-href'); 419 //var parts = fullHref.split('/'); // Splits by '/' 420 //var nid = parts[2]; 421 //nid = 422 console.log(nid); 423 424 // test 425 jQuery.ajax({ 426 url: '/restviewnode/'+nid+'?_format=hal_json', 427 method: 'GET', 428 headers: { 429 'Content-Type': 'application/hal+json', 430 'X-CSRF-Token': csrfToken 431 }, 432 433 success: function (node) { 434 console.log(node); 435 //console.log(node.title); 436 parseVideo(node); 437 } 438 }); 439 440 441 /*getCsrfToken(function (csrfToken) { 442 getNode(csrfToken, nid, parseVideo); 443 })*/; 444 445 }); 446 447 function parseVideo(node) { 448 var vtitle = node['0']['title']; 449 var vvideo = node['0']['field_video']; 450 var loopvideo = node['0']['field_video_loop']; 451 var refvideo = node['0']['field_video_reference']; 452 //var vposter = node['0']['field_poster']; 453 454 //$('.field--name-field-poster').html(vposter); 455 $('.field--name-field-video').html(vvideo);
456 videoposter($('.field--name-field-video video')); 457 $('.field--name-field-video video').get(0).play(); 458 $('.video-history').fadeOut(); 459 460 setTimeout( 461 function() 462 { 463 runVideo(); 464 $('.field--name-field-video-loop').html(loopvideo); 465 $('.field--name-field-video-reference').html(refvideo); 466 }, 700); 467 } 468 469 //$('.field--name-field-video-loop video') 470 //User clicks a video reference 471 472 //Load the video, replace the page content, update the back button 473 function services(controller, url, nid, params, callback) { 474 var http = new XMLHttpRequest(); 475 http.open(controller, url, true); 476 //Send the proper header information along with the request 477 http.setRequestHeader('Content-type', 'application/json'); 478 http.setRequestHeader('X-CSRF-Token', csrf); 479 http.onreadystatechange = function() { //Call a function when the state changes. 480 if (http.readyState == 4 && http.status == 200 && (http.responseText)) { 481 var p = strip(http.responseText).trim(); 482 //var json = JSON.parse(p); 483 //console.log(p); 484 callback(p); 485 } 486 } 487 var json = JSON.stringify(params); 488 //console.log(json); 489 http.send(json); 490 } 491 function strip(html) { 492 var tmp = document.createElement("DIV"); 493 tmp.innerHTML = html; 494 return tmp.textContent || tmp.innerText || ""; 495 } 496 497}); 498
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.