1

I want to display little messages to provide feedback to the user while he is providing input or just interacting with the UI.

I need it for my firefox addon, so I have to develop it in plain javascript and not jQuery.

I want the message to appear, but only one message can be visible at the same time, so I need some kind of queue to manage incomming messages. After a certain time e.g. 3 sec the message should fade away or just disappear.

For now I am able to add messages to the DOM. Any suggestions how to implement the queue and how to push the messages forward according to the time?

Thanks!

1
  • Perhaps not call it message queue. Message queuing is terminology reserved for computer science / engineering that describes a different concept. Better call it notification queue. Thanks for updating your question title. Commented Aug 3, 2022 at 16:33

3 Answers 3

5

Perheps you need the concept of FIFO (First In First Out)

Take a look at this simple example in plan java script language:

function Queue() { var data = []; this.isEmpty = function() { return (data.length == 0); }; this.enqueue = function(obj) { data.push(obj); }; this.dequeue = function() { return data.shift(); }; this.peek = function() { return data[0]; }; this.clear = function() { data = []; }; } 
Sign up to request clarification or add additional context in comments.

Comments

0

You can use jQuery in a firefox plugin:

Include a script tag in the xul file that points to the jQuery file, e.g.:

<script type="text/javascript" src="chrome://extensionname/content/jquery.js" /> 

In each js function that uses jQuery, insert this line:

$jQuizzle = jQuery.noConflict(); 

In each jQuery call, if you are trying to manipulate the document in the current browser window, you must supply the context as "window.content.document", like this:

$jQuizzle(".myClass", window.content.document).show(); 

Then you can use this jQuery plugin: http://benalman.com/projects/jquery-message-queuing-plugin/

5 Comments

hm this does not work for me, I tried to hide the whole content with $jQuizzle("#smsflatrateSidebar", window.content.document).hide(); but nothing happens
$jQuizzle = jQuery.noConflict(); seems to fail
Have you added the jquery file into content and changed the extensionname to what ever you're extension is called?
Jquery is included sucessfully this way <script type="application/x-javascript" src="chrome://smsflatrate/content/scripts/jquery/js/jquery-1.4.4.min.js"/> but calling $jQuizzle = jQuery.noConflict(); $jQuizzle("#myTabList", window.content.document).hide(); in a js file that is included in the same xul file fails
if I do alert($jQuizzle("#myTabList", window.content.document).html()) it alerts "null"
0

It's not clear what sort of message you want to display. The nsIAlertsService can display messages but I'm not sure how well it queues them. If you want something simpler then perhaps you could just show a custom <tooltip> element.

1 Comment

this is actually what I came up with :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.