[Proto-Scripty] Re: Range utility increment

2009-09-25 Thread Alex McAuley

if you want an array then i wluld use push
var twos=new Array();
for(i=0;i=10;++i) {

if(i%2) {
  twos[]=i;
}


}

.
Untested but i cant see why it wouldnt work


Alex Mcauley
http://www.thevacancymarket.com
- Original Message - 
From: JoJo tokyot...@gmail.com
To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
Sent: Thursday, September 24, 2009 11:15 PM
Subject: [Proto-Scripty] Range utility increment



 http://www.prototypejs.org/api/utility/dollar-r

 From the documentation of the Range utility, it seems like it can only
 increment by 1's. For example, $A($R(1,10,true)) gives you:
 [1,2,3,4,5,6,7,8,9,10].

 I'm looking for a way to specify that I want to increment by any
 value. Let's say count up by 2's: [2,4,6,8,10].  How do you do this?
 
 


--~--~-~--~~~---~--~~
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: Range utility increment

2009-09-25 Thread T.J. Crowder

Hi,

 I'm looking for a way to specify that I want to increment by any
 value. Let's say count up by 2's: [2,4,6,8,10].  How do you do this?

ObjectRange itself is for ranges of consecutive values, but you can
get an array of such values by applying Enumerable#collect to a range:

var twos;
twos = $R(1, 5).collect(function(x) { return x * 2; });

...although frankly I'd probably go with a straight loop like Alex did
(although a slightly different one):

function everyOther(start, end) {
var n;
var rv = [];
for (n = start; n = end; n += 2) {
rv[rv.length] = n;
}
return rv;
}

FWIW,
--
T.J. Crowder
tj / crowder software / com
www.crowdersoftware.com


On Sep 24, 11:15 pm, JoJo tokyot...@gmail.com wrote:
 http://www.prototypejs.org/api/utility/dollar-r

 From the documentation of the Range utility, it seems like it can only
 increment by 1's. For example, $A($R(1,10,true)) gives you:
 [1,2,3,4,5,6,7,8,9,10].

 I'm looking for a way to specify that I want to increment by any
 value. Let's say count up by 2's: [2,4,6,8,10].  How do you do this?
--~--~-~--~~~---~--~~
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: Range utility increment

2009-09-25 Thread Alex McAuley

function everyOther(start, end, increment) {
var n;
var rv = [];
for (n = start; n = end; n += increment) {
rv[rv.length] = n;
}
return rv;
}



Just a mod to make it better to be able to change it to 3's, 4's, 5's


;)




Alex Mcauley
http://www.thevacancymarket.com
- Original Message - 
From: T.J. Crowder t...@crowdersoftware.com
To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
Sent: Friday, September 25, 2009 8:29 AM
Subject: [Proto-Scripty] Re: Range utility increment



Hi,

 I'm looking for a way to specify that I want to increment by any
 value. Let's say count up by 2's: [2,4,6,8,10].  How do you do this?

ObjectRange itself is for ranges of consecutive values, but you can
get an array of such values by applying Enumerable#collect to a range:

var twos;
twos = $R(1, 5).collect(function(x) { return x * 2; });

...although frankly I'd probably go with a straight loop like Alex did
(although a slightly different one):

function everyOther(start, end) {
var n;
var rv = [];
for (n = start; n = end; n += 2) {
rv[rv.length] = n;
}
return rv;
}

FWIW,
--
T.J. Crowder
tj / crowder software / com
www.crowdersoftware.com


On Sep 24, 11:15 pm, JoJo tokyot...@gmail.com wrote:
 http://www.prototypejs.org/api/utility/dollar-r

 From the documentation of the Range utility, it seems like it can only
 increment by 1's. For example, $A($R(1,10,true)) gives you:
 [1,2,3,4,5,6,7,8,9,10].

 I'm looking for a way to specify that I want to increment by any
 value. Let's say count up by 2's: [2,4,6,8,10]. How do you do this?



--~--~-~--~~~---~--~~
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: Ajax accept headers in google chrome frame

2009-09-25 Thread Alex

yeah sure, that's what i thought too. was just testing the water to
see if anyone else had come across the problem. nothing in google but
then, as you say, it's still very early days.

