Skip to content
Snippets Groups Projects
Commit 3ce50df4 authored by Eric Poirier's avatar Eric Poirier
Browse files

Update for Ads js now located in solstice-assets


Signed-off-by: default avatarEric Poirier <eric.poirier@eclipse-foundation.org>
parent 18445615
No related branches found
No related tags found
1 merge request!24Update for Ads js now located in solstice-assets
Pipeline #6151 passed
......@@ -13,4 +13,4 @@
import 'eclipsefdn-solstice-assets'
import './src/eclipsefdn-promo-content'
import './src/featured-projects-committer'
\ No newline at end of file
import './src/featured-projects-committer'
$(function () {
let formats = {};
let publish_to = '';
$('.eclipsefdn-promo-content').each(function (index, element) {
publish_to = $(element).attr('data-ad-publish-to');
/*!
* Copyright (c) 2022 Eclipse Foundation, Inc.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* Contributors:
* Eric Poirier <eric.poirier@eclipse-foundation.org>
*
* SPDX-License-Identifier: EPL-2.0
*/
if ($(element).attr('data-ad-format').indexOf(',')) {
const format_array = $(element).attr('data-ad-format').split(',');
$(format_array).each(function (item, format) {
formats[format] = '1';
});
} else {
formats[$(element).attr('data-ad-format')] = '1';
}
});
const params = {
host: window.location.host,
source: window.location.pathname,
publish_to: publish_to,
format: formats,
};
$.ajax('https://newsroom.eclipse.org/api/ads/', {
dataType: 'json',
contentType: 'application/json',
type: 'POST',
data: JSON.stringify(params),
success: function (data) {
for (var i = 0; i < data.length; i++) {
if (data[i].id !== '') {
const url = data[i].url;
const campaign_name = data[i].campaign_name;
const image = data[i].image;
$('.eclipsefdn-promo-content').each(function (index, element) {
if (
$(element).attr('data-ad-format').includes(data[i].format) &&
url &&
campaign_name &&
image
) {
$(element).append(
'<p class="featured-story-description text-center">Sponsored Ad</p>' +
'<a href="' +
url +
'" rel="nofollow"><img alt="' +
campaign_name +
'" src="' +
image +
'" class="img-responsive center-block"></a>' +
'<p class="featured-story-description text-center"><a href="https://eclipse-5413615.hs-sites.com/ad-prospectus-form" style="float:none">Advertise Here</a></p>'
);
}
});
}
}
$.fn.matchHeight._update();
},
error: function () {
console.log('Could not load eclipsefdn-promo-content content.');
},
});
});
import "eclipsefdn-solstice-assets/js/solstice/eclipsefdn.promotion.js";
......@@ -20,7 +20,7 @@
"install": "NODE_ENV=production npm run production"
},
"dependencies": {
"eclipsefdn-hugo-solstice-theme": "0.0.148",
"eclipsefdn-hugo-solstice-theme": "0.0.158",
"js-yaml": "^3.13.1",
"json-minify": "^1.0.0"
},
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment