[Prototype-core] Re: For() loops, ++i, i++, i+=1

2009-12-16 Thread Yaffle
++i; is a little more efficient in C language,
in javascript difference in performance of all these operators is tiny


On Dec 16, 3:21 pm, RQuadling rquadl...@googlemail.com wrote:
 Hi.

 Is there any consensus on which is more efficient in a for() loop?

 I was taught that for ++i being the most efficient.

 I've created 2 patches (++ and a +1) in case anyone is interested.

 http://pastie.org/private/3rgonpsn90yjd17q9zwa
 andhttp://pastie.org/private/qufy3rwmaevxc1sysvq

 From what I've read, this could be a little pointless, but I'm not the
 expert in this area.

 Regards,

 Richard.

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


[Prototype-core] Re: Native JSON breakage

2009-12-01 Thread Yaffle
Add this code after prototype.js =). Also this code replaces FF 3.5
Native JSON.stringify with ES compatible...
It breaks compatibility!

delete String.prototype.toJSON; //! deleting this properties required
to save FF 3.5 Native JSON.stringify
delete Array.prototype.toJSON;  //!
delete Number.prototype.toJSON;

Hash.prototype.toJSON = function() {
  return this.toObject();
};

Date.prototype.toISOString = function() {
  return this.getUTCFullYear() + '-' +
(this.getUTCMonth() + 1).toPaddedString(2) + '-' +
this.getUTCDate().toPaddedString(2) + 'T' +
this.getUTCHours().toPaddedString(2) + ':' +
this.getUTCMinutes().toPaddedString(2) + ':' +
this.getUTCSeconds().toPaddedString(2) + '.' +
this.getUTCMilliseconds().toPaddedString(3) + 'Z';
};

Date.prototype.toJSON = function(key) {
  return (Object.isNumber(this)  !isFinite(this) ? null :
this.toISOString());
};

Object.isBoolean = function(object) {
  return Object.prototype.toString.call(object) === [object
Boolean];
};

Object.toJSON = (function() {
  var stack, gap, propertyList, replacerFunction;

  function quote(string) {
return String(string).inspect(true);
  }
  function str(key, holder, indent) {
var value = holder[key];

if (value !== null  (typeof value === 'object' || typeof value
=== 'function')  Object.isFunction(value.toJSON)) {
  value = value.toJSON(key);
}

if (Object.isElement(value)) { return; }

value = replacerFunction.call(holder, key, value);

if (value === null || Object.isBoolean(value)) {
  return String(value);
}

if (Object.isString(value)) {
  return quote(value);
}

if (Object.isNumber(value)) {
  return (isFinite(value) ? String(value) : 'null');
}

if (typeof value === 'object') {
  if (stack.indexOf(value) !== -1) {
throw new TypeError();
  }
  stack.push(value);

  var partial = [],
  braces  = ['{', '}'], i, strP, length, k;

  if (Object.isArray(value)) {
braces = ['[', ']'];
for(i = 0, length = value.length; i  length; i++) {
  strP = str(i, value, indent + gap);
  partial.push(Object.isUndefined(strP) ? 'null' : strP);
}
  } else {
k = propertyList || Object.keys(value);
for(i = 0, length = k.length; i  length; i++) {
  strP = str(k[i], value, indent + gap);
  if (!Object.isUndefined(strP)) {
partial.push(quote(k[i]) + (gap ? ': ' : ':') + strP);
  }
}
  }

  stack.pop();
  return braces[0] + (partial.length  gap ? '\n' + indent + gap
+ partial.join(',\n' + indent + gap) + '\n' + indent : partial.join
(','))  + braces[1];
}
  }

  return function(value /*, replacer, space */) {
var replacer = arguments[1],
space= arguments[2] || '';
stack = [];

replacerFunction = (Object.isFunction(replacer) ? replacer :
function(k, v) { return v; });

if (Object.isArray(replacer)) {
  var hash = {};
  propertyList = replacer.inject([], function(array, v) {
if ((Object.isString(v) || Object.isNumber(v))  !
hash.hasOwnProperty(' ' + v)) {
  hash[' ' + v] = 1;
  array.push(String(v));
}
return array;
  });
} else {
  propertyList = null;
}

if (Object.isNumber(space)) {
  space = Math.min(Math.floor(+space) || 0, 10);
  gap   = ' '.times(space);
} else if (Object.isString(space)) {
  gap   = space.substr(0, 10);
} else {
  gap   = '';
}

return str('', {'': value}, '');
  };
}());

(window.JSON = window.JSON || {}).stringify = Object.toJSON;// FF 3.5
uses diff. implementation

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


[Prototype-core] Re: Suggestion: String#isEmpty instead String#empty

2009-10-02 Thread Yaffle

+1 for REMOVE this methods

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



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-30 Thread Yaffle

May I ask you about localStorage?

I want to update some property, but no space left on device and
FireFox throws error NS_ERROR_FILE_NO_DEVICE_SPACE,
so localStorage[property] stays unchanged.

try{
  localStorage[property] = value; //throws
NS_ERROR_FILE_NO_DEVICE_SPACE
}catch(e){
  localStorage.removeItem(property);// also throws
NS_ERROR_FILE_NO_DEVICE_SPACE
}

How to update property or remove it at all?


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



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-29 Thread Yaffle

I use small (40 lines of code) storage class, that uses cookies or
localStorage.

IMHO, userData and databases not so usefull:
IE userData behavior relies on DOM.
database works in webkit, which supports localStorage.

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



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-29 Thread Yaffle

Yes that's is, but Safari and Chrome isn't popular browsers.(depends
on site audience)

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



[Prototype-core] Re: bug report - sorry, I didn't find the other way to report bugs in prototype.js

2009-09-25 Thread Yaffle

https://prototype.lighthouseapp.com/projects/8886-prototype/tickets/810-fix-eventstopobserving-to-return-element

On 25 сен, 19:17, T.J. Crowder t...@crowdersoftware.com wrote:
 Hi,

  I didn't find the other way to report bugs in prototype.js

 It's described here:http://prototypejs.org/contribute

  i am quite sure it was supposed to be:

      if (!responders) return element;

 Indeed.  Well-spotted!
 --
 T.J. Crowder
 tj / crowder software / comwww.crowdersoftware.com

 On Sep 25, 1:36 pm, Rafał Michalski royalt...@gmail.com wrote:



  prototype.js  - 1.6.1

  I think there is a bug in function stopObserving

  on line: 4571 there is:

      if (!responders) return;

  i am quite sure it was supposed to be:

      if (!responders) return element;

  Because it destroys chaining, I'v had in my code:

  document.stopObserving('mousemove', somefunction).stopObserving
  ('mouseup', someotherfunction)

  because there were no 'mousemove' handler the stopObserving returned
  undefined instead of element

  That is not what stopObserving is supposed to return.

  Kind regards,

  Rafał Michalski
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype: Core group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: $H({}).get('__proto__') in Firefox =)

2009-09-21 Thread Yaffle

base2.js uses prefix for it's Map Class

On 14 сен, 19:53, Yaffle vic99...@yandex.ru wrote:
   Sorry, I'm not following again :) What's not necessary? Which requests
   will be more expensive?

 May be, for-in loop will iterate a little more ...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype: Core group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: isLeftClick and IE8

2009-09-20 Thread Yaffle

http://groups.google.com/group/prototype-core/browse_thread/thread/d8faa05113019c23?hl=en

On Sep 21, 7:58 am, Vaie Lab vaiel...@gmail.com wrote:
 Hi,

 I have this code:

 my_element.observe('click', function(event) {
         event.stop();
         if (event.isLeftClick()) {
           alert('test');
         }

 }

 Work fine on firefox  safari, but IE8 always return false on
 event.isLeftClick()
 Some one have a idea how I can fix this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype: Core group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: $H({}).get('__proto__') in Firefox =)