On Sep 24, 5:22 pm, T.J. Crowder t...@crowdersoftware.com wrote:
 Hi,

 That's strange.  It sounds like something to report to the Google
 Frame team, though, since it doesn't happen normally.  Google Frame is
 early-stage[1] after all...

 [1]http://code.google.com/chrome/chromeframe/

 -- T.J. :-)

 On Sep 24, 3:53 pm, Alex alexandersand...@gmail.com wrote:



  fair point...

  yeah, with 1.6.1, rails still reports */*

  On Sep 24, 3:01 pm, T.J. Crowder t...@crowdersoftware.com wrote:

   Hi,

This is with prototype 1.6.0.2.

   Any chance of trying it with something more recent?  1.6.0.3 was
   released a year ago, and 1.6.1 was released last month.

   -- T.J.

   On Sep 24, 1:07 pm, Alex alexandersand...@gmail.com wrote:

hi everyone,

just trying out our site at work with chrome frame, and found an odd
effect: the HTTP_ACCEPT header from an ajax request only reports
(according to rails) as */*. This is with prototype 1.6.0.2.

This is not the case for standalone chrome. that works as expected.

I realise it's still very early in it's development, just wondering if
anyone seen this and had any ideas?

cheers,

alex.
--~--~-~--~~~---~--~~
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: Remove onFocus borders from buttons in IE

2009-09-25 Thread Alex McAuley


$$().invoke('observe','click',function(element) {

$(element).blur();


});


Alex Mcauley
http://www.thevacancymarket.com
- Original Message - 
From: clicforw...@googlemail.com
To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
Sent: Thursday, September 24, 2009 4:48 PM
Subject: [Proto-Scripty] Remove onFocus borders from buttons in IE



 Hello,

 i tried to remove this Borders around links and form buttons in IE

 script type=text/javascript
 document.observe(dom:loaded, function() {
  $$('button').onclick = function() {
  (this).blur();
 }
 });
 /script

 But this is not working!
 Anyone an idea how it can done right?

 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] Periodic updater

2009-09-25 Thread MakeWebAPP

Hello To all,

 I’m facing the problem with my over traffic site, My self using
periodic updater but when traffic increase script will not respond any
more.

 A browser sends the request to sever but it will not get back on
the page (Response will not display on the page). Can any one help me
how to tackle issue?


Thank you.


--~--~-~--~~~---~--~~
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: Periodic updater

2009-09-25 Thread Alex McAuley

is the server sending a response ?

Alex Mcauley
http://www.thevacancymarket.com
- Original Message - 
From: MakeWebAPP makeweb...@gmail.com
To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
Sent: Friday, September 25, 2009 12:04 PM
Subject: [Proto-Scripty] Periodic updater



Hello To all,

 I’m facing the problem with my over traffic site, My self using
periodic updater but when traffic increase script will not respond any
more.

 A browser sends the request to sever but it will not get back on
the page (Response will not display on the page). Can any one help me
how to tackle issue?


Thank you.





--~--~-~--~~~---~--~~
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 not working in IE. Stumped.

2009-09-25 Thread MastaBaba

Thanks!

Changing the span to a div was already enough, surprisingly enough. I
needed to keep the paramName, because it refers to what's to be passed
to the file from which the results are being picked up.

Anyway, who'd have thought! Thanks again!

Babak

On Sep 24, 8:10 pm, david david.brill...@gmail.com wrote:
 Hi MastaBaba,

 input name=post[tags] type=text id=tags value= /
 span id=indicator1 style=display: noneLoading.../span
 div id=hint1 class=hint/div
 script type=text/javascript
     new Ajax.Autocompleter(tags,hint1,../s/backend/tags.php,
 {paramName: value,minChars: 2, tokens: ',', indicator:
 'indicator1'});
 /script

 Try this, it could work :\\
 I change the span element to receive the autocompleter response to a
 div, and change the paramName to 'value' because it's value property
 that handle the user input.

 --
 david

 On 24 sep, 09:06, MastaBaba babak.fakhamza...@gmail.com wrote:



  Hi all,

  I've got autocompleter not working in IE, 6, 7 or 8. I'm not getting
  thrown a JS error, it simply doesn't load the underlying file, almost
  as if the library isn't even loaded, though it is. The script works in
  FF, Opera, Safari and Chrome. Any thoughts would be wildly
  appreciated.

  Here's a page with the not-working script:

 http://v2.ovcsupport.net/sandbox/javascripttest.php

  Thanks in advance for any thoughts on this,

  Babak Fakhamzadeh
