[Proto-Scripty] Re: How to correct the following code?

2009-03-11 Thread ColinFine



On Mar 10, 3:49 pm, SamuelXiao  wrote:
> Hi, ColinFine, in my javascript code.  The prev.js is to do links with
> URL preview.  It is expected to show a preview box with linked
> content.  However, in my testing, prev.js can work on its own, when it
> comes to using both script01.js and prev.js together, it doesn't
> work.  My question is how can I correct the code to make the preview
> effect work under the script01.js.  I have tried a few days.  Any help
> would be appreciated!
>
You are *still* using the useless phrase 'doesn't work'.

What happens?

What happens if you run it under firebug?

Colin

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: How to correct the following code?

2009-03-10 Thread SamuelXiao

Hi, ColinFine, in my javascript code.  The prev.js is to do links with
URL preview.  It is expected to show a preview box with linked
content.  However, in my testing, prev.js can work on its own, when it
comes to using both script01.js and prev.js together, it doesn't
work.  My question is how can I correct the code to make the preview
effect work under the script01.js.  I have tried a few days.  Any help
would be appreciated!

On Mar 10, 6:05 pm, ColinFine  wrote:
> On Mar 9, 1:15 pm,SamuelXiao wrote:
>
> > Sorry for my unclear explanation, the following is all my JavaScript
> > code,
>
> > // script01.js //
>
> > obj = new Object();
> > obj.f1 = eventHandler;
> > window.onload = obj.f1;
> > window.onunload = function(){};
>
> > function eventHandler(){
> >         postUpdater();
> >         dynamicEdit();
> >         deleteAlert();
> >         var loc = document.getElementById("newLocation");
> >         loc.selectedIndex = 0;
> >     loc.onchange = jumpPage;
> > Purpose:  What I want to do is making prev.js compatible with
> > script01.js, and make it work.
> > My problem now is that when I include script01.js or prev.js
> > separately, it works well.  But if I include both of them, prev.js
> > will not work.
>
> > My code maybe tedious,ugly and not user-friendly, sorry about that.  I
> > am new to Ajax and could some one give me reference How to write a
> > clear program?
> > And How to solve the above problem.  Thanks.
>
> Quoting all your code may or may not be helpful. The problem is, that
> you still haven't told us what problem you are seeing.
>
> "Doesn't work" might mean anything from "Produces output which looks a
> little different from what I expect" to "Crashes my browser".
>
> What are you expecting to happen, and what actually happens?
>
> Colin
>
> > On Mar 9, 5:39 pm, ColinFine  wrote:
>
> > > On Mar 6,
>
> > ...
>
> > read more »
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: How to correct the following code?

2009-03-10 Thread ColinFine



On Mar 9, 1:15 pm, SamuelXiao  wrote:
> Sorry for my unclear explanation, the following is all my JavaScript
> code,
>
> // script01.js //
>
> obj = new Object();
> obj.f1 = eventHandler;
> window.onload = obj.f1;
> window.onunload = function(){};
>
> function eventHandler(){
>         postUpdater();
>         dynamicEdit();
>         deleteAlert();
>         var loc = document.getElementById("newLocation");
>         loc.selectedIndex = 0;
>     loc.onchange = jumpPage;
> Purpose:  What I want to do is making prev.js compatible with
> script01.js, and make it work.
> My problem now is that when I include script01.js or prev.js
> separately, it works well.  But if I include both of them, prev.js
> will not work.
>
> My code maybe tedious,ugly and not user-friendly, sorry about that.  I
> am new to Ajax and could some one give me reference How to write a
> clear program?
> And How to solve the above problem.  Thanks.
>
Quoting all your code may or may not be helpful. The problem is, that
you still haven't told us what problem you are seeing.

"Doesn't work" might mean anything from "Produces output which looks a
little different from what I expect" to "Crashes my browser".

What are you expecting to happen, and what actually happens?

Colin

> On Mar 9, 5:39 pm, ColinFine  wrote:
>
> > On Mar 6,
>
> ...
>
> read more »
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: How to correct the following code?

2009-03-09 Thread SamuelXiao

Sorry for my unclear explanation, the following is all my JavaScript
code,

// script01.js //

obj = new Object();
obj.f1 = eventHandler;
window.onload = obj.f1;
window.onunload = function(){};

function eventHandler(){
postUpdater();
dynamicEdit();
deleteAlert();
var loc = document.getElementById("newLocation");
loc.selectedIndex = 0;
loc.onchange = jumpPage;
}

function postUpdater() {
var myAjax = new Ajax.PeriodicalUpdater(
"recentPost",
"recentPost.php",
{
method: 'get',
frequency: 50
});
}

function dynamicEdit() {
for(var j=0;;j++){
if($('theTitle'+j) && $('postid'+j)){
   new Ajax.InPlaceEditor(
  'theTitle'+j,
  
'answer.php?ident=Title&postid='+$('postid'+j).value+'&content='+$
('content'+j).value+'&author='+$('userId').value,
  {
 formId: 'whatever',
 okText: 'Edit !',
 cancelText: 'Cancel'
  }
   );
   }

   if($('theCont'+j) && $('postid'+j)){
   new Ajax.InPlaceEditor(
  'theCont'+j,
  'answer.php?ident=Content&postid='+ 
$('postid'+j).value+'&title='+
$('title'+j).value+'&author='+$('userId').value,
  {
 formId: 'whatever',
 okText: 'Edit!',
 cancelText: 'Cancel',
 rows:10,
 cols: 45
  }
   );
   }
   if(!$('theTitle'+j) && !$('theCont'+j)){ break;}
}
}

function deleteAlert(){
var formid = document.getElementsByName("deleteid");
for(var k=0;khttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
http://www.w3.org/1999/xhtml";>


  XXX
  

 
http://yui.yahooapis.com/
2.7.0/build/paginator/assets/skins/sam/paginator.css" />
http://yui.yahooapis.com/2.7.0/
build/yahoo-dom-event/yahoo-dom-event.js">
http://yui.yahooapis.com/2.7.0/
build/element/element-min.js">
http://yui.yahooapis.com/2.7.0/
build/paginator/paginator-min.js">












  


  
Home
Create post
  



  

  
  

  




';
echo 'Welceome!  '.$currentUser.'';

$var=file_get_contents("http://studentid:passw...@www.myschool.edu/
getPost.py?author=".$currentUser."&type=html");
$var=explode("", $var);

$varLen = count($var);

$yuij=1;

$counter = 1;
echo ''."\n\t";
#
echo ''."\n\t";

#length - 2; because  is counted;
for($i = $varLen-2; $i>=0;$i--){
echo ""."\n\t";
echo ''."\n\t";

#finding title:
if(preg_match("/Title:/",$var[$i])){
$tlen =strpos($var[$i],'Title:')+11;
$clen = strpos($var[$i],'Content:')-10;
$tname = 
substr($var[$i],$tlen,($clen-$tlen));

echo ''.$tname.''."\n\t";
echo ''."\n\t";
echo '';
}

#finding Content:
if(preg_match("/Content:/",$var[$i])){
$ctlen = strpos($var[$i],'Content:')+13;
$ctlast = strripos($var[$i],'');
$cont = 
substr($var[$i],$ctlen,($ctlast-$ctlen));

$cont = html_entity_decode($cont);
echo ''.$cont.'';
echo ''."\n\t";
}

#finding Updated:
if(preg_match("/Updated:/",$var[$i])){
$uppos =strpos($var[$i],'Updated:')+13;
$uplen = strpos($var[$i],'Title:')-4;

#date
$up = 
substr($var[$i],$uppos,($uplen-$uppos));

[Proto-Scripty] Re: How to correct the following code?

2009-03-09 Thread ColinFine



On Mar 6, 5:30 pm, SamuelXiao  wrote:
> Hi, David, it seems that periodicalupdater send request first,
> breaking down the preview code
> setting new Ajax.Request.  And the object is no longer refering to the
> gotopreview function.
> Because the firebug console returns the link that the
> periodicalupdater request sever to update something,
> just after that I move over any of the four elements (toplink), it
> doesn't work.
>
I'm sorry, I don't understand what you say is happening. There should
be no relationship between the PeriodicalUpdater and the other
Request. What do you mean when you say it 'breaks down' the preview
code - what actually happens?
You say 'the object is no longer referring to the gotopreview
function', but I don't know which object you mean.

Colin

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: How to correct the following code?

2009-03-06 Thread SamuelXiao

Hi, David, it seems that periodicalupdater send request first,
breaking down the preview code
setting new Ajax.Request.  And the object is no longer refering to the
gotopreview function.
Because the firebug console returns the link that the
periodicalupdater request sever to update something,
just after that I move over any of the four elements (toplink), it
doesn't work.

Event.observe(window,'load',function(){
var elms = document.getElementsByClassName("toplink");
Event.observe(elms[0],'mouseover',function(ev){gotopreview(ev,
0);});
Event.observe(elms[1],'mouseover',function(ev){gotopreview(ev,
1);});
Event.observe(elms[2],'mouseover',function(ev){gotopreview(ev,
2);});
Event.observe(elms[3],'mouseover',function(ev){gotopreview(ev,
3);});

});

So, my question is, how can I do the following things.
1. PreriodicalUpdater sending data to Sever and Sever return
something;
2. Then, Event.observe(elms[x]) can keep doing its part of job without
being broken by preriodicalUpdater.

Is it my logic correct? or Wrong somewhere?  Thanks for your help.



On Mar 6, 8:24 pm, david  wrote:
> Hi SamuelXiao,
>
> about the bind or bindAsEventListener method, it does not help in your
> case.
> Those two functions are used to force the value of 'this', but you are
> not inside a class, and do not use 'this' inside the gotopreview
> function.
>
> I made testiung with given code, but there is some elements missing,
> is it possible to have a live exemple to see the problem
>
> --
> david
>
> On 2 mar, 14:11, SamuelXiao  wrote:
>
> > My code is to preview webpages when user move mouse over .  At
> > the same time, my code has other parts using Prototype
> > periodicalupdater.
> > The following code can work well independently:
>
> > // javascript preview program start
> > var ci;
> > var xPos,yPos;
> > Event.observe(window,'load',function(){
> >         var elms = document.getElementsByClassName("toplink");
> >         Event.observe(elms[0],'mouseover',function(ev){gotopreview(ev,
> > 0);});
> >         Event.observe(elms[1],'mouseover',function(ev){gotopreview(ev,1);});
> >         Event.observe(elms[2],'mouseover',function(ev){gotopreview(ev,2);});
> >         Event.observe(elms[3],'mouseover',function(ev){gotopreview(ev,3);});
>
> > });
>
> >  function gotopreview(event,ci){
> >     alert(ci);
> >         xPos = Event.pointerX(event);
> >         yPos = Event.pointerY(event);
> >         var getpostid=document.getElementsByName("targetpid");
> >         var getsid = document.getElementsByName("stdid");
> >         var url = "getOnePost.php";
> >         var pars = "stdid="+getsid[ci].value + "&targetpid=" + getpostid
> > [ci].value;
>
> >         var myajax = new Ajax.Request(url,{
> >                 method:'get',
> >             parameters: pars,
> >                 asynchronous: true,
> >                 onSuccess: function(transport){
> >                         $('previewWin').update(transport.responseText);
> >                         $('previewWin').style.top = parseInt(yPos) + 2 + 
> > "px";
> >                         $('previewWin').style.left = parseInt(xPos) + 2 + 
> > "px";
> >                         $('previewWin').style.visibility = "visible";
> >                         $('previewWin').onmouseout =function(){ $
> > ('previewWin').style.visibility = "hidden";}
>
> >                 }
> >         });}
>
> > // javascript preview program end
> > // The above code can work well independently.
>
> > And my html page is link:
> > 
> > 
> > 
> > 
> > XXX
> > XXX
> > XXX
> > XXX
> > 
> > 
> > 
>
> > But when it comes to work with the periodical updater, it seems that
> > periodicalupdater send request first, breaking down the preview code
> > setting new Ajax.Request.  And the object is no longer refering to the
> > gotopreview function.
>
> > The following is my periodical code,
>
> > obj = new Object();
> > obj.f1 = eventHandler;
> > window.onload = obj.f1;
> > window.onunload = function(){};
>
> > function eventHandler(){
> >         postUpdater();
>
> > }
>
> > function postUpdater() {
> >         var myAjax = new Ajax.PeriodicalUpdater(
> >                 "recentPost",
> >                 "recentPost.php",
> >                 {
> >                         method: 'get',
> >                         frequency: 50
> >                 });
>
> > }
>
> > I use firebug to check the program and found that before I move mouse
> > over the "toplink" anchor, the postUpdater() function will send
> > request to the Sever thus, my preview code is no longer work.  I know
> > that there is bind and bindAsListener function to bind the gotopreview
> > function.  I tried but it's not work also, could some one help me or
> > tell me how to modify the code to make it work?  Is there any way stop
> > the periodicalUpdater when it is loaded?  Or if I must to use bind or
> > bindAsListener, how to write it correctly in the above code?  Any help
> > would be appreciated!
--~--~-~--~--

[Proto-Scripty] Re: How to correct the following code?

2009-03-06 Thread david

Hi SamuelXiao,

about the bind or bindAsEventListener method, it does not help in your
case.
Those two functions are used to force the value of 'this', but you are
not inside a class, and do not use 'this' inside the gotopreview
function.

I made testiung with given code, but there is some elements missing,
is it possible to have a live exemple to see the problem

--
david

On 2 mar, 14:11, SamuelXiao  wrote:
> My code is to preview webpages when user move mouse over .  At
> the same time, my code has other parts using Prototype
> periodicalupdater.
> The following code can work well independently:
>
> // javascript preview program start
> var ci;
> var xPos,yPos;
> Event.observe(window,'load',function(){
>         var elms = document.getElementsByClassName("toplink");
>         Event.observe(elms[0],'mouseover',function(ev){gotopreview(ev,
> 0);});
>         Event.observe(elms[1],'mouseover',function(ev){gotopreview(ev,1);});
>         Event.observe(elms[2],'mouseover',function(ev){gotopreview(ev,2);});
>         Event.observe(elms[3],'mouseover',function(ev){gotopreview(ev,3);});
>
> });
>
>  function gotopreview(event,ci){
>     alert(ci);
>         xPos = Event.pointerX(event);
>         yPos = Event.pointerY(event);
>         var getpostid=document.getElementsByName("targetpid");
>         var getsid = document.getElementsByName("stdid");
>         var url = "getOnePost.php";
>         var pars = "stdid="+getsid[ci].value + "&targetpid=" + getpostid
> [ci].value;
>
>         var myajax = new Ajax.Request(url,{
>                 method:'get',
>             parameters: pars,
>                 asynchronous: true,
>                 onSuccess: function(transport){
>                         $('previewWin').update(transport.responseText);
>                         $('previewWin').style.top = parseInt(yPos) + 2 + "px";
>                         $('previewWin').style.left = parseInt(xPos) + 2 + 
> "px";
>                         $('previewWin').style.visibility = "visible";
>                         $('previewWin').onmouseout =function(){ $
> ('previewWin').style.visibility = "hidden";}
>
>                 }
>         });}
>
> // javascript preview program end
> // The above code can work well independently.
>
> And my html page is link:
> 
> 
> 
> 
> XXX
> XXX
> XXX
> XXX
> 
> 
> 
>
> But when it comes to work with the periodical updater, it seems that
> periodicalupdater send request first, breaking down the preview code
> setting new Ajax.Request.  And the object is no longer refering to the
> gotopreview function.
>
> The following is my periodical code,
>
> obj = new Object();
> obj.f1 = eventHandler;
> window.onload = obj.f1;
> window.onunload = function(){};
>
> function eventHandler(){
>         postUpdater();
>
> }
>
> function postUpdater() {
>         var myAjax = new Ajax.PeriodicalUpdater(
>                 "recentPost",
>                 "recentPost.php",
>                 {
>                         method: 'get',
>                         frequency: 50
>                 });
>
> }
>
> I use firebug to check the program and found that before I move mouse
> over the "toplink" anchor, the postUpdater() function will send
> request to the Sever thus, my preview code is no longer work.  I know
> that there is bind and bindAsListener function to bind the gotopreview
> function.  I tried but it's not work also, could some one help me or
> tell me how to modify the code to make it work?  Is there any way stop
> the periodicalUpdater when it is loaded?  Or if I must to use bind or
> bindAsListener, how to write it correctly in the above code?  Any help
> would be appreciated!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---