bootstrap collapsible panel rule...

Hi there!

This code (below) works as expected, but I would like to avoid the "4-min refresher" not only when there is a video in the page, but also when the user is typing an online question , that is, when the collapsible panel is open. Reason: when the page refreshes, the panel closes and the user "looses" the content typed!

<script type="text/javascript" language="javascript">
      $(function () {
    var pageTimeout

        function resetTimer() {
            pageTimeout = setTimeout(timeoutExpired,  240000);

    $(document.body).bind('mousemove,keydown,click', resetTimer);

    $('#collapsePanelQuestion').on('', function () {resetTimer();})       
//if user is not typing a "Have a Question", we may reload page if already 4 min without other activities

    <% If (Not thereisvideoinpage) Then %>
    <% end if %>

    function timeoutExpired() {
        window.location.reload() // if not activity for 4 minutes reload page, 1min = 60 000

The part in bold is the way I have tried to put it to work, but the page refreshes every 4min even when the collapsible panel is open, therefore my solution is wrong.

Could someone change my code so that it works as expected?

Thanks a lot,
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Big MontyWeb Ninja at largeCommented:
if you want to call the refreshTimer() function when the user is typing, why not check the container they're typing into. let's say you have a textbox they're typing into called txt1, you could do something like this:

$( "#txt1" ).keypress(function() {

Open in new window

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Instead of the page reload, you can hit another page via ajax.  But you would be better off using some type of token http:/Q_28634665.html#a40678923

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fskilnikAuthor Commented:
Hello there!

Thank you both for coming here, and very sorry for my delay!

@Big Monty:  I guess you had a simple and great idea, but I guess I need something slightly different, in the sense that while the user is typing, I want the resetTimer NOT to work.  (I really know nothing about javascript, therefore although I guess the correction in your code is really easy, I cannot do it. Please help!)

@Scott Fell: I´ve read your careful suggestion and I am VERY inclined to make as you suggest in the near-future. But, for the moment, I have to have a "solution working", because my students are using the online environment while I am implementing all this. (I am NOT a professional programmer but a maths teacher. The fact that I am able to even explain my difficulties and implement all suggestions you all give me here at EE - till now, at least - makes me really proud, but of course I suffer and take much longer time than I should need IF I had the proper experience and qualifications...)
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Big MontyWeb Ninja at largeCommented:
i see what you're saying, makes sense...

let me ask you this, do you want to cancel the page refresh only while the user is typing? or do you want to cancel the page refresh once the user starts typing for the life of the page? this means the user starts typing, you cancel the refresh() function and it never turns back on after the user is done typing...this would mean if the user goes and gets a cup of coffee and returns ten minutes later to submit the page, you'll run into problems, right?
fskilnikAuthor Commented:
Hi, Big Monty!


In other words: I want the refresh to restart working after the user updates that page that is "behind" the form he is filling. If he starts typing, stops to get some coffee, the best scenario would be NOT to refresh because the collapsible panel in which the textarea he is filling is still open but... I don´t know if it is easy to handle this.
fskilnikAuthor Commented:
Let me ask you something, Big Monty:

<form class="form-horizontal" id="idForm" name="idForm" method="post" action="../../Codes_my/ins_questionDB.asp">

The form is "initiated" like above, therefore he must press "send" button to run the insertion storeprocedure.

Is there a way to change this, so that IF the page reloads, the insertion store procedure runs anyway?  I guess this would be great, because after the reloading, the user WILL be able to "edit" (and therefore complete, for instance) his/her question... got it?
Big MontyWeb Ninja at largeCommented:
the best scenario would be NOT to refresh because the collapsible panel in which the textarea he is filling is still open

but if they come back in an hour or two, they're session on the site will be lost, no?
fskilnikAuthor Commented:
Yes... but in this case I guess the form has already a hidden variable with the user´s ID, therefore the database would be updated and THEN the user would be redirected to the (re)login page... when he is redirected to the page before-expiration, he would see the page updated, because the database was, accordingly.

In other words, if you agree and help me with my last suggestion (I mean, being able to run the updating when the page refreshes, not only when the button is pressed), we were able to solve the problem in a very pleasant way...

WHat do you think?
fskilnikAuthor Commented:
Hello, Big Monty!

I guess you did not answer my last post because you saw that I will try to implement Scott Fell´s "token idea" in the next days (or one or two weeks, depending on my difficulties).

Anyway, I will spare your efforts if you simply haven´t had time to come back here (and would in the next few days), because I have decided to stop the "refresh" behavior for good, not only because it is bothering some students (they say that when a page refreshes, the position at the page they were, before refreshing, was lost), but also because Scott Fell´s suggestion (token idea) is also the proper way of dealing with my site for now on. I am sure you agree, therefore I will take the time needed to make the change.

THanks a lot for your expertise and advice/answers, as usual. I hope to "see" you again in other EE posts!

All the best and Kind Regards,
Big MontyWeb Ninja at largeCommented:
Ya I figured as much, that's why I gradually phased myself out of answering, as to not confuse you going forward. while it'll take longer to implement, it is indeed the proper solution for your situation, so no worries there.

good luck and happy programming!
fskilnikAuthor Commented:
Big Monty!

You are not only a great programmer, but also a gentleman.   :)

Thanks a LOT, as usual, also for your understanding and for your approval on my decision. It´s good to know I am really on the right track.

Kind Regards,
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.