2009-09-14 Thread Yaffle

There is an issue with Hash#toObject method...

I think, Ajax.Base#parameters can be Hash instead of object to avoid
call to Hash#toObject...

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



[Prototype-core] $H({}).get('__proto__') in Firefox =)

2009-09-13 Thread Yaffle

var h = $H({});
h.set('__proto__','sadfdsf');
alert( typeof( h.get('__proto__') ));

Also try these:

alert(Object.toQueryString('hasOwnProperty=1'.toQueryParams()));
// hasOwnProperty=function%20()%20%7B%20%5Bnative%20code%5D
%20%7DhasOwnProperty=1

May be  Object.prototype.hasOwnProperty.call(hash,key) should be
used instead of 'key in hash' operator?

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



[Prototype-core] Re: $H({}).get('__proto__') in Firefox =)

2009-09-13 Thread Yaffle

++IE dontEnum bug =)

var h = $H({});
h.set('toString',1);
alert(h.toJSON());

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



[Prototype-core] Re: $H({}).get('__proto__') in Firefox =)

2009-09-13 Thread Yaffle

You're right, `hasOwnProperty` can be useless, and
`propertyIsEnumerable` is useless becauseof dontEnum IE bug...
Why not to patch Hash to use some prefix for keys?

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



[Prototype-core] Re: True Hashes using objects as keys

2009-09-11 Thread Yaffle

May I ask you ?

Can I use Hash or vanilla objects for storing [key,value] with
key==='constructor' or key==='prototype' ?

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



[Prototype-core] Re: Template Class

2009-08-27 Thread Yaffle

My Template implementation does it too =)

In Template contrsuctor  template string splits into parts and arrays
of properties.
Example:
a#{x.y}/a   -   [a,[x,y],/a]
=)

I use String#split for this. ( so i use fixed cross-browser split )