--~--~-~--~~~---~--~~
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] better solution for Observe.click

2009-09-25 Thread Marcelo Barbudas

Hi.

I am using a Rails plugin called will_paginate. For AJAX pagination they 
use the solution presented here:
http://wiki.github.com/mislav/will_paginate/ajax-pagination
The code is something like:

|document.observe(dom:loaded, function() {
[..]
container.observe('click', function(e) {
  var el = e.element()
  if (el.match('.pagination a')) {
el.up('.pagination').insert(createSpinner())
new Ajax.Request(el.href, { method: 'get' })
e.stop()
[..]
})
|

The only problem is that this doesn't work if there are images in the 
links.
a class=next_page rel=next href=/link
img src=/images/right-point.gif?1244992605 alt=Right-point//a
When clicking on the image the trigger is called for the img tag, not 
the link.

Here is the fix I've implemented:
container.observe('click', function(e) {
  if (e.element().match('img'))
var el = e.element().ancestors()[0]
  else
var el = e.element()

  if (el.match('.pagination a')) {
el.up('.pagination').insert(createSpinner())
new Ajax.Request(el.href, { method: 'get' })
e.stop()
  }
})

I am not the best JS programmer, so maybe someone has a better solution.

-- 
Cheers,
M.

--~--~-~--~~~---~--~~
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: Range utility increment

2009-09-25 Thread Matt Foster

I'd just use an 'iterator' class to do this...

var EvenNumber = Class.create(
{
initialize : function(num){
this.num = (num % 2 == 1) ? num - 1 : num;
},
succ : function(){
return new EvenNumber(this.num + 2);
},
toString : function(){
return this.num;
}
});

var bottom = new EvenNumber(1);

var top = new EvenNumber(21);
var range = $A($R(bottom, top));

console.log(range);

I had done this to a much greater extent in my date range selector
gadget.  Where it became the master range, held a range of calendar
objects, which were in themselves ranges of date objects... fun stuff.

https://positionabsolute.net/blog/2008/01/google-calendar-date-range-selection.php

ps just looking over that, should rename that class to
PositiveEvenNumber, only going to work one way, but you get the idea


On Sep 25, 4:15 am, Alex McAuley webmas...@thecarmarketplace.com
wrote:
 function everyOther(start, end, increment) {
         var n;
         var rv = [];
         for (n = start; n = end; n += increment) {
             rv[rv.length] = n;
         }
         return rv;
     }

 Just a mod to make it better to be able to change it to 3's, 4's, 5's

 ;)

 Alex Mcauleyhttp://www.thevacancymarket.com

 - Original Message -
 From: T.J. Crowder t...@crowdersoftware.com
 To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
 Sent: Friday, September 25, 2009 8:29 AM
 Subject: [Proto-Scripty] Re: Range utility increment

 Hi,

  I'm looking for a way to specify that I want to increment by any
  value. Let's say count up by 2's: [2,4,6,8,10].  How do you do this?

 ObjectRange itself is for ranges of consecutive values, but you can
 get an array of such values by applying Enumerable#collect to a range:

     var twos;
     twos = $R(1, 5).collect(function(x) { return x * 2; });

 ...although frankly I'd probably go with a straight loop like Alex did
 (although a slightly different one):

     function everyOther(start, end) {
         var n;
         var rv = [];
         for (n = start; n = end; n += 2) {
             rv[rv.length] = n;
         }
         return rv;
     }

 FWIW,
 --
 T.J. Crowder
 tj / crowder software / comwww.crowdersoftware.com

 On Sep 24, 11:15 pm, JoJo tokyot...@gmail.com wrote:
 http://www.prototypejs.org/api/utility/dollar-r

  From the documentation of the Range utility, it seems like it can only
  increment by 1's. For example, $A($R(1,10,true)) gives you:
  [1,2,3,4,5,6,7,8,9,10].

  I'm looking for a way to specify that I want to increment by any
  value. Let's say count up by 2's: [2,4,6,8,10]. How do you do this?
--~--~-~--~~~---~--~~
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: Range utility increment

2009-09-25 Thread Alex McAuley

That only gives you even or odd increments to the top number...

WHat if you wanted every 5th number ...

Better to go with my/TJ's loop


Alex Mcauley
http://www.thevacancymarket.com
- Original Message - 
From: Matt Foster mattfoste...@gmail.com
To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
Sent: Friday, September 25, 2009 5:57 PM
Subject: [Proto-Scripty] Re: Range utility increment



I'd just use an 'iterator' class to do this...

var EvenNumber = Class.create(
{
initialize : function(num){
this.num = (num % 2 == 1) ? num - 1 : num;
},
succ : function(){
return new EvenNumber(this.num + 2);
},
toString : function(){
return this.num;
}
});

var bottom = new EvenNumber(1);

var top = new EvenNumber(21);
var range = $A($R(bottom, top));

console.log(range);

I had done this to a much greater extent in my date range selector
gadget.  Where it became the master range, held a range of calendar
objects, which were in themselves ranges of date objects... fun stuff.

https://positionabsolute.net/blog/2008/01/google-calendar-date-range-selection.php

ps just looking over that, should rename that class to
PositiveEvenNumber, only going to work one way, but you get the idea


On Sep 25, 4:15 am, Alex McAuley webmas...@thecarmarketplace.com
wrote:
 function everyOther(start, end, increment) {
 var n;
 var rv = [];
 for (n = start; n = end; n += increment) {
 rv[rv.length] = n;
 }
 return rv;
 }

 Just a mod to make it better to be able to change it to 3's, 4's, 5's

 ;)

 Alex Mcauleyhttp://www.thevacancymarket.com

 - Original Message -
 From: T.J. Crowder t...@crowdersoftware.com
 To: Prototype  script.aculo.us 
 prototype-scriptaculous@googlegroups.com
 Sent: Friday, September 25, 2009 8:29 AM
 Subject: [Proto-Scripty] Re: Range utility increment

 Hi,

  I'm looking for a way to specify that I want to increment by any
  value. Let's say count up by 2's: [2,4,6,8,10]. How do you do this?

 ObjectRange itself is for ranges of consecutive values, but you can
 get an array of such values by applying Enumerable#collect to a range:

 var twos;
 twos = $R(1, 5).collect(function(x) { return x * 2; });

 ...although frankly I'd probably go with a straight loop like Alex did
 (although a slightly different one):

 function everyOther(start, end) {
 var n;
 var rv = [];
 for (n = start; n = end; n += 2) {
 rv[rv.length] = n;
 }
 return rv;
 }

 FWIW,
 --
 T.J. Crowder
 tj / crowder software / comwww.crowdersoftware.com

 On Sep 24, 11:15 pm, JoJo tokyot...@gmail.com wrote:
 http://www.prototypejs.org/api/utility/dollar-r

  From the documentation of the Range utility, it seems like it can only
  increment by 1's. For example, $A($R(1,10,true)) gives you:
  [1,2,3,4,5,6,7,8,9,10].

  I'm looking for a way to specify that I want to increment by any
  value. Let's say count up by 2's: [2,4,6,8,10]. How do you do this?



--~--~-~--~~~---~--~~
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: Range utility increment

2009-09-25 Thread bernard
so generalize the class...
  - Original Message - 
  From: Alex McAuley 
  To: prototype-scriptaculous@googlegroups.com 
  Sent: Friday, September 25, 2009 12:25 PM
  Subject: [Proto-Scripty] Re: Range utility increment



  That only gives you even or odd increments to the top number...

  WHat if you wanted every 5th number ...

  Better to go with my/TJ's loop


  Alex Mcauley
  http://www.thevacancymarket.com
  - Original Message - 
  From: Matt Foster mattfoste...@gmail.com
  To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
  Sent: Friday, September 25, 2009 5:57 PM
  Subject: [Proto-Scripty] Re: Range utility increment



  I'd just use an 'iterator' class to do this...

  var EvenNumber = Class.create(
  {
  initialize : function(num){
  this.num = (num % 2 == 1) ? num - 1 : num;
  },
  succ : function(){
  return new EvenNumber(this.num + 2);
  },
  toString : function(){
  return this.num;
  }
  });

  var bottom = new EvenNumber(1);

  var top = new EvenNumber(21);
  var range = $A($R(bottom, top));

  console.log(range);

  I had done this to a much greater extent in my date range selector
  gadget.  Where it became the master range, held a range of calendar
  objects, which were in themselves ranges of date objects... fun stuff.

  
https://positionabsolute.net/blog/2008/01/google-calendar-date-range-selection.php

  ps just looking over that, should rename that class to
  PositiveEvenNumber, only going to work one way, but you get the idea


  On Sep 25, 4:15 am, Alex McAuley webmas...@thecarmarketplace.com
  wrote:
   function everyOther(start, end, increment) {
   var n;
   var rv = [];
   for (n = start; n = end; n += increment) {
   rv[rv.length] = n;
   }
   return rv;
   }
  
   Just a mod to make it better to be able to change it to 3's, 4's, 5's
  
   ;)
  
   Alex Mcauleyhttp://www.thevacancymarket.com
  
   - Original Message -
   From: T.J. Crowder t...@crowdersoftware.com
   To: Prototype  script.aculo.us 
   prototype-scriptaculous@googlegroups.com
   Sent: Friday, September 25, 2009 8:29 AM
   Subject: [Proto-Scripty] Re: Range utility increment
  
   Hi,
  
