[Proto-Scripty] Re: Periodical Updater detect content change
There is also a Form.observer http://www.prototypejs.org/api/timedObserver/form-observer I used to use this but implemented my own version of it with a cache and some hashing, it didnt take long to write and works perfectly HTH Alex - Original Message - From: Aamchi aman.ra...@googlemail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, June 23, 2009 11:19 PM Subject: [Proto-Scripty] Re: Periodical Updater detect content change Thanks, for your response. I'm not 100% sure if I understand correctly what you mean. If I get some data and generate a hash and write this to the JSON header and retrieve this when calling onSuccess, how will I still have the previous hash? From where will I get this? Won't the updated data cause the hash to be overwritten in the JSON header? Or do I have to send two hashes always and compare them? On 23 Jun., 22:57, Richard Quadling rquadl...@googlemail.com wrote: 2009/6/23 Aamchi aman.ra...@googlemail.com Hi, I was wondering if Ajax.PeriodicalUpdater can detect if content has changed since the last update and if so trigger an event. So for example I have a scoreboard which fetches data every 5 seconds and displays this. I would be cool if there could be some kind of notification if content had changed. I know that the new content is stores in responseText but how can I compare it to the previous content... Thanks, Aman Personally, I would do this server side. Assuming you get the data in some sort of structure before either rending some HTML and sending it or just sending it JSON'd, then you should be able to build a hash of the data. See [1] for info on Hash Functions. So. If you sent the hash value in a X-JSON header along with an onSuccess() callback, you can extract the hash from the second param to the onSuccess and compare this with the previously retrieved hash to indicate you've got changed data. See [2] for details about PeriodicalUpdater update notification and [3] for the parameters to common callbacks. Regards, Richard. [1]http://en.wikipedia.org/wiki/Hash_function [2]http://www.prototypejs.org/api/ajax/periodicalUpdater http://www.prototypejs.org/api/ajax/periodicalUpdater[3]http://www.prototypejs.org/api/ajax/options http://www.prototypejs.org/api/ajax/options -- - Richard Quadling Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! --~--~-~--~~~---~--~~ 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: php in files
Ok, let me put my idea to you and see if there is a way without reloading the whole page - I use prototype.js and project.js. project.js is just my entensions for each project, which I have narrowed down to two functions, - function myRequest( text ) { new Ajax.Request('requests.php', { method: 'post', postBody: text, onComplete: myResponse }); } function myResponse(req) { $(targetdiv).innerHTML= req.responseText; } Where text is supplied from the controls, such as 'page=home'. request.php is the only php file called directly, it decides which response is wanted and returns the text for a control or entire body for div id='mainbody'/div All of my pages and controls within them are created in php from the database. This is very easy to maintain and update, so a nice base for all kinds of applications All works well if I only respond with html including the ajax side that recalls requests.php, the only problem is that I intended some of the pages to be applications, so I want them to have php and can not see a way to pass it through the preprocessor. My request.php at the server side is like this - $Home=$button=$update=$testButton=$menuItem=; extract($_POST,EXTR_IF_EXISTS); if($menuItem != ) { $retstr = ; $dbconn = getdbconnection(); //find page associated with this menu item $query = 'SELECT body FROM menu WHERE name=\''.$menuItem.'\''; $result = pg_query($dbconn,$query) or die('Query failed: ' . pg_last_error()); $row = pg_fetch_row($result); //read in the file if(file_exists($row[0])) { $handle = fopen($row[0],r); $retstr = fread($handle,filesize($row[0])); fclose($handle); //failed attempt to use include instead //$retstr = ?php include .$row[0].; ?; } else { $retstr = File not created yet; } pg_close($dbconn); echo $retstr; } In the end this would leave me with only one main page index.php and all other pages called up via ajax and created or loaded via php. I have the feeling now that I have to update the whole page, not a terrible tragedy, but I just have the feeling that I can somehow put my fread() file through the php preprocessor. On Jun 23, 3:09 pm, Richard Quadling rquadl...@googlemail.com wrote: 2009/6/23 Robaj robrass...@gmail.com: I know this isn't strictly speaking a Prototype issue, but this is the only group I am in and a few topics do skirt around the edges of your main topic. If I have a file - home.php ?php echo h1A very interesting home page/h1; ? Then the file is returned to go into div id=mainbody/div with a plain fread() into a variable which is 'echo'd back to the client. 'include'ing this file is fine, but then it passes through php at the same time as everything else. But any such file loaded as the action of an Ajax call is not fine. It doesn't get passed via php, or at least I don't think it does - because in 'mainbody' I get part of it such as Interesting; ? Confusing because if it were being passed through php I would expect 'Interesting'. but if it were not, then I would expect the whole file in plain text. I knew when I did this with fread I was probably heading for trouble, but which is happening, partial php parseing, no php parseing or . ? If you use fread(), you are reading a file. Any file. Nothing magic. No processing. If you use include()/require()/include_once()/require_once(), then PHP will process that file if it contains a valid opening tag (?php). Uploading a file does NOT process the file. The file is only processed when it is requested. Can you provide any more information about what you are trying to do? Maybe using the PHP General list would also be a better place for this thread? (http://docs.php.net/mailing-lists.php) Regards, Richard. -- - Richard Quadling Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! --~--~-~--~~~---~--~~ 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: Periodical Updater detect content change
I thought of that too. But this only works in forms doesn't it? How do I detect a changed within a div which is reloaded every few seconds? Would you mind sending me an example? Thanks, Aman On 24 Jun., 08:36, Alex McAuley webmas...@thecarmarketplace.com wrote: There is also a Form.observerhttp://www.prototypejs.org/api/timedObserver/form-observer I used to use this but implemented my own version of it with a cache and some hashing, it didnt take long to write and works perfectly HTH Alex - Original Message - From: Aamchi aman.ra...@googlemail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, June 23, 2009 11:19 PM Subject: [Proto-Scripty] Re: Periodical Updater detect content change Thanks, for your response. I'm not 100% sure if I understand correctly what you mean. If I get some data and generate a hash and write this to the JSON header and retrieve this when calling onSuccess, how will I still have the previous hash? From where will I get this? Won't the updated data cause the hash to be overwritten in the JSON header? Or do I have to send two hashes always and compare them? On 23 Jun., 22:57, Richard Quadling rquadl...@googlemail.com wrote: 2009/6/23 Aamchi aman.ra...@googlemail.com Hi, I was wondering if Ajax.PeriodicalUpdater can detect if content has changed since the last update and if so trigger an event. So for example I have a scoreboard which fetches data every 5 seconds and displays this. I would be cool if there could be some kind of notification if content had changed. I know that the new content is stores in responseText but how can I compare it to the previous content... Thanks, Aman Personally, I would do this server side. Assuming you get the data in some sort of structure before either rending some HTML and sending it or just sending it JSON'd, then you should be able to build a hash of the data. See [1] for info on Hash Functions. So. If you sent the hash value in a X-JSON header along with an onSuccess() callback, you can extract the hash from the second param to the onSuccess and compare this with the previously retrieved hash to indicate you've got changed data. See [2] for details about PeriodicalUpdater update notification and [3] for the parameters to common callbacks. Regards, Richard. [1]http://en.wikipedia.org/wiki/Hash_function [2]http://www.prototypejs.org/api/ajax/periodicalUpdater http://www.prototypejs.org/api/ajax/periodicalUpdater[3]http://www.prototypejs.org/api/ajax/options http://www.prototypejs.org/api/ajax/options -- - Richard Quadling Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! --~--~-~--~~~---~--~~ 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: Periodical Updater detect content change
Hope this helps. Ajax/Prototype/JSON PeriodicalUpdater: A working example – log update on a background process http://joekuan.wordpress.com/2009/06/22/ajaxprototypejson-periodicalupdater-a-working-example-log-update-on-a-background-process-part-12/ On Jun 23, 3:20 pm, Aamchi aman.ra...@googlemail.com wrote: Hi, I was wondering if Ajax.PeriodicalUpdater can detect if content has changed since the last update and if so trigger an event. So for example I have a scoreboard which fetches data every 5 seconds and displays this. I would be cool if there could be some kind of notification if content had changed. I know that the new content is stores in responseText but how can I compare it to the previous content... Thanks, Aman --~--~-~--~~~---~--~~ 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] drag and drop tr from one table to another table.
Hi all, I am using scriptaculous drag functionality in table tr element. Now I am facing the following issues. I can drag a row from one table to another table but 1. While i drag a row, it gets invisible from view (not visible) 2. I applied border style for table td element but it is not working after creating Draggable object. System info: 1. scriptaculous.js v1.8.2 2. IE 7 3. Vista by Nivash Ramachandran India. --~--~-~--~~~---~--~~ 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] escapeHTML incomplete?
Hi, I just tried to put a json object inside an attribute an I bumped into an issue with String#escapeHTML(). The method does escape all the ampersands and the greater/less than signs, but it does nothing to the quots. This make the method completely unusable for writing attributes (for innerHTML use). Lets get through an example: var eventMemo = { aLabel: 'some String with quotes, \'apostrophes\'...', otherLabel: 'another String with ampersands and tags' }; //I want this object inside an html attribute, so lets //make it JSON and escape it: var attr = Object.toJSON(eventMemo).escapeHTML(); var link = 'a href=javascript:; class=fireCustomEvent'+ ' data-eventMemo=' + attr + ' '+ ' this link is supposed to fire custom event with memo '+ ' read from data-eventMemo attribute '+ '/a'; //lets see what this link looks like in Firebug: console.log(link); The output is: a href=javascript:; class=fireCustomEvent data-eventMemo={aLabel: some String with \quotes\, 'apostrophs'..., otherLabel: another String with amp;ampersands and lt;tagsgt;} this link is supposed to fire custom event with memo read from data-eventMemo attribute/a As you can see, the output is completely broken, as the are not converted to quot; and ' to #39; One have to append another replaces to properly escape the string: var attr = Object.toJSON(eventMemo).escapeHTML().gsub(//,'quot;').gsub(/'/,'#39;'); The example in the documentation of escapeHTML also contains this error, but no warning about this behaviour. IMHO: 1. A note should be added to the docs about this issue, and an example how to properly escape string for use inside attributes; 2. A parameter could be added tho this method which would escape quotes automaticly. Or a separate function could be introduced, eg. escapeHTMLquots() which would do the same unconditionally. 3. Current behaviour of method can not be changed, as this would create backward incompatibility. I will place an issue about the docs, and I would like to hear your opinion about the method modifications. Best Regards, SWilk --~--~-~--~~~---~--~~ 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: php in files
I really think you are overthinking this! If you want to echo out ?php echo('FOO'); ? for instance and have the preprocessor parse it... you need to (dangerously) eval it $variable=?php echo('pfoo/p'); ?; eval($variable); ... pfoo/p is returned to the browser... So (and i highly do not recommend this unless you truely trust the text in your database and the files it is opening) u must use php's eval(); Like so ... (using your variables) eval($retstr); then anything inside that variable or file will be evall'd as opcode and passed through the pre-processor and you will be left with html or whatever your php code spits out! HTH Alex - Original Message - From: Robaj robrass...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, June 24, 2009 7:44 AM Subject: [Proto-Scripty] Re: php in files Ok, let me put my idea to you and see if there is a way without reloading the whole page - I use prototype.js and project.js. project.js is just my entensions for each project, which I have narrowed down to two functions, - function myRequest( text ) { new Ajax.Request('requests.php', { method: 'post', postBody: text, onComplete: myResponse }); } function myResponse(req) { $(targetdiv).innerHTML= req.responseText; } Where text is supplied from the controls, such as 'page=home'. request.php is the only php file called directly, it decides which response is wanted and returns the text for a control or entire body for div id='mainbody'/div All of my pages and controls within them are created in php from the database. This is very easy to maintain and update, so a nice base for all kinds of applications All works well if I only respond with html including the ajax side that recalls requests.php, the only problem is that I intended some of the pages to be applications, so I want them to have php and can not see a way to pass it through the preprocessor. My request.php at the server side is like this - $Home=$button=$update=$testButton=$menuItem=; extract($_POST,EXTR_IF_EXISTS); if($menuItem != ) { $retstr = ; $dbconn = getdbconnection(); //find page associated with this menu item $query = 'SELECT body FROM menu WHERE name=\''.$menuItem.'\''; $result = pg_query($dbconn,$query) or die('Query failed: ' . pg_last_error()); $row = pg_fetch_row($result); //read in the file if(file_exists($row[0])) { $handle = fopen($row[0],r); $retstr = fread($handle,filesize($row[0])); fclose($handle); //failed attempt to use include instead //$retstr = ?php include .$row[0].; ?; } else { $retstr = File not created yet; } pg_close($dbconn); echo $retstr; } In the end this would leave me with only one main page index.php and all other pages called up via ajax and created or loaded via php. I have the feeling now that I have to update the whole page, not a terrible tragedy, but I just have the feeling that I can somehow put my fread() file through the php preprocessor. On Jun 23, 3:09 pm, Richard Quadling rquadl...@googlemail.com wrote: 2009/6/23 Robaj robrass...@gmail.com: I know this isn't strictly speaking a Prototype issue, but this is the only group I am in and a few topics do skirt around the edges of your main topic. If I have a file - home.php ?php echo h1A very interesting home page/h1; ? Then the file is returned to go into div id=mainbody/div with a plain fread() into a variable which is 'echo'd back to the client. 'include'ing this file is fine, but then it passes through php at the same time as everything else. But any such file loaded as the action of an Ajax call is not fine. It doesn't get passed via php, or at least I don't think it does - because in 'mainbody' I get part of it such as Interesting; ? Confusing because if it were being passed through php I would expect 'Interesting'. but if it were not, then I would expect the whole file in plain text. I knew when I did this with fread I was probably heading for trouble, but which is happening, partial php parseing, no php parseing or . ? If you use fread(), you are reading a file. Any file. Nothing magic. No processing. If you use include()/require()/include_once()/require_once(), then PHP will process that file if it contains a valid opening tag (?php). Uploading a file does NOT process the file. The file is only processed when it is requested. Can you provide any more information about what you are trying to do? Maybe using the PHP General list would also be a better place for this thread? (http://docs.php.net/mailing-lists.php) Regards, Richard. -- - Richard Quadling Zend Certified Engineer
[Proto-Scripty] Re: autocomplete IE8 Shifts DOWN and TO THE RIGHT
Hi, There's a very recent thread for the to-the-right part, anyway: http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/8aac295a1affa481 -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Jun 24, 8:12 am, mrbinky3000 mrbinky3...@gmail.com wrote: Has anyone else run into difficulties with the autocomplete displaying results shifted down and to the right in ie8. It used to just shift stuff to the right a little, which was WRONG but still acceptable. Now it pushes the results the width of the results container to the right and the height of the results container down the page. It's WAY off. I can fix by forcing IE to use the 7.5 render engine by using this meta tag meta http-equiv=X-UA-Compatible content=IE=7.5 This problem doesn't occur in any other browser that I've tested (Opera, FireFox, Chrome, older versions of IE). It is an IE8 problem only. Could use some help. --~--~-~--~~~---~--~~ 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: Periodical Updater detect content change
Well there is a couple of ways to do it Personally if you dont have alot of these elements then 2 hidden elements within the div or page that hold (A) last Ajax.Request time and (B) last change time then just listen to every input element inside the div for a change (untested) $$('#mydiv input').invoke('observe','change',function(element) { $('thehiddenelement').value=the_time_it_was_updated; }); then you can check that on the request function and see if its needed to be sent or not ... (this is a hack!!) Another way is to create a cache on page load of every input element on the page and add it to an array or a json object and store its id,parent,value in the array... HTH Alex - Original Message - From: Aamchi aman.ra...@googlemail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, June 24, 2009 8:40 AM Subject: [Proto-Scripty] Re: Periodical Updater detect content change I thought of that too. But this only works in forms doesn't it? How do I detect a changed within a div which is reloaded every few seconds? Would you mind sending me an example? Thanks, Aman On 24 Jun., 08:36, Alex McAuley webmas...@thecarmarketplace.com wrote: There is also a Form.observerhttp://www.prototypejs.org/api/timedObserver/form-observer I used to use this but implemented my own version of it with a cache and some hashing, it didnt take long to write and works perfectly HTH Alex - Original Message - From: Aamchi aman.ra...@googlemail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, June 23, 2009 11:19 PM Subject: [Proto-Scripty] Re: Periodical Updater detect content change Thanks, for your response. I'm not 100% sure if I understand correctly what you mean. If I get some data and generate a hash and write this to the JSON header and retrieve this when calling onSuccess, how will I still have the previous hash? From where will I get this? Won't the updated data cause the hash to be overwritten in the JSON header? Or do I have to send two hashes always and compare them? On 23 Jun., 22:57, Richard Quadling rquadl...@googlemail.com wrote: 2009/6/23 Aamchi aman.ra...@googlemail.com Hi, I was wondering if Ajax.PeriodicalUpdater can detect if content has changed since the last update and if so trigger an event. So for example I have a scoreboard which fetches data every 5 seconds and displays this. I would be cool if there could be some kind of notification if content had changed. I know that the new content is stores in responseText but how can I compare it to the previous content... Thanks, Aman Personally, I would do this server side. Assuming you get the data in some sort of structure before either rending some HTML and sending it or just sending it JSON'd, then you should be able to build a hash of the data. See [1] for info on Hash Functions. So. If you sent the hash value in a X-JSON header along with an onSuccess() callback, you can extract the hash from the second param to the onSuccess and compare this with the previously retrieved hash to indicate you've got changed data. See [2] for details about PeriodicalUpdater update notification and [3] for the parameters to common callbacks. Regards, Richard. [1]http://en.wikipedia.org/wiki/Hash_function [2]http://www.prototypejs.org/api/ajax/periodicalUpdater http://www.prototypejs.org/api/ajax/periodicalUpdater[3]http://www.prototypejs.org/api/ajax/options http://www.prototypejs.org/api/ajax/options -- - Richard Quadling Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! --~--~-~--~~~---~--~~ 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: Long running requests disable other navigation links on the page
Hi, I noticed I had debugging turned on and this made IIS single threaded. Ah, you're using IIS. Are you using session variables by any chance? IIS may be serializing access to the session (e.g., queuing up any further requests). When you were testing simultaneous access from other windows, did you make sure to be in the same session? There there's app pools. Your app pool may be configured to only process a single request at a time. IIS has lots of settings around this stuff, many of which seem to me to have somewhat odd defaults... :-) (But actually, if you were doing things with the same app in a different window successfully, it wouldn't be app pools, never mind.) Based on your response, it sound like this is the way Ajax is supposed to work. No, it's nothing to do with Ajax itself. It's all down to whether the browser or server is queuing up requests, or whether the thread is tied up (JavaScript is single-threaded in this context). So for instance, you can tie up the thread by doing a synchronous request (asynchronous: false in the options). That brings that browser window (at least) to a screeching halt until that request is completed, and with some browsers, it's all windows, not just the one. So...don't do synchronous requests (not that you are, in your code example you're using asynchronous: true -- which is the default, you can leave it out if you like). This issue of multiple concurrent requests has come up a couple of times lately in the forum, including a thread in which Safari seemed (to the poster) to be only allowing *one* request at a time to the same server (his issue involved a file upload, though, which may be special). So I thought I'd create a contained test to double-check things[1]. My test has two HTML files and a JSP (since I'm a Java guy), but the JSP is trivial, you can easily replace it with a PHP or VB.Net equivalent. It just ensures that it takes a least a given amount of time before returning (in a way that I would _never_ put on a live system). So if you load up longtest1.html and click the Long Request button, it starts a five-second request. Then while that's running, you can use the Short Request button to try a short Ajax request running concurrently with the long-running one, or use the link to move to longtest2.html in the same window. In my tests with the JSP running on Tomcat, all of the browsers I tried behaved exactly as I would expect: I could do the short request while waiting for the long request to finish, and I could use a link to go to another page without waiting for the long request to finish. This is expected behavior because I never try to do more than two requests to the server at the same time. I tried FF3, IE6, IE7, IE8, Safari 3 for Windows, Opera 9, and Chrome 2. So what does that tell us? I think it tells us that the problem you're hitting is probably IIS configuration, but double-check you're not doing synchronous requests or more than two simultaneous requests. [1] http://pastie.org/522706 Hope this helps, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Jun 23, 9:45 pm, franklinhu frankli...@yahoo.com wrote: On Jun 23, 10:26 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, Weird, the way things seem to run in themes in the group. I just posted this to another thread[1] here: * * * * Most browsers, and most servers, place a limit on the number of simultaneous connections between the same endpoints, and typically that limit is two simultaneous connections. I don't immediately have a reference for that, but if you search on simultaneous HTTP connection limit or concurrent HTTP connection limit or some such, you'll find info on it. Note, again, that this is done at the browser level and also, sometimes, at the server level, and it varies by vendor (and configuration). * * * * [1]http://groups.google.com/group/prototype-scriptaculous/browse_thread/... I have been looking for some kind of cancel functionality to quit out of the long running requests when a user clicks on a navigation link, but I have been unable to find anything. Can someone help? The underlying XmlHttpRequest object may support the (relatively) new abort method (which I think is well-supported now). I don't think Prototype has a documented means of aborting requests or of accessing the underlying XHR object, but it's a pretty open secret: The XHR is stored as the transport property of the Ajax.Request object. So on browsers that support it, you can abort requests: Creating the request and keeping a reference to it: req = new Ajax.Request(...); ...then using that reference to cancel if supported: try { req.transport.abort(); } catch (e) { // Handle the failure, if any and if you want to } (Naturally if you want to you can test first to see if 'transport' is there and
[Proto-Scripty] Port to ActionScript?
Is there an official port of prototype.js to ActionScript? DOM-stuff makes no sense to port, but the basic JavaScript extensions like the Array extensions and so forth would be really handy in ActionScript as well. --~--~-~--~~~---~--~~ 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: escapeHTML incomplete?
Hi, String#escapeHTML escapes HTML. Double quotes, single quotes, and newlines are all valid in HTML, so IMHO it's out of scope for escapeHTML to escape them. FWIW, I'd say the requirement you're describing is specific enough to you that you should probably just add it at your end. For instance, if your JSON strings are delimited with double quotes, there's no need to escape single quotes (and vice versa). The example in the documentation of escapeHTML also contains this error, but no warning about this behaviour. The example in the docs is: 'div class=articleThis is an article/div'.escapeHTML(); // - lt;div class=articlegt;This is an articlelt;/divgt; I can see why you're thinking of that as an error, if you think of the entire thing after the // - as being a JavaScript string literal, but it isn't -- it's just documentation. The quotes are to indicate the value is a string, not that the whole thing is a string literal. Other places will say things like // - Alerts 'Hi there' which is also not valid JavaScript. I wouldn't say it's clear, though, and FWIW I agree we should change it -- probably to an example that doesn't use double quotes. If you create a lighthouse ticket, feel free to assign it to me. I'd probably add something like this to the docs: Note that escapeHTML escapes HTML tags. If you're going to include the result in a string literal, you may also need to escape double quotes, single quotes, and newlines. String#gsub may be useful for doing that. FWIW, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Jun 24, 9:39 am, Szymon Wilkołazki wilkola...@gmail.com wrote: Hi, I just tried to put a json object inside an attribute an I bumped into an issue with String#escapeHTML(). The method does escape all the ampersands and the greater/less than signs, but it does nothing to the quots. This make the method completely unusable for writing attributes (for innerHTML use). Lets get through an example: var eventMemo = { aLabel: 'some String with quotes, \'apostrophes\'...', otherLabel: 'another String with ampersands and tags'}; //I want this object inside an html attribute, so lets //make it JSON and escape it: var attr = Object.toJSON(eventMemo).escapeHTML(); var link = 'a href=javascript:; class=fireCustomEvent'+ ' data-eventMemo=' + attr + ' '+ ' this link is supposed to fire custom event with memo '+ ' read from data-eventMemo attribute '+ '/a'; //lets see what this link looks like in Firebug: console.log(link); The output is: a href=javascript:; class=fireCustomEvent data-eventMemo={aLabel: some String with \quotes\, 'apostrophs'..., otherLabel: another String with amp;ampersands and lt;tagsgt;} this link is supposed to fire custom event with memo read from data-eventMemo attribute/a As you can see, the output is completely broken, as the are not converted to quot; and ' to #39; One have to append another replaces to properly escape the string: var attr = Object.toJSON(eventMemo).escapeHTML().gsub(//,'quot;').gsub(/'/,'#39;'); The example in the documentation of escapeHTML also contains this error, but no warning about this behaviour. IMHO: 1. A note should be added to the docs about this issue, and an example how to properly escape string for use inside attributes; 2. A parameter could be added tho this method which would escape quotes automaticly. Or a separate function could be introduced, eg. escapeHTMLquots() which would do the same unconditionally. 3. Current behaviour of method can not be changed, as this would create backward incompatibility. I will place an issue about the docs, and I would like to hear your opinion about the method modifications. Best Regards, SWilk --~--~-~--~~~---~--~~ 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: Periodical Updater detect content change
2009/6/23 Aamchi aman.ra...@googlemail.com: Thanks, for your response. I'm not 100% sure if I understand correctly what you mean. If I get some data and generate a hash and write this to the JSON header and retrieve this when calling onSuccess, how will I still have the previous hash? From where will I get this? Won't the updated data cause the hash to be overwritten in the JSON header? Or do I have to send two hashes always and compare them? On 23 Jun., 22:57, Richard Quadling rquadl...@googlemail.com wrote: 2009/6/23 Aamchi aman.ra...@googlemail.com Hi, I was wondering if Ajax.PeriodicalUpdater can detect if content has changed since the last update and if so trigger an event. So for example I have a scoreboard which fetches data every 5 seconds and displays this. I would be cool if there could be some kind of notification if content had changed. I know that the new content is stores in responseText but how can I compare it to the previous content... Thanks, Aman Personally, I would do this server side. Assuming you get the data in some sort of structure before either rending some HTML and sending it or just sending it JSON'd, then you should be able to build a hash of the data. See [1] for info on Hash Functions. So. If you sent the hash value in a X-JSON header along with an onSuccess() callback, you can extract the hash from the second param to the onSuccess and compare this with the previously retrieved hash to indicate you've got changed data. See [2] for details about PeriodicalUpdater update notification and [3] for the parameters to common callbacks. Regards, Richard. [1]http://en.wikipedia.org/wiki/Hash_function [2]http://www.prototypejs.org/api/ajax/periodicalUpdater http://www.prototypejs.org/api/ajax/periodicalUpdater[3]http://www.prototypejs.org/api/ajax/options http://www.prototypejs.org/api/ajax/options -- - Richard Quadling Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! You add a previousHash:null; to your periodic updater and check that value against the one coming in via the X-JSON header. If it is different, then the data is different. If it is the same, then the data is the same. Either way, once evaluated, same the new hash. Untested (sorry), but adapting the example at [1] ... var o_Updater = new Ajax.PeriodicalUpdater ( 'lastLogin', '/lastLogin.php', { method: 'get', frequency : 3, decay : 2, lastHash : null, onSuccess : function(o_Transport, o_JSON) { // Do we have JSON? if (!!o_JSON) { // Do we have a previous hash? if (!!this.options.lastHash (this.options.lastHash != o_JSON.thisHash)) { // Hashes are different. Maybe activate an effect to show the highlighted data and slowly fade away over time. } // Update hash. this.options.lastHash != o_JSON.thisHash; } } } ); The code on the server would be something like this (I'm using PHP). ?php // Assume we are getting this data from a database. $a_Data = array ( 'Name' = 'Richard Quadling', 'LastPost' = '2009-06-24 10:00:00', ); // Build hash $s_Hash = array('Hash' = md5(serialize($a_Data))); // Generate output. $s_Output = tbodytrtd{$a_Data['Name']}/tdtd{$a_Data['LastPost']}/td/tbody; // X-JSON Header header('X-JSON: ' . json_encode($s_Hash, JSON_FORCE_OBJECT)); // Output results. echo $s_Output; ? The PHP outputs (edited) ... X-JSON: {Hash:a0c23e7f9651f2b65135932917b7f03a} Content-type: text/html tbodytrtdRichard Quadling/tdtd2009-06-24 10:00:00/td/tbody So the X-JSON header is presented as o_JSON in onSuccess() and o_JSON.Hash is 'a0c23e7f9651f2b65135932917b7f03a' And the HTML would go to the container you defined in the PeriodicUpdater Richard. -- - Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! --~--~-~--~~~---~--~~ 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: php in files
2009/6/24 Alex McAuley webmas...@thecarmarketplace.com: I really think you are overthinking this! If you want to echo out ?php echo('FOO'); ? for instance and have the preprocessor parse it... you need to (dangerously) eval it $variable=?php echo('pfoo/p'); ?; eval($variable); ... pfoo/p is returned to the browser... So (and i highly do not recommend this unless you truely trust the text in your database and the files it is opening) u must use php's eval(); Like so ... (using your variables) eval($retstr); then anything inside that variable or file will be evall'd as opcode and passed through the pre-processor and you will be left with html or whatever your php code spits out! HTH Alex - Original Message - From: Robaj robrass...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, June 24, 2009 7:44 AM Subject: [Proto-Scripty] Re: php in files Ok, let me put my idea to you and see if there is a way without reloading the whole page - I use prototype.js and project.js. project.js is just my entensions for each project, which I have narrowed down to two functions, - function myRequest( text ) { new Ajax.Request('requests.php', { method: 'post', postBody: text, onComplete: myResponse }); } function myResponse(req) { $(targetdiv).innerHTML= req.responseText; } Where text is supplied from the controls, such as 'page=home'. request.php is the only php file called directly, it decides which response is wanted and returns the text for a control or entire body for div id='mainbody'/div All of my pages and controls within them are created in php from the database. This is very easy to maintain and update, so a nice base for all kinds of applications All works well if I only respond with html including the ajax side that recalls requests.php, the only problem is that I intended some of the pages to be applications, so I want them to have php and can not see a way to pass it through the preprocessor. My request.php at the server side is like this - $Home=$button=$update=$testButton=$menuItem=; extract($_POST,EXTR_IF_EXISTS); if($menuItem != ) { $retstr = ; $dbconn = getdbconnection(); //find page associated with this menu item $query = 'SELECT body FROM menu WHERE name=\''.$menuItem.'\''; $result = pg_query($dbconn,$query) or die('Query failed: ' . pg_last_error()); $row = pg_fetch_row($result); //read in the file if(file_exists($row[0])) { $handle = fopen($row[0],r); $retstr = fread($handle,filesize($row[0])); fclose($handle); //failed attempt to use include instead //$retstr = ?php include .$row[0].; ?; } else { $retstr = File not created yet; } pg_close($dbconn); echo $retstr; } In the end this would leave me with only one main page index.php and all other pages called up via ajax and created or loaded via php. I have the feeling now that I have to update the whole page, not a terrible tragedy, but I just have the feeling that I can somehow put my fread() file through the php preprocessor. On Jun 23, 3:09 pm, Richard Quadling rquadl...@googlemail.com wrote: 2009/6/23 Robaj robrass...@gmail.com: I know this isn't strictly speaking a Prototype issue, but this is the only group I am in and a few topics do skirt around the edges of your main topic. If I have a file - home.php ?php echo h1A very interesting home page/h1; ? Then the file is returned to go into div id=mainbody/div with a plain fread() into a variable which is 'echo'd back to the client. 'include'ing this file is fine, but then it passes through php at the same time as everything else. But any such file loaded as the action of an Ajax call is not fine. It doesn't get passed via php, or at least I don't think it does - because in 'mainbody' I get part of it such as Interesting; ? Confusing because if it were being passed through php I would expect 'Interesting'. but if it were not, then I would expect the whole file in plain text. I knew when I did this with fread I was probably heading for trouble, but which is happening, partial php parseing, no php parseing or . ? If you use fread(), you are reading a file. Any file. Nothing magic. No processing. If you use include()/require()/include_once()/require_once(), then PHP will process that file if it contains a valid opening tag (?php). Uploading a file does NOT process the file. The file is only processed when it is requested. Can you provide any more information about what you are trying to do? Maybe using the PHP General list would also be a better place for this thread? (http://docs.php.net/mailing-lists.php) Regards,
[Proto-Scripty] Re: drag and drop tr from one table to another table.
Hi Nivash, I was trying to reproduce your error. Could you please post the code because I did not have the same error. -- david On 24 juin, 09:29, Nivash Ramachandran rniv...@gmail.com wrote: Hi all, I am using scriptaculous drag functionality in table tr element. Now I am facing the following issues. I can drag a row from one table to another table but 1. While i drag a row, it gets invisible from view (not visible) 2. I applied border style for table td element but it is not working after creating Draggable object. System info: 1. scriptaculous.js v1.8.2 2. IE 7 3. Vista by Nivash Ramachandran India. --~--~-~--~~~---~--~~ 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: Autocompleter shifts results to the right in IE8
After more debugging, I finally tracked down the problem, and it looks like there's already a ticket raised with Prototype to fix this in IE8: https://prototype.lighthouseapp.com/projects/8886-prototype/tickets/618-getoffsetparent-returns-body-for-new-hidden-elements-in-ie8-final#ticket-618-9 Dan --~--~-~--~~~---~--~~ 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: Drag Drop inside .net AJAX - Dispose of items?
Hi James, var items = document.getElementsByClassName(bla); for each item, SAVEDDRAGGABLE[i]=new Draggable(items[i].id... etc) then to destroy them, just do for each SAVEDDRAGGABLE, SAVEDDRAGGABLE.destroy(). So just save the scriptaculous object in creation, and use the method destroy() of draggable to destroy them. -- david On 23 juin, 18:10, Wyerarch wyera...@gmail.com wrote: Hi All, I'm loving this drag drop library in my application, however i've got serious memory leaks because I don't know how to destroy the items. I'm using the .net ScriptManager.RegisterClientScriptBlock method to register my script, so that all items from the database can be Draggables. However, I can't find a way of using the destroy method on them? In my register block i'm loading all the Draggables into an array - e..g var items = document.getElementsByClassName(bla); Then for each item, new Draggable(items[i].id... etc) How can I unload/destory them on async postback? if I look at the variable items it references the divs, not the objects? How can I access the objects to destroy them? Thanks, James. --~--~-~--~~~---~--~~ 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: Drag Drop inside .net AJAX - Dispose of items?
I just forgot, on the scriptaculous wiki, on exemples section, you can have an exemple: http://wiki.github.com/madrobby/scriptaculous/draggable -- david On 24 juin, 12:50, david david.brill...@gmail.com wrote: Hi James, var items = document.getElementsByClassName(bla); for each item, SAVEDDRAGGABLE[i]=new Draggable(items[i].id... etc) then to destroy them, just do for each SAVEDDRAGGABLE, SAVEDDRAGGABLE.destroy(). So just save the scriptaculous object in creation, and use the method destroy() of draggable to destroy them. -- david On 23 juin, 18:10, Wyerarch wyera...@gmail.com wrote: Hi All, I'm loving this drag drop library in my application, however i've got serious memory leaks because I don't know how to destroy the items. I'm using the .net ScriptManager.RegisterClientScriptBlock method to register my script, so that all items from the database can be Draggables. However, I can't find a way of using the destroy method on them? In my register block i'm loading all the Draggables into an array - e..g var items = document.getElementsByClassName(bla); Then for each item, new Draggable(items[i].id... etc) How can I unload/destory them on async postback? if I look at the variable items it references the divs, not the objects? How can I access the objects to destroy them? Thanks, James. --~--~-~--~~~---~--~~ 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: Dragdrop with absolute position
Hi Fagnain, Please post code, because I though it was possible. -- david On 23 juin, 11:16, Fagnain drean.fab...@gmail.com wrote: Hi, I tried to create 2 sortables in a page with drag drop from one to another. There is no problem when I make a test outside of my site. But when I include the code in the page I want it to be - into one of the 3 div I have with the CSS property position set to absolute - I can't do my drag and drop. I realized that this drag drop works fine when I put a new div without setting the position and drag over. So my question is : Can we set dragdrop on elements within a div with an absolute position (and how can we do that of course) ? Thanks. --~--~-~--~~~---~--~~ 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: Port to ActionScript?
Hi rlovtang, I've never ear somethink like that, but as ACTIONSCRIPT IS ECMASCRIPT, isn't it easy to port prototype function to it ?? btw, it's just a guess, I did not use actionscript ! -- david On 24 juin, 10:28, rlovtang ronnylovtan...@gmail.com wrote: Is there an official port of prototype.js to ActionScript? DOM-stuff makes no sense to port, but the basic JavaScript extensions like the Array extensions and so forth would be really handy in ActionScript as well. --~--~-~--~~~---~--~~ 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] on0 handlers
One handler to consider adding to your AJAX requests is on0. This is called if the connection to the webserver fails, typically because the the server is overloaded or has gone down since the page was loaded. While these conditions are uncommon, otherwise a failed connection calls the onSuccess handler! And if your webserver is overloaded or down, it's good to tell your users to wait a bit before trying again. I've updated the example at http://proto-scripty.wikidot.com/prototype:how-to-bulletproof-ajax-requests Doug Reeder reeder...@osu.edu http://reeder29.livejournal.com/ https://twitter.com/reeder29 --~--~-~--~~~---~--~~ 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: on0 handlers
2009/6/24 Doug Reeder reeder...@gmail.com: One handler to consider adding to your AJAX requests is on0. This is called if the connection to the webserver fails, typically because the the server is overloaded or has gone down since the page was loaded. While these conditions are uncommon, otherwise a failed connection calls the onSuccess handler! And if your webserver is overloaded or down, it's good to tell your users to wait a bit before trying again. I've updated the example at http://proto-scripty.wikidot.com/prototype:how-to-bulletproof-ajax-requests Doug Reeder reeder...@osu.edu http://reeder29.livejournal.com/ https://twitter.com/reeder29 Oh. Nice. I have a set of generic responders which show messages for all my AJAX calls. Adding on0 as I speak. -- - Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! --~--~-~--~~~---~--~~ 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: escapeHTML incomplete?
T.J. Crowder wrote: Hi, String#escapeHTML escapes HTML. Double quotes, single quotes, and newlines are all valid in HTML, so IMHO it's out of scope for escapeHTML to escape them. FWIW, I'd say the requirement you're describing is specific enough to you that you should probably just add it at your end. For instance, if your JSON strings are delimited with double quotes, there's no need to escape single quotes (and vice versa). I have already added proper gsubs to the resulting escaped string, thanks for the tip. I still cannot agree that this is specific to my project only. I very often need to put some (unknown)string into elements attribute. I used to do it by creating new Element() and using setAttribute(), which did not require escaping anything, but latest discusions about speed of innerHTML operation make me try this approach. I still have to set attributes of the elements to different strings, and I cannot now if they contain quotes or not, so I need to escape them. I think than many people need to put strings inside element attributes. The JSON in attribute is probably more specific to my project. Anyway, I know nothing can be done to the actual method, I just think the docs should have an example what to do in that case. [...] If you create a lighthouse ticket, feel free to assign it to me. I'd probably add something like this to the docs: here it comes: http://prototype.lighthouseapp.com/projects/8886-prototype/tickets/722-escapehtml-underdocumented-note-about-quotes-needed Thank you for your time. Best Regards, SWilk --~--~-~--~~~---~--~~ 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: Autocompleter shifts results to the right in IE8
Thanks for tracking that down! On Wed, Jun 24, 2009 at 3:48 AM, BillyRayPreachersSon billyraypreachers...@gmail.com wrote: After more debugging, I finally tracked down the problem, and it looks like there's already a ticket raised with Prototype to fix this in IE8: https://prototype.lighthouseapp.com/projects/8886-prototype/tickets/618-getoffsetparent-returns-body-for-new-hidden-elements-in-ie8-final#ticket-618-9 Dan --~--~-~--~~~---~--~~ 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: drag and drop tr from one table to another table.
Can you post a link to an example? Rick On Wed, Jun 24, 2009 at 3:29 AM, Nivash Ramachandran rniv...@gmail.comwrote: Hi all, I am using scriptaculous drag functionality in table tr element. Now I am facing the following issues. I can drag a row from one table to another table but 1. While i drag a row, it gets invisible from view (not visible) 2. I applied border style for table td element but it is not working after creating Draggable object. System info: 1. scriptaculous.js v1.8.2 2. IE 7 3. Vista by Nivash Ramachandran India. --~--~-~--~~~---~--~~ 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: drag and drop tr from one table to another table.
Whoops - i replied to your first message before updating the thread. Sorry about that. Rick On Wed, Jun 24, 2009 at 12:57 PM, Rick Waldron waldron.r...@gmail.comwrote: Can you post a link to an example? Rick On Wed, Jun 24, 2009 at 3:29 AM, Nivash Ramachandran rniv...@gmail.comwrote: Hi all, I am using scriptaculous drag functionality in table tr element. Now I am facing the following issues. I can drag a row from one table to another table but 1. While i drag a row, it gets invisible from view (not visible) 2. I applied border style for table td element but it is not working after creating Draggable object. System info: 1. scriptaculous.js v1.8.2 2. IE 7 3. Vista by Nivash Ramachandran India. --~--~-~--~~~---~--~~ 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: drag and drop tr from one table to another table.
It's okay Rick .. On Jun 24, 9:59 pm, Rick Waldron waldron.r...@gmail.com wrote: Whoops - i replied to your first message before updating the thread. Sorry about that. Rick On Wed, Jun 24, 2009 at 12:57 PM, Rick Waldron waldron.r...@gmail.comwrote: Can you post a link to an example? Rick On Wed, Jun 24, 2009 at 3:29 AM, Nivash Ramachandran rniv...@gmail.comwrote: Hi all, I am using scriptaculous drag functionality in table tr element. Now I am facing the following issues. I can drag a row from one table to another table but 1. While i drag a row, it gets invisible from view (not visible) 2. I applied border style for table td element but it is not working after creating Draggable object. System info: 1. scriptaculous.js v1.8.2 2. IE 7 3. Vista by Nivash Ramachandran India. --~--~-~--~~~---~--~~ 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: Long running requests disable other navigation links on the page
On Jun 24, 2:52 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, I noticed I had debugging turned on and this made IIS single threaded. Ah, you're using IIS. Are you using session variables by any chance? IIS may be serializing access to the session (e.g., queuing up any further requests). When you were testing simultaneous access from other windows, did you make sure to be in the same session? There there's app pools. Your app pool may be configured to only process a single request at a time. IIS has lots of settings around this stuff, many of which seem to me to have somewhat odd defaults... :-) (But actually, if you were doing things with the same app in a different window successfully, it wouldn't be app pools, never mind.) Based on your response, it sound like this is the way Ajax is supposed to work. No, it's nothing to do with Ajax itself. It's all down to whether the browser or server is queuing up requests, or whether the thread is tied up (JavaScript is single-threaded in this context). So for instance, you can tie up the thread by doing a synchronous request (asynchronous: false in the options). That brings that browser window (at least) to a screeching halt until that request is completed, and with some browsers, it's all windows, not just the one. So...don't do synchronous requests (not that you are, in your code example you're using asynchronous: true -- which is the default, you can leave it out if you like). This issue of multiple concurrent requests has come up a couple of times lately in the forum, including a thread in which Safari seemed (to the poster) to be only allowing *one* request at a time to the same server (his issue involved a file upload, though, which may be special). So I thought I'd create a contained test to double-check things[1]. My test has two HTML files and a JSP (since I'm a Java guy), but the JSP is trivial, you can easily replace it with a PHP or VB.Net equivalent. It just ensures that it takes a least a given amount of time before returning (in a way that I would _never_ put on a live system). So if you load up longtest1.html and click the Long Request button, it starts a five-second request. Then while that's running, you can use the Short Request button to try a short Ajax request running concurrently with the long-running one, or use the link to move to longtest2.html in the same window. In my tests with the JSP running on Tomcat, all of the browsers I tried behaved exactly as I would expect: I could do the short request while waiting for the long request to finish, and I could use a link to go to another page without waiting for the long request to finish. This is expected behavior because I never try to do more than two requests to the server at the same time. I tried FF3, IE6, IE7, IE8, Safari 3 for Windows, Opera 9, and Chrome 2. So what does that tell us? I think it tells us that the problem you're hitting is probably IIS configuration, but double-check you're not doing synchronous requests or more than two simultaneous requests. [1]http://pastie.org/522706 Hope this helps, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available Thanks for creating that example. Using it, I was able to create a similar application that runs under IIS using .asp pages. I created a page delay.asp that took the place of delay.jsp which just delays 5 seconds: Delay.asp %@ LANGUAGE=VBSCRIPT % % Dim PauseTime, Start PauseTime = 5 Start = Timer ' Set start time. Do While Timer Start + PauseTime Loop Response.write finished % I found that if you redirect to an html file, there is never a problem. If you redirect to an .ASP page, it will block if you are using session variables. If you turn them off, then the redirection is allowed to happen immediately, so your suspicion about session variables was correct. Unfortunately, my application depends heavily on session variables so turning them off is not an option at this point. Is there anyone else out there who has used classic .ASP pages and prototype.js to create AJAX pages? I tried changing the app pool worker threads = 2, but this didn't seem to do anything. I am using IIS6. --~--~-~--~~~---~--~~ 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: Periodical Updater detect content change
Thanks Richard, I will try this out. Really appreciate your help! On 24 Jun., 12:12, Richard Quadling rquadl...@googlemail.com wrote: 2009/6/23 Aamchi aman.ra...@googlemail.com: Thanks, for your response. I'm not 100% sure if I understand correctly what you mean. If I get some data and generate a hash and write this to the JSON header and retrieve this when calling onSuccess, how will I still have the previous hash? From where will I get this? Won't the updated data cause the hash to be overwritten in the JSON header? Or do I have to send two hashes always and compare them? On 23 Jun., 22:57, Richard Quadling rquadl...@googlemail.com wrote: 2009/6/23 Aamchi aman.ra...@googlemail.com Hi, I was wondering if Ajax.PeriodicalUpdater can detect if content has changed since the last update and if so trigger an event. So for example I have a scoreboard which fetches data every 5 seconds and displays this. I would be cool if there could be some kind of notification if content had changed. I know that the new content is stores in responseText but how can I compare it to the previous content... Thanks, Aman Personally, I would do this server side. Assuming you get the data in some sort of structure before either rending some HTML and sending it or just sending it JSON'd, then you should be able to build a hash of the data. See [1] for info on Hash Functions. So. If you sent the hash value in a X-JSON header along with an onSuccess() callback, you can extract the hash from the second param to the onSuccess and compare this with the previously retrieved hash to indicate you've got changed data. See [2] for details about PeriodicalUpdater update notification and [3] for the parameters to common callbacks. Regards, Richard. [1]http://en.wikipedia.org/wiki/Hash_function [2]http://www.prototypejs.org/api/ajax/periodicalUpdater http://www.prototypejs.org/api/ajax/periodicalUpdater[3]http://www.prototypejs.org/api/ajax/options http://www.prototypejs.org/api/ajax/options -- - Richard Quadling Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! You add a previousHash:null; to your periodic updater and check that value against the one coming in via the X-JSON header. If it is different, then the data is different. If it is the same, then the data is the same. Either way, once evaluated, same the new hash. Untested (sorry), but adapting the example at [1] ... var o_Updater = new Ajax.PeriodicalUpdater ( 'lastLogin', '/lastLogin.php', { method : 'get', frequency : 3, decay : 2, lastHash : null, onSuccess : function(o_Transport, o_JSON) { // Do we have JSON? if (!!o_JSON) { // Do we have a previous hash? if (!!this.options.lastHash (this.options.lastHash != o_JSON.thisHash)) { // Hashes are different. Maybe activate an effect to show the highlighted data and slowly fade away over time. } // Update hash. this.options.lastHash != o_JSON.thisHash; } } } ); The code on the server would be something like this (I'm using PHP). ?php // Assume we are getting this data from a database. $a_Data = array ( 'Name' = 'Richard Quadling', 'LastPost' = '2009-06-24 10:00:00', ); // Build hash $s_Hash = array('Hash' = md5(serialize($a_Data))); // Generate output. $s_Output = tbodytrtd{$a_Data['Name']}/tdtd{$a_Data['LastPost']}/td/tbody; // X-JSON Header header('X-JSON: ' . json_encode($s_Hash, JSON_FORCE_OBJECT)); // Output results. echo $s_Output; ? The PHP outputs (edited) ... X-JSON: {Hash:a0c23e7f9651f2b65135932917b7f03a} Content-type: text/html tbodytrtdRichard Quadling/tdtd2009-06-24 10:00:00/td/tbody So the X-JSON header is presented as o_JSON in onSuccess() and o_JSON.Hash is 'a0c23e7f9651f2b65135932917b7f03a' And the HTML would go to the container you defined in the PeriodicUpdater Richard. -- - Richard Quadling Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! --~--~-~--~~~---~--~~ 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
[Proto-Scripty] Re: Periodical Updater detect content change
Hi Richard, Your example works perfectly :-) Just a few minor things that I had to change to make it actually work (not being fussy, just if someone else finds this useful as well and wants to try it out): -The this operator didn't work for me, I replaced it with o_Updater - In the PHP the array key which stores the hash is 'Hash' and not 'thisHash', so replace thisHash with Hash in the js-code - And when updating hash: o_Updater.options.lastHash = o_JSON.thisHash (instead of o_Updater.options.lastHash != o_JSON.thisHash) Thanks again. Aman On 24 Jun., 12:12, Richard Quadling rquadl...@googlemail.com wrote: 2009/6/23 Aamchi aman.ra...@googlemail.com: Thanks, for your response. I'm not 100% sure if I understand correctly what you mean. If I get some data and generate a hash and write this to the JSON header and retrieve this when calling onSuccess, how will I still have the previous hash? From where will I get this? Won't the updated data cause the hash to be overwritten in the JSON header? Or do I have to send two hashes always and compare them? On 23 Jun., 22:57, Richard Quadling rquadl...@googlemail.com wrote: 2009/6/23 Aamchi aman.ra...@googlemail.com Hi, I was wondering if Ajax.PeriodicalUpdater can detect if content has changed since the last update and if so trigger an event. So for example I have a scoreboard which fetches data every 5 seconds and displays this. I would be cool if there could be some kind of notification if content had changed. I know that the new content is stores in responseText but how can I compare it to the previous content... Thanks, Aman Personally, I would do this server side. Assuming you get the data in some sort of structure before either rending some HTML and sending it or just sending it JSON'd, then you should be able to build a hash of the data. See [1] for info on Hash Functions. So. If you sent the hash value in a X-JSON header along with an onSuccess() callback, you can extract the hash from the second param to the onSuccess and compare this with the previously retrieved hash to indicate you've got changed data. See [2] for details about PeriodicalUpdater update notification and [3] for the parameters to common callbacks. Regards, Richard. [1]http://en.wikipedia.org/wiki/Hash_function [2]http://www.prototypejs.org/api/ajax/periodicalUpdater http://www.prototypejs.org/api/ajax/periodicalUpdater[3]http://www.prototypejs.org/api/ajax/options http://www.prototypejs.org/api/ajax/options -- - Richard Quadling Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! You add a previousHash:null; to your periodic updater and check that value against the one coming in via the X-JSON header. If it is different, then the data is different. If it is the same, then the data is the same. Either way, once evaluated, same the new hash. Untested (sorry), but adapting the example at [1] ... var o_Updater = new Ajax.PeriodicalUpdater ( 'lastLogin', '/lastLogin.php', { method : 'get', frequency : 3, decay : 2, lastHash : null, onSuccess : function(o_Transport, o_JSON) { // Do we have JSON? if (!!o_JSON) { // Do we have a previous hash? if (!!this.options.lastHash (this.options.lastHash != o_JSON.thisHash)) { // Hashes are different. Maybe activate an effect to show the highlighted data and slowly fade away over time. } // Update hash. this.options.lastHash != o_JSON.thisHash; } } } ); The code on the server would be something like this (I'm using PHP). ?php // Assume we are getting this data from a database. $a_Data = array ( 'Name' = 'Richard Quadling', 'LastPost' = '2009-06-24 10:00:00', ); // Build hash $s_Hash = array('Hash' = md5(serialize($a_Data))); // Generate output. $s_Output = tbodytrtd{$a_Data['Name']}/tdtd{$a_Data['LastPost']}/td/tbody; // X-JSON Header header('X-JSON: ' . json_encode($s_Hash, JSON_FORCE_OBJECT)); // Output results. echo $s_Output; ? The PHP outputs (edited) ... X-JSON: {Hash:a0c23e7f9651f2b65135932917b7f03a} Content-type: text/html tbodytrtdRichard Quadling/tdtd2009-06-24 10:00:00/td/tbody So the X-JSON header is presented as o_JSON in onSuccess() and o_JSON.Hash is 'a0c23e7f9651f2b65135932917b7f03a' And
[Proto-Scripty] determine if dom:onload has happened yet?
So prototype 1.6 lets you register an event handler for the psuedo- event dom:loaded. Good enough. But if you register a callback for this event AFTER it's already happened anywhere, it'll never get called (or possibly even something stranger will happen, something strange was happening to me, but could have been my code). I have some re-useable code that sometimes might get called before dom:loaded (in which case it wants to register a callback to do it's thing on dom:onload), but sometimes might get called after dom:loaded (in which case it would just go ahead and do it's thing). Is there any way to tell if dom:loaded has happened yet? --~--~-~--~~~---~--~~ 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: determine if dom:onload has happened yet?
yes, using document.loaded. Try something like: document.loaded ? callback() : document.observe('dom:loaded', callback); Best, Tobie On Jun 24, 11:53 pm, jrochkind rochk...@jhu.edu wrote: So prototype 1.6 lets you register an event handler for the psuedo- event dom:loaded. Good enough. But if you register a callback for this event AFTER it's already happened anywhere, it'll never get called (or possibly even something stranger will happen, something strange was happening to me, but could have been my code). I have some re-useable code that sometimes might get called before dom:loaded (in which case it wants to register a callback to do it's thing on dom:onload), but sometimes might get called after dom:loaded (in which case it would just go ahead and do it's thing). Is there any way to tell if dom:loaded has happened yet? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---