On Aug 27, 4:19 pm, T.J. Crowder t...@crowdersoftware.com wrote:
 Samuel,

 Sorry for the Simon error in my last post. Years ago I knew a guy
 named Simon Lebeau, clearly it got ingrained my brain.

 -- T.J. :-)

 On Aug 27, 10:35 am, T.J. Crowder t...@crowdersoftware.com wrote:



  Hi Simon,

  Funny you should be doing that, I was just looking at Template the
  other day and thinking I might suggest a rewrite for 1.7 or 2.0.

  When I did a similar thing in Java a few years back, I made it heavy
  on the initialization and light on evaluation -- since the point of a
  template is to be reused.  The idea was to turn the template string
  into an array of literal segments and replacement segments on init,
  e.g.

      Hello #{username}, welcome to #{sitename}!

  becomes:

      Literal: Hello 
      Replace: 'username'
      Literal: , welcome to 
      Replace: 'sitename'
      Literal: !

  Then evaluating the template is just running through the array;
  roughly (http://pastie.org/596449):

      var result, n, l, sub;
      l = segments.length;
      result = new Array(l);
      for (n = 0; n  l; ++n) {
        segment = segments[n];
        if (typeof segment == 'string') {
          result[n] = segment;
        }
        else {
          sub = /* ...get substitution ... */
          result[n] = sub;
        }
      }
      return result.join('');

  Your current code for #evaluate could readily be recast as the
  #initialize piece.

  Granted this may be slightly larger (because we need to add the loop
  above), but it should (subject to testing) be faster.  It also lends
  itself to future enhancement, such as having formatting syntax, since
  that cost is front-loaded.  I've already proposed the first, trivial,
  formatter for a common use case -- a flag indicating we should escape
  HTML tags when 
  subbing:http://github.com/tjcrowder/prototype/commit/29b76e7a9e9c6168d62f1d1c...

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

  On Aug 26, 12:28 am, Samuel Lebeau samuel.leb...@gmail.com wrote:

   Hi,

   I've been working on a Template rewrite trying to reduce code size and  
   complexity.
   It uses `String#replace` instead of `String#gsub` and thus performs  
   better.
   Do you guys see any enhancements (in terms of performance or code  
   size) that could be made ?

   Diff:http://github.com/samleb/prototype/commit/8ba0a0b80c5ad230cec32e76636...
   File:http://github.com/samleb/prototype/blob/8ba0a0b80c5ad230cec32e766360e...

   Best,
   Samuel.

   On 12 août 09, at 20:37, Allen wrote:

Sorry, misunderstood what you were asking. I thought you meant why
can't the values be populated into the string at initialization.

On Aug 12, 2:32 pm, Yaffle vic99...@yandex.ru wrote:
String#interpolate uses Template#evaluate.
This Template realization makes some actions in constructor of
Template class instead of Template#evaluate.
So if you will use Template#evaluate many times for one Template
object, you will save a little time.

On Aug 12, 6:41 pm, Allen bla...@gmail.com wrote:

You should use Strings interpolate function for this. A template is
meant to be reused many times with many different filler values.

On Jun 14, 10:41 am, Yaffle vic99...@yandex.ru wrote:

var Template = Class.create({
  initialize: function(template, pattern){
    var parts = template.toString().split(pattern ||
Template.Pattern),
        pl = parts.length,
        pattern2 = /^([^.\[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;

    for(var i=1,k=1;ipl;i+=4){
      var before = parts[i] || '',
         escaped = parts[i+1];
      if(before=='\\'){
        parts[k-1] += escaped;
      }else{
        parts[k-1] += before;

        var propList = [],
            expr  = parts[i+2],
            match = pattern2.exec(expr);
        while(match){
          propList.push( match[1].startsWith('[') ?  
match[2].replace(/\
]/g, ']') : match[1] );
          if(!match[3]){
            break;
          }
          expr = expr.substring('[' == match[3] ? match[1].length :
match[0].length);
          match = pattern2.exec(expr);
        }

        if(propList.length){
          parts[k]   = propList;
          parts[k+1] = parts[i+3];
          k+=2;
        }else{
          parts[k-1] += parts[i+3];
        }

      }
    }
    parts.length = k;
    this.parts = parts;
  },
  evaluate: function(object){
    if(Object.isFunction(object.toTemplateReplacements)){
      object = object.toTemplateReplacements();
    }
    object = object || '';

    var r = this.parts[0

[Prototype-core] Re: Adding a object data to PeriodicalExecuter

2009-06-23 Thread Yaffle

Why you can't use closure or Function#curry based on it?

(new PeriodicalExecuter(function(someData){
  var x = someData.num;
  // 
}.curry({ num: 1, text: string })));


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



[Prototype-core] Re: Template Class

2009-06-14 Thread Yaffle


var Template = Class.create({
  initialize: function(template, pattern){
var parts = template.toString().split(pattern ||
Template.Pattern),
pl = parts.length,
pattern2 = /^([^.\[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;

for(var i=1,k=1;ipl;i+=4){
  var before = parts[i] || '',
 escaped = parts[i+1];
  if(before=='\\'){
parts[k-1] += escaped;
  }else{
parts[k-1] += before;

var propList = [],
expr  = parts[i+2],
match = pattern2.exec(expr);
while(match){
  propList.push( match[1].startsWith('[') ? match[2].replace(/\
]/g, ']') : match[1] );
  if(!match[3]){
break;
  }
  expr = expr.substring('[' == match[3] ? match[1].length :
match[0].length);
  match = pattern2.exec(expr);
}

if(propList.length){
  parts[k]   = propList;
  parts[k+1] = parts[i+3];
  k+=2;
}else{
  parts[k-1] += parts[i+3];
}

  }
}
parts.length = k;
this.parts = parts;
  },
  evaluate: function(object){
if(Object.isFunction(object.toTemplateReplacements)){
  object = object.toTemplateReplacements();
}
object = object || '';

var r = this.parts[0];
for(var i=1,pl=this.parts.length;ipl;i+=2){
  var propList = this.parts[i],
  ctx = object;
  for(var j=0,l = propList.length;jl  ctx;j++){
ctx = ctx[propList[j]];
  }
  r+= String.interpret(ctx)+this.parts[i+1];
}
return r;
  }
});
Template.Pattern = /(^|.|\r|\n)(#\{([^\}]*)\})/;

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



[Prototype-core] Template Class

2009-06-13 Thread Yaffle

Why Template Class can't split template string when initializing?

Example:

function xTemplate(template){
  var a = template.split(Template.Pattern),
  l = a.length;
  return function(object){
var x = a[0];
for(var i=1;il;i+=4){
  x+= a[i]+String.interpret(object[a[i+2]])+a[i+3];
}
return x;
  };
}
var st = option value='#{index}' #{selected}#{name}/option,
 f = xTemplate(st),
 o = {index:1,name:'name'},
 t = new Template(st),
 now = function(){ return (new Date()).valueOf(); },
 xt = now()+500;
while(now()xt);
var t1 = now();
for(var i=0;i5;i++){
  f(o);
}
var t2 = now();
for(var i=0;i5;i++){
  t.evaluate(o);
}
alert((now()-t2)/(t2-t1));

with xTemplate we can't use escape sequence and other, but
Template class can be rewritten...
Also String.prototype.split isn't cross-browser, when called with
RegExp as separator, so I used there fixed version from
 http://blog.stevenlevithan.com/archives/cross-browser-split .


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



[Prototype-core] Re: alert('a href=javascript:alert(\'\')test/a'.stripTags());

2009-04-24 Thread Yaffle

String#prototype#split Great Fix

http://blog.stevenlevithan.com/archives/cross-browser-split


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



[Prototype-core] Array.prototype.push.apply and update used by Function.prototype.bind

2009-04-24 Thread Yaffle

  function update(array, args) {
var arrayLength = array.length, length = args.length;
while (length--) array[arrayLength + length] = args[length];
return array;
  }

Array.prototype.push.apply(array,args) == update(array,args) ?

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



[Prototype-core] alert('a href=javascript:alert(\'\')test/a'.stripTags());

2009-04-22 Thread Yaffle

  var tag = /\/?\w+(?:\s+\w+(?:\s*=\s*(?:(?:(?:\\.|[^])*)|
(?:'(?:\\.|[^'])*')|[^\s]+))?)*\s*\/?/gim;
  var tagName = /^\/?(\w+)/im;
  String.prototype.stripHTMLTags = function(tagsToKeep){
if(tagsToKeep)
  tagsToKeep = tagsToKeep.invoke('toLowerCase');
return this.replace(tag, function(m){
  return (tagsToKeep  tagsToKeep.indexOf(m.match(tagName)
[1].toLowerCase())!=-1? m: '');
});
  };

 alert('a href=javascript:alert(\'\')test/a'.stripHTMLTags());
 alert('a href=javascript:alert(\'\')test/a'.stripTags());

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



[Prototype-core] Function.prototype.defer

2009-03-29 Thread Yaffle

Should I use defer method for browsers, which doesn't need a moment
to update new markup?
May be Function.prototype could contain method, that will use defer
for IE and run function immediately for other browsers?
The defer method may slow page loading and may be cause errors.

Sorry, for my english.


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



[Prototype-core] Re: Function.prototype.defer

2009-03-29 Thread Yaffle

Thanks for your answer.
Yes, that example may be very specific and so not  fore core, but:

!DOCTYPE html
html
head
script type=text/javascript src=http://prototypejs.org/assets/
2009/3/27/prototype.js/script
script type=text/javascript// ![CDATA[

document.observe('dom:loaded',function(){

  (function (){
$$('body')[0].update('a id=upsasd/a');

(function(){
  var u = $('ups');
  if(u==null)
alert('ups...');
}).defer();
  }).delay(1);

  setInterval(function(){
$$('body')[0].update('');
  },1);

});

// ]]/script
/head
body
/body
/html
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype: Core group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] _each method and context

2009-02-16 Thread Yaffle

Hello,

Why with JavaScript = 1.5,  Array.prototype._each method doesn't use
a context object

like

Array.prototype.forEach(callback[, thisObject]) in JavaScript 1.6

or

Enumerable.prototype.each(iterator[, context]) ?

thank you.

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



[Prototype-core] Re: Function.prototype.bind optimization

2009-02-16 Thread Yaffle

Good!
My searching it on lighthouse was not succeful...



kangax:
 On Feb 16, 8:56 am, Yaffle vic99...@yandex.ru wrote:
  Function.prototype.bind may work 2 times faster, if when calling bind
  with one argument,it would return function without arg.concat
 
    bind: function() {
      if (arguments.length  2  Object.isUndefined(arguments[0]))
  return this;
      var __method = this, args = $A(arguments), object = args.shift();
          if(arg.length)
        return function() {
          return __method.apply(object, concat($A(arguments)));
        };
      return function(){
        return __method.apply(object, $A(arguments));
      };
    }
 
  P.S.  bind function used with one argument very frequently

 Similar optimization was already done few months ago
 http://prototype.lighthouseapp.com/projects/8886/tickets/215-optimize-bind-bindaseventlistener

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



[Prototype-core] Re: _each method and context

2009-02-16 Thread Yaffle

Hm i am stupid.., why this ticket is for  1.6.0.3 milestone?


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



[Prototype-core] Re: Function.prototype.bind optimization

2009-02-16 Thread Yaffle


Hm i am stupid.., why this ticket is for  1.6.0.3 milestone?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype: Core group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Can the community do anything to help make bugfix releases more frequent?

2009-02-06 Thread Yaffle

May be it's time to make 1.6.0.4 version?

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



[Prototype-core] Re: Prototype in French

2009-01-05 Thread Yaffle
А Смысл? В API вроде все по-русски написано, Все равно надо код
смотреть чаще, если что не понятно.
Вот в коде уже есть вопросы зачем

On Jan 5, 6:58 pm, Cyril CHARLIER cyril.charl...@gmail.com wrote:
 Hi all,

 is there a way to translate the API or Doc to French ?

 I started a translation when it was version 1.5... but it will be more
 efficient if it is an official project !

 Any idea to ask it to Andrew or Tobie ?

 thanks to all !

 Cyril

 PS : I make the same message in LinkedIn Discussion sorry
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype: Core group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Ajax.PeriodicalUpdater inherit Ajax.Base

2009-01-03 Thread Yaffle

Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { $super();
this.onComplete = this.options.onComplete;
this.frequency = (this.options.frequency || 2);
this.decay = (this.options.decay || 1);

}

I don't undestand...
Why Ajax.PeriodicalUpdater should inherit Ajax.Base properties ?

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



[Prototype-core] Re: Protopacked distribution

2008-12-01 Thread Yaffle

You may use Packer at
http://dean.edwards.name/packer/

Better use Minifer (or don't use Base62 encode for Packer) and gzip
js files on you server.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype: Core group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] function for script loading

2008-11-19 Thread Yaffle

hello
I can't find in prototype.js function, that can load javascript such
as jsload

http://code.google.com/p/jsload/downloads/list

It may be very useful.

How about add to prototype lite version of this function?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype: Core group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Prototype.js mistakes

2008-11-07 Thread Yaffle

var Prototype = {
//
  ScriptFragment: 'script[^]*([\\S\\s]*?)\/script',
//
}

May be next code would a little better?

var Prototype = {
//
  ScriptFragment: 'script[^]*(?:!\\-\\-)?([\\S\\s]*?)(?:\\-\\-)?
\/script',
//
}

and for:
  evalScripts: function() {
return this.extractScripts().map(function(script) { return
eval(script) });
  },

  evalScripts: function() {
return this.extractScripts().map(function(script) { return
window.eval(script) });
  },


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype: Core group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---