]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/jslib.js
1 Array
.prototype.indexFromEnd = function(d
) {
5 return p
[p
.length
+ d
];
10 /* how horribly inefficient */
11 String
.prototype.replaceAll = function(f
, t
) {
12 var i
= this.indexOf(f
);
22 /* how horribly inefficient (again) */
23 String
.prototype.splitMax = function(by
, max
) {
24 var items
= this.split(by
);
25 var newitems
= items
.slice(0, max
-1);
27 if(items
.length
>= max
)
28 newitems
.push(items
.slice(max
-1).join(by
));
33 function setAtEnd(obj
) {
34 pos
= obj
.value
.length
;
36 if(obj
.createTextRange
) {
37 var range
= obj
.createTextRange();
38 range
.move("character", pos
);
40 } else if(obj
.selectionStart
) {
42 obj
.setSelectionRange(pos
, pos
);