Skip to content

Commit fcf6eab

Browse files
committed
Revert "Don't show Usabilla button if it's blocked"
This reverts commit d886f63.
1 parent d886f63 commit fcf6eab

1 file changed

Lines changed: 39 additions & 44 deletions

File tree

src/NuGetGallery/Scripts/gallery/common.js

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -463,56 +463,51 @@
463463
};
464464

465465
nuget.enableUsabilla = function (obfuscatedPath) {
466-
// Only enable Usabilla if the API is available and the button container is in the DOM. If the user has
467-
// external scripts blocked or trackers blocks, Usabilla might not be loaded at all. This method was confirmed
468-
// with Usabilla support staff.
469-
if (window.usabilla_live !== undefined && $(".usabilla_live_button_container").length > 0) {
470-
// If there is an obfuscated path, hook into the outgoing AJAX request containing the feedback and obfuscate
471-
// the URL data. This approach was provided by the Usabilla technical support.
472-
if (obfuscatedPath) {
473-
var obfuscatedUrl = document.createElement('a');
474-
obfuscatedUrl.href = window.location.href;
475-
if (obfuscatedPath.substring(0, 1) != "/") {
476-
obfuscatedUrl.pathname = "/" + obfuscatedPath;
477-
} else {
478-
obfuscatedUrl.pathname = obfuscatedPath;
479-
}
480-
481-
window.usabilla_live("setEventCallback", function (category, action, label, value, eventdata) {
482-
if (action != "Feedback:Open") {
483-
return;
484-
}
466+
// If there is an obfuscated path, hook into the outgoing AJAX request containing the feedback and obfuscate
467+
// the URL data. This approach was provided by the Usabilla technical support.
468+
if (obfuscatedPath) {
469+
var obfuscatedUrl = document.createElement('a');
470+
obfuscatedUrl.href = window.location.href;
471+
if (obfuscatedPath.substring(0, 1) != "/") {
472+
obfuscatedUrl.pathname = "/" + obfuscatedPath;
473+
} else {
474+
obfuscatedUrl.pathname = obfuscatedPath;
475+
}
485476

486-
function sendWithObfuscation(vData) {
487-
if (vData) {
488-
var data = JSON.parse(vData);
489-
data.url = obfuscatedUrl.href;
490-
vData = JSON.stringify(data);
491-
arguments[0] = vData;
492-
}
493-
realSend.apply(this, arguments);
494-
}
477+
window.usabilla_live("setEventCallback", function (category, action, label, value, eventdata) {
478+
if (action != "Feedback:Open") {
479+
return;
480+
}
495481

496-
var realSend = XMLHttpRequest.prototype.send;
497-
var ub_window = document.getElementById("lightningjs-frame-usabilla_live_feedback").contentWindow;
498-
ub_window.XMLHttpRequest.prototype.send = sendWithObfuscation;
499-
if (window.XDomainRequest) {
500-
realSend = XDomainRequest.prototype.send;
501-
ub_window.XDomainRequest.prototype.send = sendWithObfuscation;
482+
function sendWithObfuscation(vData) {
483+
if (vData) {
484+
var data = JSON.parse(vData);
485+
data.url = obfuscatedUrl.href;
486+
vData = JSON.stringify(data);
487+
arguments[0] = vData;
502488
}
503-
});
504-
}
505-
506-
// Hide the default feedback button.
507-
window.usabilla_live("hide");
489+
realSend.apply(this, arguments);
490+
}
508491

509-
// Wire-up and show the custom feedback button.
510-
document.getElementById("usbl-integrated-button").addEventListener("click", function (event) {
511-
event.preventDefault();
512-
window.usabilla_live("click");
492+
var realSend = XMLHttpRequest.prototype.send;
493+
var ub_window = document.getElementById("lightningjs-frame-usabilla_live_feedback").contentWindow;
494+
ub_window.XMLHttpRequest.prototype.send = sendWithObfuscation;
495+
if (window.XDomainRequest) {
496+
realSend = XDomainRequest.prototype.send;
497+
ub_window.XDomainRequest.prototype.send = sendWithObfuscation;
498+
}
513499
});
514-
document.getElementById("usabilla-button").style.display = "block";
515500
}
501+
502+
// Hide the default feedback button.
503+
window.usabilla_live("hide");
504+
505+
// Wire-up and show the custom feedback button.
506+
document.getElementById("usbl-integrated-button").addEventListener("click", function (event) {
507+
event.preventDefault();
508+
window.usabilla_live("click");
509+
});
510+
document.getElementById("usabilla-button").style.display = "block";
516511
};
517512

518513
window.nuget = nuget;

0 commit comments

Comments
 (0)