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

2009-03-11 Thread ColinFine



On Mar 10, 3:49 pm, SamuelXiao foolsmart2...@gmail.com 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 ColinFine



On Mar 9, 1:15 pm, SamuelXiao foolsmart2...@gmail.com 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 colin.f...@pace.com 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 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 colin.f...@pace.com wrote:
 On Mar 9, 1:15 pm,SamuelXiaofoolsmart2...@gmail.com 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 colin.f...@pace.com 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 ColinFine



On Mar 6, 5:30 pm, SamuelXiao foolsmart2...@gmail.com 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-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=Titlepostid='+$('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=Contentpostid='+ 
$('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;kformid.length;k++){
formid[k].onclick=function(){
return confirm(Are you sure to delete this post?);
}
}
}

function jumpPage(){
var newLoc = document.getElementById(newLocation);
var newPage = newLoc.options[newLoc.selectedIndex].value;
if(newPage != ){window.location = newPage;}
}


--End of
script01.js--

//prev.js code//

 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;}

}
});
}

-End of
prev.js--

// Yahoo UI paginator yuifunction.js //

// YUI Paginator
YAHOO.util.Event.onDOMReady(function () {
// Set up the application under the YAHOO.example namespace
var Ex = YAHOO.namespace('example');
Ex.content= YAHOO.util.Dom.get('yuicontent');
Ex.handlePagination = function (state) {
// Show the appropriate content for the requested page
Ex.content.className = 'page' + state.page;
// Update the Paginator's state, confirming change
Ex.paginator.setState(state);
};
// Create the Paginator widget and subscribe to its changeRequest
event
Ex.paginator = new YAHOO.widget.Paginator({
rowsPerPage : 3,
totalRecords : Ex.content.getElementsByTagName('div').length,
containers : 'paging'
});
Ex.paginator.subscribe('changeRequest', Ex.handlePagination);
// Render the Paginator into the configured 

[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 foolsmart2...@gmail.com wrote:
 My code is to preview webpages when user move mouse over a/a.  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:
 html
 head
 /head
 body
 a class=toplink value=XX/a
 a class=toplink value=XX/a
 a class=toplink value=XX/a
 a class=toplink value=XX/a
 div id=previewWin/div
 /body
 /html

 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
-~--~~~~--~~--~--~---