[Proto-Scripty] Re: help with basic regular expression
On Mar 17, 2:25 pm, kangax wrote: > On Mar 16, 9:44 pm, RobG wrote: > > > On Mar 17, 4:10 am, kangax wrote: > > > > On Mar 16, 1:13 pm, arkady wrote: > > > > > if trying to strip off the everything before the and everything > > > > after > > > > response.replace(/.*(?=)/, '').replace(/(<\/body>).*/, '$1'); > > > That seems a bit risky, the string may not always have lower case tag > > names and the body opening tag may include attributes. New lines in > > I actually took OP's issue too literally; i.e. - "strip off everything > before the and after " : ) > > > the string might trip it up too. In any case, it doesn't work for me > > at all in Firefox 3 or IE 6. > > Which string did you feed it with? dot doesn't match newlines, does > it? [\s\S] should match: > > response.replace(/[\s\S]*(?= (which *should* only ever be with maybe some whitespace but who knows what a server might send?) as you’ve done below. According to the innerHTML, Firebug puts a div between the head and body elements - not sure if I like that, it will be dealt with by error correction (moved into the body or perhaps ignored completely) if fed back to the browser. > > An alternative, provided all new lines are removed, is: > > > response.match(//i)[0]; > > > or > > > response.replace(/\s/g,' ').match(/\/i)[0]; > > > A sub-string version is: > > > var start = response.toLowerCase().indexOf(' > var end = response.toLowerCase().indexOf('') + 7; > > var theBody = response.substring(start, end) > > Obviously, string-based matching should be marginally faster than > regex, especially when that regex is based on a relatively slow > positive lookahead : ) But the substring stuff just *looks* clunky. :-p > > var response = document.documentElement.innerHTML; > console.time(1); > for (var i=0; i<100; i++) { > var l = response.toLowerCase(); > response.substring(l.indexOf('') + 7);} > > console.timeEnd(1); > > var response = document.documentElement.innerHTML; > console.time(2); > for (var i=0; i<100; i++) { > response.replace(/[\s\S]*(?= .replace(/(<\/body>)[\s\S]*/i, '$1');} > > console.timeEnd(2); > > //1: 186ms > //2: 2664ms For that sort of speed gain, I’d use substring every time - match is about 50% slower again. -- Rob --~--~-~--~~~---~--~~ 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: help with basic regular expression
On Mar 16, 9:44 pm, RobG wrote: > On Mar 17, 4:10 am, kangax wrote: > > > On Mar 16, 1:13 pm, arkady wrote: > > > > if trying to strip off the everything before the and everything > > > after > > > response.replace(/.*(?=)/, '').replace(/(<\/body>).*/, '$1'); > > That seems a bit risky, the string may not always have lower case tag > names and the body opening tag may include attributes. New lines in I actually took OP's issue too literally; i.e. - "strip off everything before the and after " : ) > the string might trip it up too. In any case, it doesn't work for me > at all in Firefox 3 or IE 6. Which string did you feed it with? dot doesn't match newlines, does it? [\s\S] should match: response.replace(/[\s\S]*(?= > An alternative, provided all new lines are removed, is: > > response.match(//i)[0]; > > or > > response.replace(/\s/g,' ').match(/\/i)[0]; > > A sub-string version is: > > var start = response.toLowerCase().indexOf(' var end = response.toLowerCase().indexOf('') + 7; > var theBody = response.substring(start, end) Obviously, string-based matching should be marginally faster than regex, especially when that regex is based on a relatively slow positive lookahead : ) var response = document.documentElement.innerHTML; console.time(1); for (var i=0; i<100; i++) { var l = response.toLowerCase(); response.substring(l.indexOf('') + 7); } console.timeEnd(1); var response = document.documentElement.innerHTML; console.time(2); for (var i=0; i<100; i++) { response.replace(/[\s\S]*(?=)[\s\S]*/i, '$1'); } console.timeEnd(2); //1: 186ms //2: 2664ms -- kangax --~--~-~--~~~---~--~~ 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: help with basic regular expression
On Mar 17, 4:10 am, kangax wrote: > On Mar 16, 1:13 pm, arkady wrote: > > > if trying to strip off the everything before the and everything > > after > > response.replace(/.*(?=)/, '').replace(/(<\/body>).*/, '$1'); That seems a bit risky, the string may not always have lower case tag names and the body opening tag may include attributes. New lines in the string might trip it up too. In any case, it doesn't work for me at all in Firefox 3 or IE 6. An alternative, provided all new lines are removed, is: response.match(//i)[0]; or response.replace(/\s/g,' ').match(/\/i)[0]; A sub-string version is: var start = response.toLowerCase().indexOf('') + 7; var theBody = response.substring(start, end) -- Rob --~--~-~--~~~---~--~~ 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: help with basic regular expression
thank you. that worked. i was trying to use the sub() method. does it work? On Mar 16, 11:10 am, kangax wrote: > On Mar 16, 1:13 pm, arkady wrote: > > > if trying to strip off the everything before the and everything > > after > > response.replace(/.*(?=)/, '').replace(/(<\/body>).*/, '$1'); > > [...] > > -- > kangax --~--~-~--~~~---~--~~ 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: Sortable is undefined
Hi, > The most interesting thing is > that it works as an independent HTML file but fails with the above > error when I ran it on my server as a JSP page. Very suspicious. :-) Sounds like a deployment error. With things running on your server, if you go to your page, and then edit the address bar to manually retrieve the JavaScript files from the relative "scripts" location and press Enter, does it work? E.g., suppose your usual page is: http://localhost:8080/some/path/somefile.jsp ...you'd edit that to be: http://localhost:8080/some/path/scripts/prototype.js ...and see if you do, in fact, see the Prototype file. If you do, try: http://localhost:8080/some/path/scripts/scriptaculous.js ...and make sure you get the script.aculo.us file. You might try making sure that all of script.aculo.us' subsidiary files are there. If they're all there, I'm not sure what's going on. (OT: Prototype works best if you declare a doctype on your documents, e.g., XHTML transitional or some such. Quirks mode isn't really supported. But I don't think that's what's going on *here*.) HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Mar 16, 3:13 pm, sujikin wrote: > Hi, > > For the below script, I am getting the error "Sortable is undefined", > > > > ABCD > > > type="text/javascript" > > > > ul.testlist { > list-style-type:none; > margin:0; > padding:0; > } > ul.testlist li { > width:200px; > font:12px Verdana; > padding:4px; > cursor:move; > } > ul.testlist li.over { > background-color:#fcb; > } > > > > > > One > Two > Three > > > > > // Sortable.create('testlist', { > onUpdate: function() { $('test2').innerHTML= Sortable.sequence > ('testlist');} > }); > // ]]> > > > > > All the js files are included properly. The most interesting thing is > that it works as an independent HTML file but fails with the above > error when I ran it on my server as a JSP page. > > Any help will be appreciated! > > Thanks & Regards > Sujeet --~--~-~--~~~---~--~~ 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] Sortable is undefined
Hi, For the below script, I am getting the error "Sortable is undefined", ABCD ul.testlist { list-style-type:none; margin:0; padding:0; } ul.testlist li { width:200px; font:12px Verdana; padding:4px; cursor:move; } ul.testlist li.over { background-color:#fcb; } One Two Three // All the js files are included properly. The most interesting thing is that it works as an independent HTML file but fails with the above error when I ran it on my server as a JSP page. Any help will be appreciated! Thanks & Regards Sujeet --~--~-~--~~~---~--~~ 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: IE 7 and dynamic div in IFRAMES
I solved a similar problem with a JS solution. I defined a fucntion which resizes my IFRAME in the top window var framed_height; function setFramedSize (height) { if (height!= framed_height){ framed_height = height; $('display_frame').setStyle({ height: height.toString()+'px' }) }; } which is called after "onload" from the iframe top.setFramedSize($('myDiv').height()) HTH George --~--~-~--~~~---~--~~ 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] ajax-autocompleter null feedback
Hello ! I was coming to this group, hoping that, maybe, you could help me... So, I'm working with the ajax-autocompleter which works great. My aim is to redirect between an editing function for an existing item, or a creating function for a not-found item I insert a specific id to each , and I can therefore use it for the editing function with an afterUpdateElement option. But if no results are found, the list is empty, and I can't find any way to tell my afterUpdateElement script that no results were found... Would you have any tips for me ? Thank you very much --~--~-~--~~~---~--~~ 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: help with basic regular expression
On Mar 16, 1:13 pm, arkady wrote: > if trying to strip off the everything before the and everything > after response.replace(/.*(?=)/, '').replace(/(<\/body>).*/, '$1'); [...] -- kangax --~--~-~--~~~---~--~~ 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] help with basic regular expression
if trying to strip off the everything before the and everything after response = response.sub(/^.+/, "").sub(/<\/body>.*$/,""); but its not doing it. i even tried something simpler: response = response.sub(/^.+$/, "") as a test and it did not work either. --~--~-~--~~~---~--~~ 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: Sortable Lists: Can only move one row?
Hi Programme, that could be a lot of things, but one thougth, did you have same element ID for the list ?? Perhaps, you could use pastie.org to paste created code. -- david On 13 mar, 15:09, Programme wrote: > Hey > > Here is a very nice tutorial on Sortable > Lists:http://zenofshen.com/posts/ajax-sortable-lists-tutorial > > However; when trying this myself I always end up with a list that > works half way. The list loads and I can move an item, but that is it. > I can not move any other items unless I reload the page and can then > move another row? > > Any ideas on why this is happening? --~--~-~--~~~---~--~~ 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: Prototype exception in IE and not in Mozilla Firefox
Hi virchete, could we have some live testing code to see the error in action?? Or pehaps som edebugging info with FireBug, as it seems to appear on a non IE browser. -- david On 13 mar, 15:47, virchete wrote: > Hello, I have a problem with prototype just in the line 1372 > > if((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) { > this.status = this.getStatus(); > this.statusText = this.getStatusText(); > > this.responseText = String.interpret(transport.responseText);// > THIS LINEE FAILS > this.headerJSON = this._getHeaderJSON(); > } > > The problem is called when I do a Ajax.Updater, and this code is > inside of Ajax.response. > > I hope someone could help me. I have seen this problem in this forum > but nobody put a solution. --~--~-~--~~~---~--~~ 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: HELP please on question regarding onComplete
T.J. Thanks so much for taking the time to respond. A colleague of mine finally found what my problem was. The issue resided in the ELSE IF statement. Please see the modified code below: [CODE] function getVendorInfo(vNum) { var url = '/common/Lookup.action'; new Ajax.Updater('vendorInfoResults', url, {method: 'get', parameters: {vendorInfo: '', vendorNum: vNum}, onComplete: function() { var vendorWinH = document.body.offsetHeight; var vendorInfoH = $ ('vendorInfoResults').offsetHeight; if (vendorWinH == winH) window.resizeBy(0, vendorInfoH); else { var newVendorWinH = winH + vendorInfoH; if (newVendorWinH <> vendorWinH) window.resizeBy(0, newVendorWinH - vendorWinH); } } }); } [/CODE] On Mar 13, 2:21 am, "T.J. Crowder" wrote: > Hi, > > Try using Function#defer[1] to defer your onComplete logic; the > browser may not be done processing the DOM changes from the update > yet. Not saying that's definitely it, but it may help and is easy to > try. > > [1]http://prototypejs.org/api/function/defer > > HTH, > -- > T.J. Crowder > tj / crowder software / com > Independent Software Engineer, consulting services available > > On Mar 12, 3:31 pm, Mel wrote: > > > In the following function, I am experiencing weird behavior when > > trying to resize a popup window based on the size of the inserted JSP > > page within this popup window page. In JSP 1 I have a list of records > > which is preceded by an icon on each record. I click on the icon > > image and it should open JSP 2 within JSP 1 via the DIV tags in JSP > > 1. When I click on the icon the function below should execute and it > > does but the functionality is not consistent depending on the size of > > the window. The problem seems to exist in the ELSE section within the > > IF statement. If the inserted JSP page via DIV tags, called > > 'vendorInfoResults', extends in size below the outline of the popup > > window and I click on the next icon of the rows displayed in the > > 'vendorInfoResults' section then the window does not expand and I may > > do it again a second time and then it does work. > > > Are there any issues or bugs within the onComplete function that I am > > using in prototype-1.6.0.2.js which is the version that I'm using? Is > > there a better way to handle the window.resizeBy method? > > > Any help would be greatly appreciated. I've been trying to resolve > > this issue since last Friday and it's driving me nuts. > > > [CODE] > > function getVendorInfo(vNum) { > > var url = '/common/Lookup.action'; > > new Ajax.Updater('vendorInfoResults', url, > > {method: 'get', > > parameters: {vendorInfo: '', vendorNum: > > vNum}, > > onComplete: function() { > > var vendorWinH = > > document.body.offsetHeight; > > var vendorInfoH = > > $('vendorInfoResults').offsetHeight; > > > if (vendorWinH == winH) > > window.resizeBy(0, > > vendorInfoH); > > else { > > var newVendorWinH = winH + > > vendorInfoH; > > alert("newVendorWinH = " + > > newVendorWinH); > > alert("vendorWinH = " + > > vendorWinH); > > alert("winH = " + winH); > > if (newVendorWinH > > > vendorWinH) > > window.resizeBy(0, > > newVendorWinH - vendorWinH); > > else if (newVendorWinH < > > vendorWinH) > > > > //window.resizeBy(0, vendorWinH - newVendorWinH); > > window.resizeBy(0, > > winH - (vendorWinH + 5)); > > } > > } > > }); > > > } > > > [/CODE] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send
[Proto-Scripty] Re: IE 7 and dynamic div in IFRAMES
Hi smatcookie, If we can see the error in action, it could be more easy to solve the problem. btw, I did not hear of such a problem on iFRAME with dynamic content, but isn't it possible for you to uncapsulate the iFRAME with a DIV so that instead retrieving the IFRAME height, you'll retrieve the DIV's one. -- david On 16 mar, 00:19, smartcookie wrote: > Hey, I recently received a bug report from a client that they were not > able to navigate our e-learning web site. > > I found out that the specs they had were IE 7 > and the only time this happened is on pages with collapsible / > expandable animated div's. What is happening is the iframe in our > site that contains the content is not stretching the height of the > iframe when dynamic content is expanded, after the page height has > already been rendered. > > I have seen this issue reported by doing a google search, but did not > see any solutions to this problem. > > We have a script which runs on the onload of the iframe to resize the > height, but again this issue only arises with dynamic content. > > Does anybody know any solutions or can think of where to start? > P.S. removing the iframe is not an option in this situation --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---