Write to Log on Tab Switch

22 views
Skip to first unread message

CSEL

unread,
Dec 16, 2010, 4:51:30 PM12/16/10
to Shelve Firefox Add-on
As far as I can tell, Shelve will only write to log files when new
pages are loaded (on "DOMContentLoaded", I think). Is there a
straightforward modification to shelve.js that would allow it to write
to the log file on tab changes as well as on new page loads? Thanks
for the help.

lith

unread,
Dec 16, 2010, 5:56:52 PM12/16/10
to Shelve Firefox Add-on
> to the log file on tab changes as well as on new page loads?

What exactly do you mean with tab changes and new page loads? Could
you please describe in what situations you want shelve to write a log
entry. You're right that shelve is currently triggered by the
DOMContentLoaded event. How would "new page loads" differ from that?

CSEL

unread,
Dec 17, 2010, 12:50:57 AM12/17/10
to Shelve Firefox Add-on
Basically what I want to do is use Shelve to maintain a log of which
webpage a user is viewing at any given point in time, even when they
are using multiple tabs (though assuming only one browser window is
open at a time).

For example, if a user ran a search on google.com in one tab (i.e.,
loaded the page at time1), opened one of the results in a second tab
(at t2), switched back to the first tab (at t3), and then clicked on a
different result to open a new page in a third tab (at t4), the log
would read t0: google.com, t1: ResultPage1.com, t4: ResultPage2.com.
What I am trying to accomplish is to have Shelve treat such tab
changes (e.g., the change from tab 2 back to tab 1 at t3) as if the
user reloaded the page in tab 1. Thus, in this example, the log would
instead read t1: google.com, t2: ResultPage1.com, t3: google.com, t4:
ResultPage2.com.

Hopefully my example actually made things clearer. If not, I'm happy
to try again or provide additional details. Thanks very much for the
prompt reply!

CSEL

unread,
Dec 17, 2010, 12:54:45 AM12/17/10
to Shelve Firefox Add-on
Sorry, in the current state the log would read t1: google.com, t2:
ResultPage1.com, t4: ResultPage2.com (not t0 and t1). Sorry for the
added confusion.

CSEL

unread,
Dec 17, 2010, 1:06:13 AM12/17/10
to Shelve Firefox Add-on
> How would "new page loads" differ from that?

Just to clarify this point also, "new page loads" are the same as
DOMContentLoaded events for my purposes. It was just a poorly worded
question. I should have written something like "...that would allow it
to write to the log file on tab changes [in addition to] on new page
loads [, which it does already]." Apologies again for the confusion.



On Dec 16, 5:56 pm, lith <minil...@gmail.com> wrote:

CSEL

unread,
Dec 21, 2010, 1:34:15 PM12/21/10
to Shelve Firefox Add-on
In case it would be helpful to somebody else, I was able to accomplish
my goal by adding the following function and listener to shelve.js:

//Added to var shelve =
logOnTabSelect: function() {
var evt = document.createEvent('Event');
evt.initEvent('load',true,true);
shelve.autoSelectShelve(evt);
},

//Added to shelve.setupAutoSelect function
window.addEventListener('TabSelect', shelve.logOnTabSelect, true);

lith

unread,
Dec 22, 2010, 12:11:08 PM12/22/10
to Shelve Firefox Add-on
Hi,

> In case it would be helpful to somebody else, I was able to accomplish
> my goal by adding the following function and listener to shelve.js:

Thanks for figuring this out. In the next version there will be an
boolean preference extensions.shelve.events.TabSelect that will enable
this. Since it really seems a very special use case, I won't add a gui
though.

Regards,
Tom
Reply all
Reply to author
Forward
0 new messages