1var user = null; 2 3// ESC amagem menus i buscador. 4document.addEventListener('keyup', function(e) { 5 if (e.key === 'Escape') { 6 const overlaySearch = document.querySelector('.overlay-search'); 7 const overlay = document.getElementById('navegation-site'); 8 9 if (overlaySearch) overlaySearch.classList.remove('in'); 10 if (overlay) overlay.classList.remove('in'); 11 } 12}); 13 14 /////////////////////////////////////// 15 16 17 /* ************************* SERVEIS PLEGAT ************************* */ 18/** 19 $('.page-template-template-home #templateeltemps, .page-template-template-home #farmacies, .page-template-template-home #classificats, .page-template-template-home #defuncions').addClass("plegat"); 20 //console.log("plegat"); 21 22 $(".el-tempss h2 a:first-child").click(function(e) { 23 e.preventDefault(); 24 25 if ( $('#templateeltemps').hasClass( "plegat" ) ) { 26 $( '#templateeltemps' ).removeClass("plegat"); 27 $( '#farmacies' ).addClass("plegat"); 28 $( '#classificats' ).addClass("plegat"); 29 $( '#defuncions' ).addClass("plegat"); 30 } else { 31 $( '#templateeltemps' ).addClass("plegat"); 32 } 33 }); 34 35 $(".farmacies-guardia h2 a:first-child").click(function(e) { 36 e.preventDefault(); 37 38 if ( $('#farmacies').hasClass( "plegat" ) ) { 39 $( '#templateeltemps' ).addClass("plegat"); 40 $( '#farmacies' ).removeClass("plegat"); 41 $( '#classificats' ).addClass("plegat"); 42 $( '#defuncions' ).addClass("plegat"); 43 } else { 44 $( '#farmacies' ).addClass("plegat"); 45 } 46 }); 47 48 $(".classificats h2 a:first-child").click(function(e) { 49 e.preventDefault(); 50 51 if ( $('#classificats').hasClass( "plegat" ) ) { 52 $( '#templateeltemps' ).addClass("plegat"); 53 $( '#farmacies' ).addClass("plegat"); 54 $( '#classificats' ).removeClass("plegat"); 55 $( '#defuncions' ).addClass("plegat"); 56 } else { 57 $( '#classificats' ).addClass("plegat"); 58 } 59 }); 60 61 $(".defuncions-list h2 a:first-child").click(function(e) { 62 e.preventDefault(); 63 64 if ( $('#defuncions').hasClass( "plegat" ) ) { 65 $( '#templateeltemps' ).addClass("plegat"); 66 $( '#farmacies' ).addClass("plegat"); 67 $( '#classificats' ).addClass("plegat"); 68 $( '#defuncions' ).removeClass("plegat"); 69 } else { 70 $( '#defuncions' ).addClass("plegat"); 71 } 72 }); 73**/ 74 /* ************************* LLLISTAT EL GRUP PLEGAT ************************* */ 75/** 76 $(".9club h2").click(function(e) { 77 e.preventDefault(); 78 79 if ( $('#el9club').hasClass( "plegat" ) ) { 80 $( '#el9club' ).removeClass("plegat"); 81 $( '#el9fm' ).addClass("plegat"); 82 $( '#sidebarblogosfera' ).addClass("plegat"); 83 $( '#PC-buttons' ).addClass("plegat"); 84 } else { 85 $( '#el9club' ).addClass("plegat"); 86 } 87 }); 88 89 $(".9fm h2").click(function(e) { 90 e.preventDefault(); 91 92 if ( $('#el9fm').hasClass( "plegat" ) ) { 93 $( '#el9club' ).addClass("plegat"); 94 $( '#el9fm' ).removeClass("plegat"); 95 $( '#sidebarblogosfera' ).addClass("plegat"); 96 $( '#PC-buttons' ).addClass("plegat"); 97 } else { 98 $( '#el9fm' ).addClass("plegat"); 99 } 100 }); 101 102 } 103}); 104**/ 105 106 107 108// Scroll Down HEADER ANIMATION 109document.addEventListener('DOMContentLoaded', function () { 110 const header = document.querySelector('header.header'); 111 const smallerElements = document.querySelectorAll('.smaller'); 112 113 if (!header) return; 114 115 const headerTop = header.offsetTop; 116 117 window.addEventListener('scroll', function () { 118 if (window.scrollY > headerTop + 80) { 119 smallerElements.forEach(el => el.classList.add('in')); 120 } else { 121 smallerElements.forEach(el => el.classList.remove('in')); 122 } 123 }); 124}); 125 126 127/* /// PRINT FUNCTION ////// */ 128function printFunction() { 129 window.print(); 130} 131 132/** 133var owl = $("#owl-demo"); 134 135 if (owl.length) { 136 owl.owlCarousel({ 137 items : 4, 138 itemsDesktop : [1199,4], 139 itemsDesktopSmall : [979,2], 140 itemsTablet: [768,1], 141 navigation: false, 142 // loop: true, 143 navigationText: [ 144 "<span class='icon9fm-angle-left'></span>", 145 "<span class='icon9fm-angle-right'></span>" 146 ] 147 }); 148 149 // Custom Navigation Events 150 $(".left-arrow").click(function(e){ 151 e.preventDefault(); 152 owl.trigger('owl.prev'); 153 }); 154 155 $(".right-arrow").click(function(e){ 156 e.preventDefault(); 157 owl.trigger('owl.next'); 158 }); 159 } 160 161 var owl_programacio = $("#owl_programacio"); 162 163 if (owl_programacio.length) { 164 owl_programacio.owlCarousel({ 165 items : 3, 166 itemsDesktop : [1199,4], 167 itemsDesktopSmall : [979,2], 168 itemsTablet: [768,1], 169 navigation: false, 170 // loop: true, 171 navigationText: [ 172 "<span class='icon9fm-angle-left'></span>", 173 "<span class='icon9fm-angle-right'></span>" 174 ] 175 }); 176 177 // Custom Navigation Events 178 $(".graella .left-arrow").click(function(e){ 179 e.preventDefault(); 180 owl_programacio.trigger('owl.prev'); 181 }); 182 183 $(".graella .right-arrow").click(function(e){ 184 e.preventDefault(); 185 owl_programacio.trigger('owl.next'); 186 }); 187 } 188/* ////////////////////////// 189$('iframe').load(function() { 190 $(this).contents().find('img').css({with: '100%', 'height': 'auto'}); 191}) 192*/ 193 194 195 196var TemplateElTemps = { 197 198 data: function () { 199 return { 200 'ciutat' : null, 201 'forecast' : null, 202 'ciutat_buscada': null, 203 'previsio' : null, 204 'actual': null, 205 'icons': null, 206 'diesSetmana' : ['Diumenge', 'Dilluns', 'Dimarts', 'Dimecres', 'Dijous', 'Divendres', 'Dissabte', 'Diumenge' ], 207 'loading': false, 208 'loaded': false 209 } 210 }, 211 212 ready: function() { 213console.log('aquest'); 214 if (! this.ciutat) { 215 this.getGeolocation(); 216 } 217 console.log(this.ciutat); 218 this.loadWeather(); 219 }, 220 221 methods: { 222 getGeolocation: function() { 223 if ($("body").hasClass("osona-ripolles")) { 224 this.ciutat = 'Vic'; 225 } else { 226 this.ciutat = 'Granollers'; 227 } 228 this.ciutat_buscada = this.ciutat; 229 }, 230 231 showDate: function(data) { 232 var d = new Date(data); 233 var hours = d.getHours(); 234 var minutes = d.getMinutes(); 235 if (hours < 10) hours = '0' + hours; 236 if (minutes < 10) minutes = '0' + minutes; 237 return hours + ':' + minutes; 238 }, 239 showDay: function(data) { 240 var d = new Date(data); 241 var day = d.getDay(); 242 return day; 243 }, 244 245 loadWeather: function() { 246 var that = this; 247 jQuery( window ).scroll(function() { 248 249 if (! that.loaded && (jQuery(window).scrollTop() + jQuery(window).height() > jQuery('#templateeltemps').offset().top)) 250 { 251 that.loaded = true; 252 that.getWeatherForCity(); 253 } 254 }); 255 256 }, 257 changeCity: function() { 258 console.log(this.ciutat); 259 console.log(this.loaded); 260 if (this.loaded) 261 this.getWeatherForCity(); 262 }, 263 getWeatherForCity: function() { 264 265 if (this.ciutat) { 266 this.ciutat_buscada = this.ciutat; 267 this.loading = true;
268 //var geoAPI = 'https://maps.googleapis.com/maps/api/geocode/json?address=' + this.ciutat + '&key=AIzaSyDPYtRNSQhvIsoNGiQlAZ4cWz-PRKXEC2s&language=ca'; 269 //var geoAPI = 'https://maps.googleapis.com/maps/api/geocode/json?address=' + this.ciutat + '&key=AIzaSyCLDMZhQsg4F2GcxrVrojk8Mrehc1qKG-4&language=ca'; 270 var geoAPI = 'https://api.openweathermap.org/data/2.5/weather?q=' + this.ciutat + ',es&units=metric&appid=dc788df211a022e21bfc979f61ca4d81&lang=ca'; 271 console.log(geoAPI); 272 console.log('geoAPI'); 273 274 var that = this; 275 276 this.$http.get(geoAPI, {credentials: false}).then(function(response) { 277 response = response.json(); 278 279 /* 280 var lat = response.results[0].geometry.location.lat; 281 var lng = response.results[0].geometry.location.lng; 282 */ 283 var lat = response.coord.lat; 284 var lng = response.coord.lng; 285 286 //that.ciutat = response.results[0].address_components[0].long_name; 287 //that.ciutat = response.name; 288 289 that.previsio = response; 290 291 if (document.URL.split('/')[3] == "el-temps") 292 this.getForecastsForCity(); 293 /*jQuery.ajax({ 294 url : "/wp-admin/admin-ajax.php", 295 type : 'post', 296 dataType: 'json', 297 data : { 298 action : 'get_temps', 299 lat : lat, 300 lng : lng 301 }, 302 success : function( data ) { 303 console.log('c'); 304 console.log(data); 305 that.previsio = data; 306 that.loading = false; 307 }, 308 error: function(e) { 309 console.log('d'); 310 console.log(e); 311 } 312 });*/ 313 //$.get( geoAPI, function( data ) { 314 this.loading = false; 315 //}); 316 }) 317 .catch(function (error) { 318 console.log('Promise catch: ' + error); 319 //alert('No hem trobat la població sol·licitada'); 320 this.loading = false; 321 }); 322 } 323 }, 324 getForecastsForCity: function() { 325 326 if (this.previsio){ 327 328 var that = this; 329 console.log('ee'); 330 //this.$http.get("https://api.openweathermap.org/data/2.5/onecall?lat="+ this.previsio.coord.lat +"&lon="+ this.previsio.coord.lon +"&exclude=hourly&units=metric&appid=5e1f519cd3d07b383ad8f272e2ec53e2&lang=ca", {credentials: false}) 331 this.$http.get("https://api.openweathermap.org/data/2.5/forecast?lat="+ this.previsio.coord.lat +"&lon="+ this.previsio.coord.lon +"&appid=f4a10f0e28e414739a5a0db02f37e4c5&units=metric") 332 .then(function(response) { 333 response = response.json(); 334 335 that.forecast = response.list; 336 console.log(that.forecast); 337 }); 338 339 } 340 }, 341 searchCity: function() { 342 this.getWeatherForCity(); 343 }, 344 345 setWeatherIcon: function(code) { 346 var icons = { 347 'clear-day': 'day-sunny', 348 'clear-night': 'night-clear', 349 'rain': 'rain', 350 'snow': 'snow', 351 'sleet': 'sleet', 352 'wind': 'strong-wind', 353 'fog': 'fog', 354 'cloudy': 'cloudy', 355 'partly-cloudy-day': 'day-cloudy', 356 'partly-cloudy-night': 'night-cloudy', 357 'hail': 'hail', 358 'thunderstorm': 'thunderstorm', 359 'tornado': 'tornado', 360 }; 361 362 return '<i class="wi wi-' + icons[code] + '"></i>'; 363 }, 364 } 365}; 366 367/**new Vue({ 368 el: '#templateeltemps', 369 components: { 370 'template-el-temps': TemplateElTemps 371 } 372});**/ 373// register 374//Vue.component('external-content', ExternalContent); 375//Vue.component('sidebar-blogosfera', SidebarBlogosfera); 376//Vue.component('sidebar-agenda', SidebarAgenda); 377//Vue.component('template-el-temps', TemplateElTemps); 378 379// create a root instance 380//new Vue({ 381// el: '#main' 382//}) 383 384/***** EXTERNAL CONTENT VUEJS ELEMENT ****/ 385var ExternalContent = { 386 template: '<section class="articles-petits">' 387 + '<div class="col-md-4 col-sm-4 col-6 item article-imatge" v-for="item in content">' 388 + '<a class="border-bottom" href="{{ item.url }}">' 389 + '<figure class="row" style="background-image: url({{ item.urlDestacada }});-webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover;background-repeat: no-repeat; background-position: 50% 50%;position:relative">' 390 + '<div class="video-hover" v-if="video == 1"><i class="icon-play" aria-hidden="true"></i></div>' 391 + '</figure>' 392 + '<h1>{{ item.nom }}</h1>' 393 + '</a>' 394 + '</div></section>', 395 396 props: ['title', 'apiUrl', 'video'], 397 398 data: function () { 399 return { 400 content: '', 401 loading: true, 402 } 403 }, 404 405 ready: function() { 406 this.$http.get(this.apiUrl).then(function(response) { 407 this.content = response.json(); 408 }); 409 } 410} 411 412 413 414/** Hemeroteca **/ 415 416var Hemeroteca = { 417 418 data: function () { 419 return { 420 user: '', 421 loading: false, 422 diari: '', 423 } 424 }, 425 426 methods: { 427 descarrega : function() { 428 //url = this.element; 429 console.log('asasasa'); 430 431 this.loading = true; 432 console.log(this.diari); 433 var that = this; 434 if (! user) { 435 window.location.href = 'https://9club.el9nou.cat/osona-ripolles/entra?type=restricted&redirect=' + window.location.href; 436 this.loading = false;
437 return; 438 } 439 440 // $.get({ url: "/wp-json/api/hemeroteca/generar-link?id=" + url + "&fitxer=" + fitxer + "&api_token=" + user.api_token}).done(function(data) { 441 $.get({ url: "/wp-json/api/hemeroteca/generar-link?id=" + this.diari + "&fitxer=" + this.diari + "&api_token=" + user.api_token}).done(function(data) { 442 that.loading = false; 443 console.log(data); 444 if (data.status == 'success') { 445 if (data.url) { 446 //https://el9nou.s3-eu-west-1.amazonaws.com/images/ 447 window.location.href = data.url; 448 } 449 } 450 else { 451 alert(data.message); 452 } 453 }); 454 } 455}, 456} 457/**new Vue({ 458 el: '#hemeroteca', 459 460 components: { 461 'hemeroteca-diari': Hemeroteca 462 } 463});**/ 464 465/***** Comments ****/ 466var Comments = { 467 props: ['site', 'id', 'edicio'], 468 data: function () { 469 return { 470 initialized: false, 471 comments: '', 472 text: '', 473 loading: false, 474 success: '', 475 acting_as: '' 476 } 477 }, 478 479 ready: function() { 480 console.log('edicio'); 481 console.log(this.edicio); 482 var that = this; 483 var loadPosition = $('#comments').offset().top - $(window).height() - 300; 484 $( document ).scroll(function(value) { 485 if (! this.initialized && loadPosition < $(window).scrollTop()) { 486 this.initialized = true; 487 that.getComments(); 488 } 489 }); 490 491 }, 492 methods: { 493 getComments: function() { 494 this.loading = true; 495 this.$http.get('https://9club.el9nou.cat/api/comentaris?site=' + this.site + '&id=' + this.id, {credentials: true}).then(function(response) { 496 this.acting_as = response.json().acting_as; 497 this.comments = response.json().comments; 498 this.loading = false; 499 this.loadingButton = false; 500 }); 501 }, 502 503 anarAComentari: function() { 504 $('html,body').animate({scrollTop: $('#commentform').offset().top}); 505 }, 506 507 enviarComentari: function() { 508 this.loadingButton = true; 509 this.$http.post('https://9club.el9nou.cat/api/comentaris?site=' + this.site + '&id=' + this.id + '&url=' + window.location.href, { 'text' : this.text }, {credentials: true}).then(function(response) { 510 this.comments.push(response.json()); 511 this.success = 'Comentari publicat correctament!'; 512 this.loadingButton = false; 513 this.text = ''; 514 }); 515 } 516 } 517} 518 519/**new Vue({ 520 el: '#comments', 521 522 components: { 523 'comments': Comments 524 }, 525 ready: function() { 526 //this.$http.get('https://blogosfera.el9nou.cat/wp-json/api/ultimes').then(function(response) { 527 // this.content = response.json(); 528 //}); 529 } 530});**/ 531 532 533 534 535/** NoticiaPremium **/ 536 537var NoticiaPremium = { 538 props: ['id', 'categories'], 539 data: function () { 540 return { 541 user: '', 542 loading: false, 543 content: '', 544 } 545 }, 546 547 ready: function() { 548 this.loading = true; 549 var that = this; 550 //console.log(this.id); 551 $.ajaxSetup({ 552 xhrFields: { 553 withCredentials: true 554 } 555 }); 556 557 //var url = "https://9club.el9nou.cat/api/usuari/permisos?pot-premium=1"; 558 559 var that = this; 560 console.log(this.categories); 561 562 var categories = this.categories; 563 if (! categories) 564 categories = []; 565 var categoryEsports = categories.includes(14); 566 567 var baseUrl = "https://9club.el9nou.cat/api/usuari/permisos?pot-premium=1"; 568 569 var url = categoryEsports ? `${baseUrl}&ek0=1` : baseUrl; 570 571 $.ajax({ url: url }).done(function(data) { 572 573 if (data.allowed) 574 { 575 $( "#noticia-premium" ).load( 'https://el9nou.cat/wp-json/api/el9nou/obte-contingut-premium?api_token='
575+ data.user.api_token + '&id=' + that.id + '&subscripcio='+ data.user.subscripcio_id + '&llegides=' + data.user.gratuites_llegides, function( response, status, xhr ) { 576 console.log(data); 577 if ( status == "error" ) { 578 var msg = "Sorry but there was an error: "; 579 $( "#error" ).html( msg + xhr.status + " " + xhr.statusText ); 580 } 581 // ga('send', 'event', 'Noticia Premium', 'llegida', data.user.nom + ' ' + data.user.cognoms ); 582 }); 583 584 585 } 586 else { 587 that.content = false; 588 that.loading = false; 589 } 590 591 }); 592 }, 593} 594/**new Vue({ 595 el: '#noticia-premium', 596 597 components: { 598 'noticia-premium': NoticiaPremium 599 } 600});**/ 601/** 602$(document).ready( function() { 603 $('.farmacia').click( function() { 604 $(this).find('.expanded').slideToggle(); 605 }); 606});**/
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.