Skip to content

Commit

Permalink
chore: merge
Browse files Browse the repository at this point in the history
  • Loading branch information
fkakatie committed Sep 29, 2022
2 parents a335db8 + 3c00020 commit bd30310
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 71 deletions.
57 changes: 22 additions & 35 deletions blocks/header/header.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ header nav {
header nav[aria-expanded=true] {
grid-template: 'hamburger brand' 'sections sections' 'user user' '. .' 'social social';
grid-template-columns: 36px 1fr;
grid-template-rows: var(--nav-height) auto auto 1fr auto;
grid-template-rows: 64px auto auto 1fr auto;
position: fixed;
min-height: 100vh;
width: 70%;
Expand Down Expand Up @@ -99,6 +99,11 @@ header nav .nav-brand.white {
background-color: var(--color-white);
}

header nav .nav-brand > a img {
width: auto;
max-height: var(--nav-height);
}

header nav[aria-expanded=true] .nav-brand a {
left: 10px;
transform: translateY(-50%);
Expand All @@ -116,13 +121,13 @@ header nav[aria-expanded=true] .nav-brand a {
}

header nav .nav-brand > a img {
max-height: unset;
margin: 5px 0;
}

header nav[aria-expanded=false] .nav-brand img {
width: auto;
max-width: unset;
max-height: 50px;
max-width: 220px;
}
}

Expand Down Expand Up @@ -151,7 +156,7 @@ header nav .nav-partners-title {

header .nav-partner-wrapper {
position: relative;
height: 50px;
width: 80px;
}

header nav[aria-expanded=true] .nav-partner-wrapper {
Expand Down Expand Up @@ -179,6 +184,18 @@ header nav .nav-partner img {
}

@media (min-width: 700px) {
header nav .nav-partner-wrapper {
position: relative;
height: 50px;
width: 100%;
}

header nav .nav-partner {
width: auto;
left: 50%;
transform: translateX(-50%);
}

header nav[aria-expanded=false] .nav-partners {
display: block;
position: unset;
Expand Down Expand Up @@ -541,34 +558,6 @@ header nav .nav-user button {
cursor: pointer;
}

header nav .nav-user button[data-status=loading] .icon.icon-user {
/* display: none; */
visibility: hidden;
}

header nav .nav-user button[data-status=loading] .icon.icon-spinner svg {
animation: spinner linear 3s infinite;
opacity: .5;
}

@keyframes spinner {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

header nav .nav-user button[data-status=initialized] .icon.icon-spinner {
display: none;
visibility: hidden;
}

header nav .nav-user button[data-status=initialized] .icon.icon-spinner svg {
animation: unset;
}

header nav[aria-expanded=true] .nav-user button {
display: block;
justify-content: flex-start;
Expand Down Expand Up @@ -603,7 +592,6 @@ header nav .nav-user button .icon.icon-caret::after {
}

header nav[aria-expanded=true] .nav-user button img,
header nav[aria-expanded=true] .nav-user button .icon.icon-spinner,
header nav[aria-expanded=true] .nav-user button .icon.icon-caret {
display: none;
visibility: hidden;
Expand Down Expand Up @@ -632,8 +620,7 @@ header nav .nav-user button img {
}

header nav .nav-user button img,
header nav .nav-user .icon.icon-user svg,
header nav .nav-user .icon.icon-spinner svg {
header nav .nav-user .icon.icon-user svg {
height: 24px;
width: 24px;
}
Expand Down
6 changes: 5 additions & 1 deletion blocks/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
decorateLinkedPictures,
} from '../../scripts/scripts.js';

import { initGigya } from '../../scripts/delayed.js';

/**
* collapses all open nav sections
* @param {Element} sections The container element
Expand Down Expand Up @@ -58,9 +60,11 @@ function setupUser(section) {
</button>`;
} else {
section.innerHTML = `<button id="nav-user-button" class="nav-user-button" data-status="loading">
${icon.outerHTML}<span class="icon icon-spinner"></span><span>${text}</span>
${icon.outerHTML}<span>${text}</span>
</button>`;
}
const button = section.querySelector('button');
button.addEventListener('click', initGigya);
}

function parseCountdown(ms) {
Expand Down
6 changes: 4 additions & 2 deletions blocks/social/social.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readBlockConfig, decorateIcons } from '../../scripts/scripts.js';
import { readBlockConfig, decorateIcons, fetchPlaceholders } from '../../scripts/scripts.js';

const TWITTER_URL = 'https://twitter.com/';

Expand Down Expand Up @@ -93,6 +93,7 @@ function buildTwitterTile(tile, data) {
export default async function decorate(block) {
const config = readBlockConfig(block);
block.textContent = '';
const placeholders = await fetchPlaceholders();

const wrapper = document.createElement('ul');

Expand All @@ -101,7 +102,8 @@ export default async function decorate(block) {
wrapper.append(profilesTile);

// fetch social feed
const resp = await fetch('https://api.massrelevance.com/brgyan07p/tournament_r011.json');
const tournament = `${placeholders.tourCode}${placeholders.tournamentId}`;
const resp = await fetch(`https://api.massrelevance.com/brgyan07p/tournament_${tournament}.json`);
if (resp.ok) {
const feed = await resp.json();
feed.forEach((item) => {
Expand Down
6 changes: 3 additions & 3 deletions blocks/weather/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function buildRow(data) {

export default async function decorate(block) {
const blockClasses = [...block.classList];
const weatherPrefix = 'https://www.pgatour.com/bin/data/feeds';
const weatherPrefix = 'https://little-forest-58aa.david8603.workers.dev/?url=https://www.pgatour.com/bin/data/feeds';
if (blockClasses.includes('forecast')) {
block.parentNode.classList.add('forecast-wrapper');
// fetch weather
Expand Down Expand Up @@ -71,7 +71,7 @@ export default async function decorate(block) {
col.append(
buildRow(hour.FCTTIME.civil),
buildRow(`${hour.wspd.english} mp/h ${hour.wdir.dir}`),
buildRow(`<img src="${hour.icon_url.replace('.gif', '.png')}" alt="${hour.condition}" /> ${hour.condition}`),
buildRow(`<img src="${hour.icon_url.replace('.gif', '.png')}" alt="${hour.condition}" /> ${hour.condition.replaceAll('/', '/<wbr>')}`),
buildRow(`<span class="weather-temp">${hour.temp.english}</span>`),
buildRow(`<span class="weather-humidity">${hour.humidity}</span>`),
buildRow(`<span class="weather-chance-of-rain">${hour.pop}</span>`),
Expand All @@ -85,7 +85,7 @@ export default async function decorate(block) {
col.append(
buildRow(day.date.weekday),
buildRow(`${day.avewind.mph} mp/h ${day.avewind.dir}`),
buildRow(`<img src="${day.icon_url.replace('.gif', '.png')}" alt="${day.conditions}" /> ${day.conditions}`),
buildRow(`<img src="${day.icon_url.replace('.gif', '.png')}" alt="${day.conditions}" /> ${day.conditions.replaceAll('/', '/<wbr>')}`),
buildRow(`<span class="weather-temp">${day.high.fahrenheit}</span>`),
buildRow(`<span class="weather-humidity">${day.avehumidity}</span>`),
buildRow(`<span class="weather-chance-of-rain">${day.pop}</span>`),
Expand Down
85 changes: 64 additions & 21 deletions scripts/delayed.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
// eslint-disable-next-line import/no-cycle
import {
decorateIcons,
sampleRUM,
decorateBlock,
loadBlock,
} from './scripts.js';
import { decorateIcons, fetchPlaceholders, sampleRUM } from './scripts.js';

const isProd = window.location.hostname.endsWith('theplayers.com');
const placeholders = await fetchPlaceholders();
const isProd = window.location.hostname.endsWith(placeholders.hostname);

if (!isProd) {
if (!isProd === 'this') {
// temporary override for analytics testing
if (!localStorage.getItem('OptIn_PreviousPermissions')) localStorage.setItem('OptIn_PreviousPermissions', '{"aa":true,"mediaaa":true,"target":true,"ecid":true,"adcloud":true,"aam":true,"campaign":true,"livefyre":false}');
}
Expand Down Expand Up @@ -49,23 +45,25 @@ const pageType = window.location.pathname === '/' ? 'homePage' : 'contentPage';
const pname = window.location.pathname.split('/').pop();
window.pgatour.Omniture = {
properties: {
pageName: `pgatour:the-players-championship:${pname}`,
eVar16: `pgatour:the-players-championship:${pname}`,
pageName: `pgatour:tournaments:the-players-championship:${pname}`,
eVar16: `pgatour:tournaments:the-players-championship:${pname}`,
prop18: pageType,
eVar1: 'pgatour',
prop1: 'pgatour',
prop2: 'r011',
eVar2: 'r011',
eVar6: window.location.href,
},
defineOmnitureVars: () => {},
defineOmnitureVars: () => {
if (window.s) {
Object.assign(window.s, window.pgatour.Omniture.properties);
}
},

};

window.pgatour.docWrite = document.write.bind(document);

loadScript(`https://assets.adobedtm.com/d17bac9530d5/90b3c70cfef1/launch-1ca88359b76c${isProd ? '.min' : ''}.js`);

/* setup favorite players */
function alphabetize(a, b) {
if (a.nameL.toUpperCase() < b.nameL.toUpperCase()) return -1;
Expand Down Expand Up @@ -448,7 +446,10 @@ function setupGigya() {
gigya.accounts.session.verify({ callback: checkIfLoggedIn });
}

function initGigya() {
// eslint-disable-next-line import/prefer-default-export
export function initGigya() {
const button = document.getElementById('nav-user-button');
if (button) button.removeEventListener('click', initGigya);
loadScript(
'https://cdns.gigya.com/JS/socialize.js?apikey=3__4H034SWkmoUfkZ_ikv8tqNIaTA0UIwoX5rsEk96Ebk5vkojWtKRZixx60tZZdob',
setupGigya,
Expand All @@ -463,7 +464,7 @@ async function populateStatusBar(statusBar) {
const statusBarData = document.querySelector('.status-bar-data');
// fetch weather
try {
const resp = await fetch('https://www.pgatour.com/bin/data/feeds/weather.json/r011');
const resp = await fetch('https://little-forest-58aa.david8603.workers.dev/?url=https://www.pgatour.com/bin/data/feeds/weather.json/r011');
const { current_observation: weatherData } = await resp.json();
const location = weatherData.display_location.full;
const icon = weatherData.icon_url.replace('.gif', '.png');
Expand All @@ -488,11 +489,53 @@ async function populateStatusBar(statusBar) {
populateStatusBar(document.querySelector('header > .status-bar'));

/* setup cookie preferences */
const cookieScript = loadScript('https://cdn.cookielaw.org/scripttemplates/otSDKStub.js');
cookieScript.setAttribute('data-domain-script', '262c6c79-a114-41f0-9c07-52cb1fb7390c');
function getCookie(cookieName) {
const name = `${cookieName}=`;
const decodedCookie = decodeURIComponent(document.cookie);
const split = decodedCookie.split(';');
// eslint-disable-next-line no-plusplus
for (let i = 0; i < split.length; i++) {
let c = split[i];
while (c.charAt(0) === ' ') c = c.substring(1);
if (c.indexOf(name) === 0) return c.substring(name.length, c.length);
}
return null;
}

if (document.querySelector('.ads')) {
const adsBlock = document.querySelector('.ads');
decorateBlock(adsBlock);
loadBlock(adsBlock);
async function OptanonWrapper() {
const geoInfo = window.Optanon.getGeolocationData();
Object.keys(geoInfo).forEach((key) => {
const cookieName = `PGAT_${key.charAt(0).toUpperCase() + key.slice(1)}`;
const cookie = getCookie(cookieName);
if (!cookie || cookie !== geoInfo[key]) document.cookie = `${cookieName}=${geoInfo[key]}`;
});

const OneTrustActiveGroup = () => {
/* eslint-disable */
var y = true, n = false;
var y_y_y = {'aa': y, 'aam': y, 'ecid': y};
var n_n_n = {'aa': n, 'aam': n, 'ecid': n};
var y_n_y = {'aa': y, 'aam': n, 'ecid': y};
var n_y_y = {'aa': n, 'aam': y, 'ecid': y};

if (typeof OnetrustActiveGroups != 'undefined')
if (OnetrustActiveGroups.includes(',C0002,'))
return OnetrustActiveGroups.includes(',C0004,')?y_y_y:y_n_y;
else
return OnetrustActiveGroups.includes(',C0004,')?n_y_y:n_n_n;

return geoInfo.country == 'US'?y_y_y:n_n_n;
/* eslint-enable */
};
if (!localStorage.getItem('OptIn_PreviousPermissions')) {
const adobeSettings = OneTrustActiveGroup();
adobeSettings.tempImplied = true;
localStorage.setItem('OptIn_PreviousPermissions', JSON.stringify(adobeSettings));
}

loadScript(`https://assets.adobedtm.com/d17bac9530d5/90b3c70cfef1/launch-1ca88359b76c${isProd ? '.min' : ''}.js`);
}
const cookieScript = loadScript('https://cdn.cookielaw.org/scripttemplates/otSDKStub.js');
cookieScript.setAttribute('data-domain-script', `262c6c79-a114-41f0-9c07-52cb1fb7390c${isProd ? '' : '-test'}`);

window.OptanonWrapper = OptanonWrapper;
2 changes: 1 addition & 1 deletion scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ async function loadLazy(doc) {
*/
function loadDelayed() {
// eslint-disable-next-line import/no-cycle
window.setTimeout(() => import('./delayed.js'), 3000);
window.setTimeout(() => import('./delayed.js'), 4000);
// load anything that can be postponed to the latest here
}

Expand Down
24 changes: 19 additions & 5 deletions styles/lazy-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ body .gigya-style-modern div.gigya-screen-dialog-caption {
text-transform: uppercase;
}

/* close button */
body .gigya-style-modern div.gigya-screen-dialog-close > a > img {
filter: brightness(2) grayscale(1);
body .gigya-style-modern.gigya-screen-dialog-mobile div.gigya-screen-dialog-inner {
margin-top: 64px;
}

body .gigya-style-modern div.gigya-screen-dialog-close > a > img:hover {
filter: brightness(1) grayscale(1);
body .gigya-style-modern.gigya-screen-dialog-mobile div.gigya-screen-dialog-top {
line-height: unset;
height: 64px;
}

/* body */
Expand All @@ -43,6 +43,20 @@ body .gigya-screen a:link, body .gigya-screen a:visited {
color: var(--link-color);
}

body .gigya-style-modern div.gigya-screen-dialog-close > a {
padding: 0;
}

/* close button */
body .gigya-style-modern div.gigya-screen-dialog-close > a > img {
filter: brightness(2) grayscale(1);
height: 15px;
}

body .gigya-style-modern div.gigya-screen-dialog-close > a > img:hover {
filter: brightness(1) grayscale(1);
}

/* button */
body .gigya-screen input[type=submit],
body .gigya-screen input[type=button] {
Expand Down
5 changes: 2 additions & 3 deletions tools/importer/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ const ticketSummaryToColumnsBlock = (main, document) => {
item.remove();
}
});

const table = WebImporter.DOMUtils.createTable(cells, document);
lastItem.replaceWith(table);
}
Expand Down Expand Up @@ -231,9 +230,9 @@ export default {
} else if (u.pathname.startsWith('/tournaments/the-cj-cup')) {
makeAbsoluteLinks(main, 'https://main--pga-the-cj-cup--hlxsites.hlx.page', '/tournaments/the-cj-cup');
} else if (u.pathname.startsWith('/tournaments/mitsubishi-electric-championship-at-hualalai')) {
makeAbsoluteLinks(main, 'https://main--pga-mitsubishi-electric-championship-at-hualalai--hlxsites.hlx.page', '/champions/tournaments/mitsubishi-electric-championship-at-hualalai');
makeAbsoluteLinks(main, 'https://main--pga-mitsubishi-electric-championship--hlxsites.hlx.page', '/champions/tournaments/mitsubishi-electric-championship-at-hualalai');
} else if (u.pathname.startsWith('/tournaments/bridgestone-senior-players-championship')) {
makeAbsoluteLinks(main, 'https://main--pga-bridgestone-senior-players-championship--hlxsites.hlx.page', '/champions/tournaments/bridgestone-senior-players-championship');
makeAbsoluteLinks(main, 'https://main--pga-kaulig-companies-championship--hlxsites.hlx.page', '/champions/tournaments/kaulig-companies-championship');
} else if (u.pathname.startsWith('/tournaments/dominion-energy-charity-classic')) {
makeAbsoluteLinks(main, 'https://main--pga-dominion-energy-charity-classic--hlxsites.hlx.page', '/champions/tournaments/dominion-energy-charity-classic');
} else if (u.pathname.startsWith('/tournaments/charles-schwab-cup-championship')) {
Expand Down

0 comments on commit bd30310

Please sign in to comment.