MCPcopy
hub / github.com/ampproject/amphtml / reddit

Function reddit

3p/reddit.js:47–76  ·  view source on GitHub ↗
(global, data)

Source from the content-addressed store, hash-verified

45 * @param {!Object} data
46 */
47export function reddit(global, data) {
48 const embedtype = data.embedtype || 'post';
49
50 let container;
51 let scriptSource = '';
52
53 // Post and comment embeds are handled totally differently.
54 if (embedtype === 'post') {
55 container = getPostContainer(global);
56 scriptSource = 'https://embed.redditmedia.com/widgets/platform.js';
57 } else if (embedtype === 'comment') {
58 container = getCommentContainer(global, data);
59 scriptSource = 'https://www.redditstatic.com/comment-embed.js';
60 }
61
62 const link = global.document.createElement('a');
63 link.href = data.src;
64
65 container.appendChild(link);
66 global.document.getElementById('c').appendChild(container);
67
68 getContainerScript(global, scriptSource);
69
70 global.addEventListener('resize', (event) => {
71 global.context.updateDimensions(
72 event.target.outerWidth,
73 event.target.outerHeight
74 );
75 });
76}

Callers 1

test-amp-reddit.jsFile · 0.90

Calls 6

getCommentContainerFunction · 0.85
updateDimensionsMethod · 0.80
getPostContainerFunction · 0.70
getContainerScriptFunction · 0.70
getElementByIdMethod · 0.45
addEventListenerMethod · 0.45

Tested by

no test coverage detected