Show just one web notification at once on the desktop - html

I've been working with HTML5 web notifications on desktop, and they seem to work really well.
But I'm just showing them as in the default behavior of the browser.
This means that when I send multiple notifications they stack up to 3, and then as older ones get closed, the waiting ones appear in place.
What I want to know if its possible, and if it is how I can do it, is if I can show just one, not three notifications at once, and if there's a new one to show, put it in the place of the previous one.
I hope I was clear on my problem, let me know otherwise.
Thanks in advance.

Well, I found out by myself, and the key was the tag attribute.
When you create a new notification with the same tag as an existing one, the new one replaces the old one.
So if the goal is to display only one notification at once, just create the notifications always using the same tag.
For instance:
var notification = new Notification(
"Title", {
tag: 1
}
);

Related

React history - is there a way to remove duplicate entires when going back?

Currently for my back button I'm using window.history.back() which, in itself is working properly. My issue is with an iframe that I have for refreshing sessions, example
<iframe src="https://example.com/some/path?gcp-iap-mode=SESSION_REFRESHER" style="width:0;height:0;border:0; border:none;"></iframe>
Path in my project represents current url, so it keeps changing every time I change locations. Now, with the source the iframe has, it keeps throwing 404 and getting into my history so instead of clicking back button once, I have to do it at least two times - first times it fails as it tries to reach randompath?gcp-iap-mode=SESSION_REFRESHER and then it goes to proper path.
My question is, is there a way for me to check the "back" value, to see if the "back" value has a specific query (for example gcp-iap-mode part), or check if it's the same as a current location (duplicate) so I can skip that entry (and couple of back steps) and go back to a different path in history stack?
Seems an issue like this is common in iframes. I tried looking at it from a wrong perspective, by looking for ways to change history where the only thing that needed to be changed is the iframe itself.
Basically when we only change the src attribute of the iframe it gets rendered again and again and the src gets pushed to history stack. What we needed here was the iframe to unmount and the soultion to all of that was pretty simple - add a key prop to the iframe.
This is a blog page that helped me, so if somebody wants to read more:
https://www.aleksandrhovhannisyan.com/blog/react-iframes-back-navigation-bug/

Can HTTP GET be used if there are small side-effects?

As far as I understand, GET has to be idempotent - it cannot change anything in the system and repeating it should always return the same unless something else changed the state of the application.
Problem is, on my website, there should be a lot of little changes based on whether some content has been already seen before by the user. I mean, like notifications, new message alerts, content sorting based on whether user saw it or not, how many users saw the content counters... For example when user clicks on notification, the notification should disappear from his notification panel and never be seen there again, so it changes something - state of the notification, but I can press F5 as many times as I want and it always returns the same page with same info, same buttons etc.
Can I ignore this kind of side-effect as too small and I can use GET or do I have to make most links and buttons on the website use POST like I do with links and buttons which lead to more "serious" changes? I do that by making forms around each of them with those links as form actions and original buttons as submit buttons of the form which seems a little messy to me and I don't want it almost everywhere (or is there a better way?).
This can be tackled from several points of view, I'll illuminate it from this angle:
The end result here is always the same, hence the request is idempotent.
The user visits the URL, the end result is that the notifications are cleared. They can visit the page again and again, the end result is that the notifications are cleared. They're not going to get an error message because the notifications have been previously cleared (that would not be idempotent). Yes, they will see different content each time they visit the page, but nothing says that the page content must be identical each time the resource is requested (that would put half the web in a bind).
Contrast that with a POST request to /questions (which creates a new question, for example): each time you repeat that POST request, a completely new resource is being created. You POST once, and /questions/12345 is being created. You repeat the same request, /questions/12346 is being created. That is not idempotent.
No, you do not need to make all those requests into POST requests.

ColdFusion Cookie/Form Submission Loophole

