Thanks a lot Mark, <div>That works like a charm. I really appreciate your simplified solution sample code. <br><br>Thanks again everyone for your helps. </div><div><br><div class="gmail_quote">On Wed, Oct 10, 2012 at 12:12 PM, Mark Jubenville <span dir="ltr"><<a href="mailto:ioncache@gmail.com" target="_blank">ioncache@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Alternatively if you don't want to do the whole ajax thing, you can
do something similar just checking the text of the body:<br>
<br>
<tt><script><div class="im"><br>
var page_check;<br>
<br>
var nMilliseconds = 60*1000; // frequency of server check in
milliseconds<br>
var checkServerStatus = function () {<br></div>
if ( /Text that you are searching
for/.test(document.body.innerHTML) ) {<br>
// simple javascript alert box<br>
alert("Text you want to display when the search is
found");<br>
<br>
// an actual new window/tab<br>
var
text_window=window.open("","","width=200,height=100");<br>
text_window.document.write("<p>Text you want to
display when the search is found</p>");<br>
text_window.focus();<br>
<br>
clearInterval(page_check);<div class="im"><br>
}<br>
};<br>
page_check = setInterval( checkServerStatus, nMilliseconds );<br></div>
</script></tt><br>
<br>
That doesn't require jQuery either.<br>
<br>
I put in examples of opening an actual window or just showing an
alert box.<div><div class="h5"><br>
<br>
<div>On 2012-10-10 11:40 AM, Mark Jubenville
wrote:<br>
</div>
<blockquote type="cite">
I'd use setInerval instead of setTimeout though:<br>
<br>
<tt>var page_check;</tt><tt><br>
</tt><tt><br>
</tt><tt>var nMilliseconds = 60*1000; // frequency of server check
in milliseconds</tt><tt><br>
</tt><tt> var checkServerStatus = function () {</tt><tt><br>
</tt><tt> $.ajax({ url: "/path/to/your/log/file/script"
}).done(function</tt><tt><br>
</tt><tt> (jqXHR, textStatus) {</tt><tt><br>
</tt><tt> if (/a regexp matching text in your log
file/.test(jqXHR.responseText))</tt><tt> {<br>
</tt><tt> $.facybox("The text you wish the user to see in
the popup dialogue.");<br>
clearInterval(page_check);<br>
}</tt><tt><br>
</tt><tt> });</tt><tt><br>
</tt><tt> };</tt><tt><br>
</tt><tt> page_check = setInterval( checkServerStatus,
nMilliseconds );</tt><br>
<br>
<br>
<br>
<div>On 2012-10-10 11:27 AM, Antonio Sun
wrote:<br>
</div>
<blockquote type="cite">Thanks a lot Shaun.
<div><br>
</div>
<div>That sure will pave my way to the right direction. </div>
<div>I'll start playing. </div>
<div><br>
</div>
<div>Thanks everyone!<br>
<br>
<div class="gmail_quote">On Wed, Oct 10, 2012 at 10:27 AM,
Shaun Fryer <span dir="ltr"><<a href="mailto:sfryer@sourcery.ca" target="_blank">sfryer@sourcery.ca</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi
Antonio,<br>
<br>
That makes sense. Unfortunately it's a little beyond the
scope of a<br>
simple email to provide a complete solution for your
situation.<br>
However, you might try something like the following.<br>
<br>
You'll need two things. #1. an ajax function of some kind.
Given that<br>
you aren't interested in learning JS, I'd recommend using
a<br>
cross-browser abstraction library which has an ajax
method, such as<br>
jQuery. #2. You'll need a popup dialogue of some kind.
There are<br>
plenty to choose from. For the purposes of providing an
example, I've<br>
[arbitrarily] chosen the facybox jQuery plugin. I have no
direct<br>
experience with it, but the API seems simple enough, so it
should work<br>
fine.<br>
<br>
Add a script tag including the jQuery library, followed by
one for the<br>
plugin for your popup ( <a href="http://bitbonsai.com/facybox/" target="_blank">http://bitbonsai.com/facybox/</a>
). Now in a<br>
separate script tag below this, add code similar to that
below<br>
(modified accordingly).<br>
<br>
var nMilliseconds = 60*1000; // frequency of server check
in milliseconds<br>
var checkServerStatus = function () {<br>
$.ajax({ url: "/path/to/your/log/file/script"
}).done(function<br>
(jqXHR, textStatus) {<br>
if (/a regexp matching text in your log
file/.test(jqXHR.responseText))<br>
$.facybox("The text you wish the user to see in the
popup dialogue.");<br>
else setTimeout( checkServerStatus, nMilliseconds );<br>
});<br>
};<br>
setTimeout( checkServerStatus, nMilliseconds );<br>
<br>
The above is just pseudo-code, but it *should* work with
very little<br>
modification, assuming you're using the indicated JS
libraries.<br>
<br>
Hope this helps.<br>
<div>--<br>
Shaun Fryer<br>
----------------------------------------------------------<br>
perl -e 'print chr for map{$_+=22}($ARGV[0])=~/(\d\d)/g'
\<br>
52959394107588899482799210587992861082757785799222<br>
----------------------------------------------------------<br>
<br>
<br>
</div>
<div>
<div>On Wed, Oct 10, 2012 at 9:51 AM, Antonio
Sun <<a href="mailto:antoniosun@lavabit.com" target="_blank">antoniosun@lavabit.com</a>>
wrote:<br>
> Hi, thanks a lot for your offer Shaun.<br>
><br>
> That was actually what I thought the solution to
be. Now let's forget what I<br>
> said and focus on what I need to accomplish.<br>
><br>
> Yes, I totally control the page content. The
situation is,<br>
><br>
> I am designing a web portal that can launch
back-end server side processes.<br>
> The problem is that the process can finish in
seconds, or it might need<br>
> hours to finish, depending how much work the
process has. So my design is to<br>
> spawn a sub process, and capture all its outputs
to a log text file, then<br>
> return immediately to the user, in a web notice
page saying, your job is<br>
> queued; here is the log url; please check
manually if is finished or not.<br>
><br>
> But my all my fellow coworkers said they don't
want to check themselves.<br>
> Instead, they want my web portal to check for
them. I couldn't think of any<br>
> solution from the server side to capture the end
of the sub process, then<br>
> informed the already submitted web notice page.
Hence, I'm turning to the<br>
> javascript front-end for solutions. Because I
have zero knowledge of<br>
> Javascript, it might not be feasible at all. But
I know the best solution is<br>
> that if I can have a desktop notification
mechanism just like gmail does,<br>
> that should solve the problem, because my sub
process control task does know<br>
> when the sub process ends, and write a specific
ending tag to the end of the<br>
> log file, which is what I was planning to
watch/search for. Every page of my<br>
> portal does include a standard master template
(except the log text file),<br>
> so if I can send a signal at the end of my sub
process and capture that by<br>
> the master template, then pop up a javascript
window, that will do as well.<br>
><br>
> Sorry for the lengthy gibberish, hope that you
can figure something out from<br>
> it.<br>
><br>
> Thanks</div></div></blockquote></div></div></blockquote></blockquote>
</div></div><span class="HOEnZb"><font color="#888888"><pre cols="72">--
Mark Jubenville | <a href="mailto:ioncache@gmail.com" target="_blank">ioncache@gmail.com</a></pre>
</font></span></div>
<br>_______________________________________________<br>
toronto-pm mailing list<br>
<a href="mailto:toronto-pm@pm.org">toronto-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/toronto-pm" target="_blank">http://mail.pm.org/mailman/listinfo/toronto-pm</a><br>
<br></blockquote></div><br></div>