Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove debugging statements #6418

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions kitsune/sumo/static/sumo/js/ajaxvote.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ export default function AjaxVote(form, options) {
AjaxVote.prototype.init.call(this, form, options);
}

(function($) {
(function ($) {
akatsoulas marked this conversation as resolved.
Show resolved Hide resolved

'use strict';

AjaxVote.prototype = {
init: function(form, options) {
init: function (form, options) {
var self = this,
$ajaxForm = $(form),
$btns = $ajaxForm.find('[type="submit"], [data-type="submit"]');
Expand All @@ -32,13 +32,13 @@ export default function AjaxVote(form, options) {
self.voted = false;
self.$form = $ajaxForm;

$btns.on('click', function(e) {
$btns.on('click', function (e) {
if (!self.voted) {
var $btn = $(this),
$form = $btn.closest('form'),
url = $form.attr('action'),
formDataArray = $form.serializeArray(),
data = {url},
data = { url },
i, l;
$btns.attr('disabled', 'disabled');
$form.addClass('busy');
Expand All @@ -51,7 +51,7 @@ export default function AjaxVote(form, options) {
type: 'POST',
data: data,
dataType: 'json',
success: function(response) {
success: function (response) {
if (response.survey) {
self.showSurvey(response.survey, $form.parent());
}
Expand All @@ -68,9 +68,9 @@ export default function AjaxVote(form, options) {
}

// Hide other forms
self.$form.filter(function() { return !$form.is(this); }).remove();
self.$form.filter(function () { return !$form.is(this); }).remove();
},
error: function() {
error: function () {
var msg = gettext('There was an error submitting your vote.');
self.showMessage(msg, $btn, $form);
$btns.prop("disabled", false);
Expand All @@ -84,13 +84,11 @@ export default function AjaxVote(form, options) {
return false;
});
},
showMessage: function(message, $showAbove, $form) {
// TODO: Tweak KBox to handle this case.
showMessage: function (message, $showAbove, $form) {
var self = this,
$html = $('<div class="ajax-vote-box"><p class="msg document-vote--heading"></p></div>'),
offset = $showAbove.offset();
$html.find('p').html(message);
console.log('options', self.options)

if (self.options.positionMessage) {
// on desktop browsers we use absolute positioning
Expand All @@ -107,23 +105,23 @@ export default function AjaxVote(form, options) {
// on mobile browsers we just append to the grandfather
// TODO: make this more configurable with an extra option
$showAbove.parent().parent()
.addClass($showAbove.val()).append($html);
.addClass($showAbove.val()).append($html);
}

function fadeOut() {
$html.fadeOut(function() {
$html.fadeOut(function () {
$html.remove();
});
if (self.options.removeForm) {
self.$form.fadeOut(function() {
self.$form.fadeOut(function () {
self.$form.remove();
});
}
$('body').off('click', fadeOut);
clearTimeout(timer);
}
},
showSurvey: function(survey, $container) {
showSurvey: function (survey, $container) {
var $survey = $(survey);
var $commentCount = $survey.find('#remaining-characters');
var $commentBox = $survey.find('textarea');
Expand All @@ -148,7 +146,7 @@ export default function AjaxVote(form, options) {
var checked = $radios.filter(':checked').val();
var feedback = $textbox.val();
if (checked === undefined ||
((checked === 'other' || checked === 'firefox-feedback') && !feedback)) {
((checked === 'other' || checked === 'firefox-feedback') && !feedback)) {
$submit.prop('disabled', true);
$reason.fadeIn(600);
} else {
Expand All @@ -157,7 +155,7 @@ export default function AjaxVote(form, options) {
}
}

$commentBox.on('input', function() {
$commentBox.on('input', function () {
var currentCount = $commentBox.val().length;
var checked;

Expand Down
6 changes: 0 additions & 6 deletions kitsune/sumo/static/sumo/js/analytics.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
export default function trackEvent(name, parameters) {
if (window.gtag) {
if (window.gaConsoleLogging) {
console.log("------------------------------");
console.log(`event: ${name}:`);
console.log(`parameters: ${JSON.stringify(parameters, null, 2)}`);
console.log("------------------------------");
}
window.gtag('event', name, parameters);
}
}
Expand Down
25 changes: 7 additions & 18 deletions kitsune/sumo/static/sumo/js/gtm-snippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,25 @@

import dntEnabled from "./libs/dnt-helper";

(function(w) {
(function (w) {
'use strict';

let html = document.getElementsByTagName('html')[0];
let GTM_CONTAINER_ID = html.getAttribute('data-gtm-container-id');

w.gaConsoleLogging = false;

w.dataLayer = w.dataLayer || [];

w.gtag = function() {
w.gtag = function () {
w.dataLayer.push(arguments)
}
// If doNotTrack is not enabled, it is ok to add GTM
// @see https://bugzilla.mozilla.org/show_bug.cgi?id=1217896 for more details
if (typeof dntEnabled === 'function' && !dntEnabled() && GTM_CONTAINER_ID) {
(function(w,d,s,l,i,j,f,dl,k,q){
w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});f=d.getElementsByTagName(s)[0];
k=i.length;q='//www.googletagmanager.com/gtag/js?id=@&l='+(l||'dataLayer');
while (k--) {j=d.createElement(s);j.async=!0;j.src=q.replace('@',i[k]);f.parentNode.insertBefore(j,f);}
}(window,document,'script','dataLayer',[GTM_CONTAINER_ID]));
(function (w, d, s, l, i, j, f, dl, k, q) {
w[l] = w[l] || []; w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' }); f = d.getElementsByTagName(s)[0];
k = i.length; q = '//www.googletagmanager.com/gtag/js?id=@&l=' + (l || 'dataLayer');
while (k--) { j = d.createElement(s); j.async = !0; j.src = q.replace('@', i[k]); f.parentNode.insertBefore(j, f); }
}(window, document, 'script', 'dataLayer', [GTM_CONTAINER_ID]));

w.gtag('js', new Date());

Expand All @@ -50,15 +48,6 @@ import dntEnabled from "./libs/dnt-helper";
if (html.dataset.gaDebugMode) {
configParameters.debug_mode = true;
}
// Always ensure this block of console-logging code follows all
// of the code that modifies the "configParameters" object.
if (html.dataset.gaConsoleLogging) {
w.gaConsoleLogging = true;
console.log("------------------------------");
console.log(`config for ${GTM_CONTAINER_ID}:`);
console.log(`parameters: ${JSON.stringify(configParameters, null, 2)}`);
console.log("------------------------------");
}

w.gtag('config', GTM_CONTAINER_ID, configParameters);
}
Expand Down
35 changes: 17 additions & 18 deletions kitsune/sumo/static/sumo/js/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@ window.addEventListener("DOMContentLoaded", (event) => {

if (countryField) {
fetch(proxyUrl)
.then(response => {
if (!response.ok) {
throw new Error(`Fetch failed, status ${response.status}`)
}
return response.json();
.then(response => {
if (!response.ok) {
throw new Error(`Fetch failed, status ${response.status}`)
}
return response.json();

})
.then(data => {

if(data && data.country_name) {
countryField.value = data.country_name;
} else {
})
.then(data => {

if (data && data.country_name) {
countryField.value = data.country_name;
} else {
countryField.value = '';
}
})
.catch(error => {
console.error('Error fetching country:', error);
countryField.value = '';
console.log('No country name found in response.');
}
})
.catch(error => {
console.error('Error fetching country:', error);
countryField.value = '';
});
});
}
});
12 changes: 3 additions & 9 deletions kitsune/sumo/static/sumo/js/protocol-modal-init.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
import "sumo/js/protocol";

(function() {
(function () {
'use strict';
var modalLink = document.querySelectorAll('[data-sumo-modal]');
if (modalLink) {
modalLink.forEach(function(e) {
modalLink.forEach(function (e) {
var dialogLink = e.dataset.sumoModal;
var content = document.getElementById(dialogLink);
function openThisDialog(e){
function openThisDialog(e) {
Mzp.Modal.createModal(e.target, content, {
closeText: 'Close modal',
content: document.getElementById(e.target.dataset.sumoModal),
onCreate: function() {
// console.log('Modal opened');
},
onDestroy: function() {
// console.log('Modal closed');
}
});
e.preventDefault();
};
Expand Down
41 changes: 14 additions & 27 deletions kitsune/sumo/static/sumo/js/protocol-nav.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import "sumo/js/protocol";

(function() {
'use strict';
Mzp.Navigation.init();
Mzp.Menu.init();
(function () {
'use strict';
Mzp.Navigation.init();
Mzp.Menu.init();
})();

var toggleNavButtons = document.querySelectorAll('[data-sumo-toggle-nav]');
Expand Down Expand Up @@ -35,7 +35,7 @@ if (toggleNavButtons.length > 0) {

// if search nav, focus the field
if (toggleThisId == "#search-navigation") {
window.scrollTo(0,0);
window.scrollTo(0, 0);
toggleThisItem.querySelector('.searchbox').focus();
}

Expand All @@ -52,25 +52,12 @@ if (toggleNavButtons.length > 0) {
// address bar slides away on scroll, which causes problems.
var timeout = false;
var width = window.innerWidth;
window.addEventListener('resize', function() {
clearTimeout(timeout);
timeout = setTimeout(function(){
if (window.innerWidth != width) {
width = window.innerWidth;
resetNavs();
}
}, 250);
});

// lang switcher from protocol. #TODO: test this in app.
// (function() {
// 'use strict';
// // a custom callback can be passed to the lang switcher for analytics purposes.
// Mzp.LangSwitcher.init(function(
// previousLanguage, newLanguage) {
// console.log('Previous language: ',
// previousLanguage);
// console.log('New language: ',
// newLanguage);
// })
// })();
window.addEventListener('resize', function () {
clearTimeout(timeout);
timeout = setTimeout(function () {
if (window.innerWidth != width) {
width = window.innerWidth;
resetNavs();
}
}, 250);
});
Loading