I'm looking for a way to specify that I want to increment by any
value. Let's say count up by 2's: [2,4,6,8,10]. How do you do this?
  
   ObjectRange itself is for ranges of consecutive values, but you can
   get an array of such values by applying Enumerable#collect to a range:
  
   var twos;
   twos = $R(1, 5).collect(function(x) { return x * 2; });
  
   ...although frankly I'd probably go with a straight loop like Alex did
   (although a slightly different one):
  
   function everyOther(start, end) {
   var n;
   var rv = [];
   for (n = start; n = end; n += 2) {
   rv[rv.length] = n;
   }
   return rv;
   }
  
   FWIW,
   --
   T.J. Crowder
   tj / crowder software / comwww.crowdersoftware.com
  
   On Sep 24, 11:15 pm, JoJo tokyot...@gmail.com wrote:
   http://www.prototypejs.org/api/utility/dollar-r
  
From the documentation of the Range utility, it seems like it can only
increment by 1's. For example, $A($R(1,10,true)) gives you:
[1,2,3,4,5,6,7,8,9,10].
  
I'm looking for a way to specify that I want to increment by any
value. Let's say count up by 2's: [2,4,6,8,10]. How do you do this?



  

--~--~-~--~~~---~--~~
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: Range utility increment

2009-09-25 Thread Matt Foster

 That only gives you even or odd increments to the top number...

