Remove cookie policy popup created by ngx-cookieconsent - cookieconsent

How can I remove the small "Cookie policy" window?
I am using latest version of ngx-cookieconsent with Angular 7.2

i forced to close it by:
this.ccService.close(false);
or to hide by this.ccService.fadeOut();
since 'revokable': false option didnt work.

I'm a bit late for this answer but had the same issue today and I found some workaround.
this.statusChangeSubscription = this.ccService.statusChange$.subscribe(
(event: NgcStatusChangeEvent) => {
if (event.status === 'allow') {
this.ccService.close(false); // Hide revoke button after accepting cookies
}
});
Below this or at the end of ngOnInit() I added this:
if (this.ccService.hasConsented()) {
this.ccService.destroy();
}
Code above check if you get consent and if yes it will destroy popup instance.

An alternative solution is to add the following in the app.component.scss:
/* Hide ng cookies consent revoke button */
::ng-deep .cc-revoke {
display: none;
}

Have you try the this.ccService.getConfig().autoOpen=false ?
After saving cookie, i set it to false.

Related

Is there a way to have a bookmark be created upon clicking a button/link?

I'm trying to figure out if it's possible to make it so that if you click a link or button, a bookmark will be created. Anything that comes up on Google has to do with ebooks, and I can't seem to find anything. If anyone has the answer, it would be a huge help!
function addFavorites(a) {
pageTitle = document.title;
pageURL = document.location;
try {
// Internet Explorer solution
eval("window.external.AddFa-vorite(pageURL, pageTitle)".replace(/-/g, ''));
} catch (e) {
try {
// Mozilla Firefox solution
window.sidebar.addPanel(pageTitle, pageURL, "");
} catch (e) {
// Opera solution
if (typeof(opera) == "object") {
a.rel = "sidebar";
a.title = pageTitle;
a.url = pageURL;
return true;
} else {
// The rest browsers (i.e Chrome, Safari)
alert('Press ' + (navigator.userAgent.toLowerCase().indexOf('mac') != -1 ? 'Cmd' : 'Ctrl') + '+D to bookmark this page.');
}
}
}
return false;
}
Add to Favorites
Source: https://rudrastyh.com/javascript/favorite-button.html
Be aware of eval()
eval() may be a dangerous function under certain circumstances, which executes the code it's passed with the privileges of the caller.
Get advised by Mozilla.org and use with caution
No, there's no stright forward way for that.
Opera, Google Chrome and Safari do not provide a way to add new elements to the Favorites (Bookmarks) from JavaScript.
There was an API for that however, which is the Window.external API, and I believe it used to work as window.external.AddFavorite() in Internet Explorer, and window.sidebar.addPanel() in Firefox (obsolete, deprecated, i.e. dead, see for the API).
Not sure this info would help, but you might have to create a browser extension for that, then connect your button with your extension, this way you can ensure its stability.
My suggestion is to simply ask the users to bookmark the webpage they're in if that would help to solve the problem you're trying to solve (not sure what you're trying to create).

Pushpad: subscribe prompt only showed up the first time a user clicks on enable button on chrome

Hello,
I already checked the answers from the question PushPad: Subscribe is removed after site refresh, but it did not help me.
I created a subscribe/unsubscribe button, following the doc, and the prompt is showing up on Firefox each time i click on the subscribe button so i guess my flow is correct but i don't understand why it's not working on Chrome => the prompt is only showing the first time i launch Chrome.
Here is what i do
pushpad('init', #projectID);
var pushId = $("#main").data("pushid");
var pushSig = $("#main").data("pushsig");
var updateButton = function (isSubscribed) {
var btn = $('#activate-push-notif');
if (isSubscribed) {
btn.html('Unsubscribe');
btn.addClass('subscribed');
} else {
btn.html('Subscribe');
btn.removeClass('subscribed');
}
};
// check whether the user is subscribed to the push notifications and
// initialize the button status (e.g. display Subscribe or Unsubscribe)
pushpad('status', updateButton);
// when the user clicks the button...
$('#activate-push-notif').on('click', function (e) {
e.preventDefault();
// if he wants to unsubscribe
if ($(this).hasClass('subscribed')) {
pushpad('unsubscribe', function () {
updateButton(false);
}, {
uid: pushId,
});
// if he wants to subscribe
} else {
// try to subscribe the user to push notifications
pushpad('subscribe', function (isSubscribed) {
if (isSubscribed) {
updateButton(true);
} else {
updateButton(false);
alert('You have blocked notifications from your browser preferences.');
}
}, {
uid: pushId,
uidSignature: pushSig
});
}
});
Thanks for your help to figure it out.
Make sure that you wrap all your code inside $(function () { ... }, so that your code is run when the page is fully loaded, otherwise your click handler may not work properly.
Probably the point is that when you see the Firefox prompt you click "Not now" (instead of "Never allow" which is hidden under the ▼ menu). That is why you can see the prompt multiple times. In other browsers, like Chrome, the default option is "Block" (which is a permanent block, like "Never allow").
When the user blocks the notifications you cannot display the browser prompt again, due to browser restrictions... however there are some alternative solutions. For example you can display a custom prompt as many times as you want, and then display the browser prompt only if the user says yes to your custom prompt. See this example. Otherwise you can display a prompt only to users who have blocked the notifications, asking to unblock the notifications. See this example. Another option is to display a button in the page to allow the users to subscribe to notifications when they decide to do that.

How to disable strongloop's API explorer swagger console

I'd like to disable the strongloop api explorer (pref as noted in docs) - not clear if this is a bug or documentation issue.
Setting or replacing component config or using component-config.production as noted in the docs fails and generates an critical error / crashing express.
// Original
{
"loopback-component-explorer": {
"mountPath": "/explorer"
}
}
// changes made to disable
{
"loopback-component-explorer": false
}
Docs:
https://docs.strongloop.com/display/APIC/Preparing+for+deployment#Preparingfordeployment-DisablingAPIExplorer
Remove the loopback-component-explorer entry from your component-config.json file entirely.
You can remove only 'loopback-component-explorer' part from 'component-config.json' and keep the empty object, where the code will not get crashed.
Original code:
{
"loopback-component-explorer": {
"mountPath": "/explorer"
}
}
Updated:
{
}
Also can turn off stack traces, more info here

Ionic slides (ion-slides) : hide pagger when reaching the end

I am using ionic slides and I want to hide the pager when the user reaches the last slide.
There is a showPagger() method but I cannot figure out how to use it for this purpose.
Any help on this?? Thanks
html :
<ion-slides pager (change)="onSlideChanged()">
...
<ion-slides>
js :
$scope.onSlideChanged = function() {
if ($ionicSlideBoxDelegate.currentIndex() == $ionicSlideBoxDelegate.slidesCount()) {
$ionicSlideBoxDelegate.showPager(false);
}
else {
$ionicSlideBoxDelegate.showPager(true);
}
}
I will update answer later.
Unfortunately, after searching and searching I found out that it is an open issue about it in ionic repository. The showPager property is not exposed to the directive API, so there is no direct use to it.

How to disable right-click on a hyperlink in html

I need to disable right-click on a hyperlink which is in a span. I need to disable only one link from the whole page. Any suggestions?
If you dont want to show the context menu on hyperlink, you can do so without doing anything to other part or even span where it exists. I tested in IE, Firefox and it works.
Link
This should work:
oncontextmenu=”return false;”
Place it on any element you want to disable right click for.
Be aware that this causes bad user experience and users can disable it very easily.
Disclaimer: not tested.
If you don't want to pollute your HTML with inline events and you care about supporting IE < 9, you can use this lovely mess:
function addEvent (el, eventType, listener) {
if (el.addEventListener) { // W3C-compliant
el.addEventListener(eventType, listener, false);
}
else {// IE-specific
el.attachEvent('on'+eventType, listener);
}
}
addEvent(document.getElementById('myLinkID'), 'contextmenu', function (e) {
if (e.preventDefault) { // W3C
e.preventDefault();
}
else { // IE
e.returnValue = false;
}
});
I have never seen one done through HTML (that does not imply it is not possible). However, JavaScript can help you here.
You can do something like:
var eventbutton = (isNS) ? myevent.which : myevent.button;
if((eventbutton==2)||(eventbutton==3)) return false;
Try this oncontextmenu="return false;"
IN MVC:
#Html.ActionLink("print page", "myprint", "print", null, new { #oncontextmenu="return false;"})
You can also use jQuery:
$(".myHyperlinks").contextmenu(function () { return false; });