Okay so here is my problem. I have developed a framework which does the following:
If, for example, you have four webpages... but you only want to allow users to reach the "4th" webpage after progressing through pages 1-3 sequentially - I have built this functionality (basically I set an encrypted cookie keeping track of what the user has completed thus allowing to know what they should be able to access). There are two parts of it:
1) If a page does NOT have a quiz, the user must only visit the webpages sequentially to be allowed to view the 4th page in the "progression".
2) However, if a page has a quiz on it, the user must successfully pass the quiz to go on to the next sequential page.
Now... Here is the real biggie... The last page will often be a web form which, obviously, I only want an individual to fill out and submit if they have reached the form by sequentially getting to that last page in the progression... BUT I found a flaw in the system. If someone were to go completely through the progression and fill the form out... they could delete their browser's "form data" and go "back" to the form and allow a friend to fill the form out. That would be detrimental to the system, and the users who will be navigating this progression are GOING to look for ways to get around going through it.
Some of the suggestions I will probably get will not be possible given the larger framework I am in, but rather than list all of the impossibilities I would like to see what you guys thought would be a way of getting around this issue?
P.S. This functionality is built in HTML and ColdFusion.
Thank you for any feedback, it is a great help!
EDIT:
Keep in mind the user must be able to back track any previous page they already completed.

Send IconicTile Notification in Windows Phone

I am trying to send Iconic Tile Notification from Server to Client using node2dm. Node2dm provides us with 'mpns' module which I am using to send Messages. I want my notification to look like the first tile in the image and not like the second one.
Now I have two issue.
=>. First is, I am able to send notifications of second type where notification count appears in a circle. But I am not able to clear that notification count. I used
mpns.sendTile(pushUri, backgroundImage, count, title, backBackgroundImage)
for this. I tried sending count=0 for clearing the notification from tile but it didn't work.
=>. Second problem is, I tried sending notification of first type from above image since I was not able to clear the notification count for previous one. And also this looks more elegant. For this I used
mpns.sendIconicTile(pushUri, backgroundColor, count, title, iconImage, smallIconImage, wideContent1, wideContent2, wideContent3)
But with this. I am not even getting any tile update at all. There is an option of providing id in sendIconicTile() function, but I dont know what to pass it there. I don't have an id for my tile. Its primary default tile which I am trying to update, not a secondary tile. So I think 'id' shouldn't be required.
Can someone please help me with this. Or suggest some other way to update my tile.
Ok, I'm not familiar with node2dm, but I'll try to help. For the first problem, if you were sending notification by yourself you would set this line <wp:Count Action="Clear"></wp:Count> in notification XML payload. Now I'm not sure if you can do that with node2dm, but they should provide a way to set that.
The second problem looks as your client application doesn't have Iconic tile template. You need to change that in you app's WMAppManifest.xml. It needs to look something like this
<Tokens>
<PrimaryToken TokenID="YouAppNameToken" TaskName="_default">
<TemplateIconic>
<SmallImageURI IsResource="false" IsRelative="true">TileIcon.png</SmallImageURI>
<Count>0</Count>
<IconImageURI IsResource="false" IsRelative="true">TileIcon.png</IconImageURI>
<Title>Your title</Title>
</TemplateIconic>
</PrimaryToken>
</Tokens>

How to use pushState,replaceState and popState correctly?

I'm trying to use the history API but I can't get it working as I'd expect. I've look at several examples but they all appear to be doing something wrong. That is, this flow doesn't work as expected:
On new page call pushState
On popState load desired page
What I'm finding happens is that for #2 the URL is not modified to the old state (testing in Firefox). Unless I call pushState, or replaceState again the URL stays where it was. I'm also finding that somehow the first page ends up duplicated in the browser's history (holding down back I can see it).
How exactly should the history be used so that Back/Forward/Reload all work like a traditional page flow?
The problems I'm having relate to the use of an iframe in the page. Each change of the location of the frame creates a new history entry which messages with the desired history. To prevent this one must replace the iframe location instead of assigning a new one.
document.getElementById('content_frame').contentWindow.location.replace( new_path )
Location.replace doesn't create a history entry.