Incorrect, notice the constructor method? It ensures that the number
given is even such that you'll never get a range of odd numbers.
Granted the last line of the Jojo's question was

 Let's say count up by 2's: [2,4,6,8,10].  How do you do this?

Hence why I went with this specific implementation, to demonstrate how
you can create classes that the ObjectRange class can use to create
proper ranges.  I didn't feel it was necessary to abstract out the
class such that it covers all bases but demonstrate how to do it one
way and then Jojo could modify for their own purposes.

 Better to go with my/TJ's loop

What an arrogant plug of your own spaghetti code and hasty discredit
to my contribution.  Exposing your shortfalls isn't difficult, you
aren't creating a range object, completely bypassing the ObjectRange's
functionality and just simply creating a hacked out array.

So to put the nail in the coffin, here is the classes abstracted out

var IncrementNumber = Class.create({
initialize : function(num, increment){
this.num = num;
this.increment = increment;
},
succ : function(){
return this.clone(this.num + this.increment, 
this.increment);
},
clone : function(num, increment){
return new IncrementNumber(num, increment);
},
toString : function(){
return this.num;
}
});
var EvenNumber = Class.create(IncrementNumber,
{
initialize : function($super, num){
$super(num, 2);
this.num = (num % 2 == 1) ? num - 1 : num;
},
clone : function(num, increment){
return new EvenNumber(num);
}
});
var NumberRange = Class.create(ObjectRange,
{
_each: function(iterator) {
var value = this.start;
while (this.include(value.num)) {
  iterator(value.num);
  value = value.succ();
}
},

});
var bottom = new IncrementNumber(-10, 2);
//var bottom = new EvenNumber(-20);
var top = new EvenNumber(25);
var range = $A(new NumberRange(bottom, top));

console.log(range);

nothing gets me fired up like a flame...









On Sep 25, 2:25 pm, Alex McAuley webmas...@thecarmarketplace.com
wrote:
 That only gives you even or odd increments to the top number...

 WHat if you wanted every 5th number ...

 Better to go with my/TJ's loop

 Alex Mcauleyhttp://www.thevacancymarket.com

 - Original Message -
 From: Matt Foster mattfoste...@gmail.com
 To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
 Sent: Friday, September 25, 2009 5:57 PM
 Subject: [Proto-Scripty] Re: Range utility increment

 I'd just use an 'iterator' class to do this...

 var EvenNumber = Class.create(
 {
 initialize : function(num){
 this.num = (num % 2 == 1) ? num - 1 : num;
 },
 succ : function(){
 return new EvenNumber(this.num + 2);
 },
 toString : function(){
 return this.num;
 }
 });

 var bottom = new EvenNumber(1);

 var top = new EvenNumber(21);
 var range = $A($R(bottom, top));

 console.log(range);

 I had done this to a much greater extent in my date range selector
 gadget.  Where it became the master range, held a range of calendar
 objects, which were in themselves ranges of date objects... fun stuff.

 https://positionabsolute.net/blog/2008/01/google-calendar-date-range-...

 ps just looking over that, should rename that class to
 PositiveEvenNumber, only going to work one way, but you get the idea

 On Sep 25, 4:15 am, Alex McAuley webmas...@thecarmarketplace.com
 wrote:
  function everyOther(start, end, increment) {
  var n;
  var rv = [];
  for (n = start; n = end; n += increment) {
  rv[rv.length] = n;
  }
  return rv;
  }

  Just a mod to make it better to be able to change it to 3's, 4's, 5's

  ;)

  Alex Mcauleyhttp://www.thevacancymarket.com

  - Original Message -
  From: T.J. Crowder t...@crowdersoftware.com
  To: Prototype  script.aculo.us
  prototype-scriptaculous@googlegroups.com
  Sent: Friday, September 25, 2009 8:29 AM
  Subject: [Proto-Scripty] Re: Range utility increment

  Hi,

   I'm looking for a way to specify that I want to increment by any
   value. Let's say count up by 2's: [2,4,6,8,10]. How do you do this?

  ObjectRange itself is for ranges of consecutive values, but you can
  get an array of such values by applying Enumerable#collect to a range:

  var twos;
  twos = $R(1, 5).collect(function(x) { return x * 2; });

  ...although frankly I'd probably go with a straight loop like Alex did
  (although a slightly different one):

  function everyOther(start, end) {
  var n;
  var rv = [];
  for (n = start; n = end; n += 2) {
  

[Proto-Scripty] Re: Range utility increment

2009-09-25 Thread Alex McAuley

Omg get over yourself you have taken what i said completely the wrong way..

What arrogant plug was that?...

Lets take your code and look at it shall we...

30+ lines for no reason other than Hey look at me, i can write a 
function/class in 30 lines that only needs to be 5.

Chill out dude, i wasn't knocking your code, it was just OTT.

You can continue to think you are right which is arrogance in itself... 
there is more than one way to skin a cat.

TJ's/My loop that took all of 30 seconds to create is faster no doubt, has 
less weight and does the job. I personaly have better things to do than 
write some amazing class to achieve what can be done in 30 seconds - 
evidently you do not so good luck with that.



Alex Mcauley
http://www.thevacancymarket.com


- Original Message - 
From: Matt Foster mattfoste...@gmail.com
To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
Sent: Friday, September 25, 2009 9:16 PM
Subject: [Proto-Scripty] Re: Range utility increment



 That only gives you even or odd increments to the top number...

Incorrect, notice the constructor method? It ensures that the number
given is even such that you'll never get a range of odd numbers.
Granted the last line of the Jojo's question was

 Let's say count up by 2's: [2,4,6,8,10].  How do you do this?

Hence why I went with this specific implementation, to demonstrate how
you can create classes that the ObjectRange class can use to create
proper ranges.  I didn't feel it was necessary to abstract out the
class such that it covers all bases but demonstrate how to do it one
way and then Jojo could modify for their own purposes.

 Better to go with my/TJ's loop

What an arrogant plug of your own spaghetti code and hasty discredit
to my contribution.  Exposing your shortfalls isn't difficult, you
aren't creating a range object, completely bypassing the ObjectRange's
functionality and just simply creating a hacked out array.

So to put the nail in the coffin, here is the classes abstracted out

var IncrementNumber = Class.create({
initialize : function(num, increment){
this.num = num;
this.increment = increment;
},
succ : function(){
return this.clone(this.num + this.increment, this.increment);
},
clone : function(num, increment){
return new IncrementNumber(num, increment);
},
toString : function(){
return this.num;
}
});
var EvenNumber = Class.create(IncrementNumber,
{
initialize : function($super, num){
$super(num, 2);
this.num = (num % 2 == 1) ? num - 1 : num;
},
clone : function(num, increment){
return new EvenNumber(num);
}
});
var NumberRange = Class.create(ObjectRange,
{
_each: function(iterator) {
var value = this.start;
while (this.include(value.num)) {
  iterator(value.num);
  value = value.succ();
}
},

});
var bottom = new IncrementNumber(-10, 2);
//var bottom = new EvenNumber(-20);
var top = new EvenNumber(25);
var range = $A(new NumberRange(bottom, top));

console.log(range);

nothing gets me fired up like a flame...









On Sep 25, 2:25 pm, Alex McAuley webmas...@thecarmarketplace.com
wrote:
 That only gives you even or odd increments to the top number...

 WHat if you wanted every 5th number ...

 Better to go with my/TJ's loop

 Alex Mcauleyhttp://www.thevacancymarket.com

 - Original Message -
 From: Matt Foster mattfoste...@gmail.com
 To: Prototype  script.aculo.us 
 prototype-scriptaculous@googlegroups.com
 Sent: Friday, September 25, 2009 5:57 PM
 Subject: [Proto-Scripty] Re: Range utility increment

 I'd just use an 'iterator' class to do this...

 var EvenNumber = Class.create(
 {
 initialize : function(num){
 this.num = (num % 2 == 1) ? num - 1 : num;
 },
 succ : function(){
 return new EvenNumber(this.num + 2);
 },
 toString : function(){
 return this.num;
 }
 });

 var bottom = new EvenNumber(1);

 var top = new EvenNumber(21);
 var range = $A($R(bottom, top));

 console.log(range);

 I had done this to a much greater extent in my date range selector
 gadget. Where it became the master range, held a range of calendar
 objects, which were in themselves ranges of date objects... fun stuff.

 https://positionabsolute.net/blog/2008/01/google-calendar-date-range-...

 ps just looking over that, should rename that class to
 PositiveEvenNumber, only going to work one way, but you get the idea

 On Sep 25, 4:15 am, Alex McAuley webmas...@thecarmarketplace.com
 wrote:
  function everyOther(start, end, increment) {
  var n;
  var rv = [];
  for (n = start; n = end; n += increment) {
  rv[rv.length] = n;
  }
  return rv;
  }

  Just a mod to make it better to be able to change it to 3's, 4's, 5's

  ;)

  Alex Mcauleyhttp://www.thevacancymarket.com

  - Original Message -
  From: T.J. Crowder t...@crowdersoftware.com
  To: Prototype  script.aculo.us
  prototype-scriptaculous@googlegroups.com
  Sent: Friday, September 25, 2009 8:29 AM
  Subject: [Proto-Scripty] Re: Range utility increment

  Hi,

   I'm looking for a way to specify that I want to increment by any
   value.