mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-13 17:28:52 +00:00
Monotone-Parent: ed1968caab1223af1ac0a41cf3fd4504a3dfa473
Monotone-Revision: 4d2697a35bcf482dfa9095d58087ffb8469eada5 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-07-18T19:25:26 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
String.prototype.trim = function() {
|
||||
return this.replace(/(^\s+|\s+$)/g, '');
|
||||
}
|
||||
};
|
||||
|
||||
String.prototype.formatted = function() {
|
||||
var newString = this;
|
||||
@@ -9,31 +9,31 @@ String.prototype.formatted = function() {
|
||||
newString = newString.replace("%{" + i + "}", arguments[i], "g");
|
||||
|
||||
return newString;
|
||||
}
|
||||
};
|
||||
|
||||
String.prototype.repeat = function(count) {
|
||||
var newString = "";
|
||||
for (var i = 0; i < count; i++) {
|
||||
newString += this;
|
||||
}
|
||||
var newString = "";
|
||||
for (var i = 0; i < count; i++) {
|
||||
newString += this;
|
||||
}
|
||||
|
||||
return newString;
|
||||
}
|
||||
return newString;
|
||||
};
|
||||
|
||||
String.prototype.capitalize = function() {
|
||||
return this.replace(/\w+/g,
|
||||
function(a) {
|
||||
return ( a.charAt(0).toUpperCase()
|
||||
+ a.substr(1).toLowerCase() );
|
||||
});
|
||||
}
|
||||
function(a) {
|
||||
return ( a.charAt(0).toUpperCase()
|
||||
+ a.substr(1).toLowerCase() );
|
||||
});
|
||||
};
|
||||
|
||||
String.prototype.decodeEntities = function() {
|
||||
return this.replace(/&#(\d+);/g,
|
||||
function(wholematch, parenmatch1) {
|
||||
return String.fromCharCode(+parenmatch1);
|
||||
});
|
||||
}
|
||||
function(wholematch, parenmatch1) {
|
||||
return String.fromCharCode(+parenmatch1);
|
||||
});
|
||||
};
|
||||
|
||||
String.prototype.asDate = function () {
|
||||
var newDate;
|
||||
@@ -43,18 +43,18 @@ String.prototype.asDate = function () {
|
||||
else {
|
||||
date = this.split("-");
|
||||
if (date.length == 3)
|
||||
newDate = new Date(date[0], date[1] - 1, date[2]);
|
||||
newDate = new Date(date[0], date[1] - 1, date[2]);
|
||||
else {
|
||||
if (this.length == 8) {
|
||||
newDate = new Date(this.substring(0, 4),
|
||||
this.substring(4, 6) - 1,
|
||||
this.substring(6, 8));
|
||||
}
|
||||
if (this.length == 8) {
|
||||
newDate = new Date(this.substring(0, 4),
|
||||
this.substring(4, 6) - 1,
|
||||
this.substring(6, 8));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return newDate;
|
||||
}
|
||||
};
|
||||
|
||||
Date.prototype.sogoDayName = function() {
|
||||
var dayName = "";
|
||||
@@ -77,7 +77,7 @@ Date.prototype.sogoDayName = function() {
|
||||
}
|
||||
|
||||
return dayName;
|
||||
}
|
||||
};
|
||||
|
||||
Date.prototype.daysUpTo = function(otherDate) {
|
||||
var days = new Array();
|
||||
@@ -89,14 +89,14 @@ Date.prototype.daysUpTo = function(otherDate) {
|
||||
day1 = day2;
|
||||
day2 = tmp;
|
||||
}
|
||||
// var day1Date = new Date();
|
||||
// day1Date.setTime(this.getTime());
|
||||
// day1Date.setHours(0, 0, 0, 0);
|
||||
// var day2Date = new Date();
|
||||
// day2Date.setTime(otherDate.getTime());
|
||||
// day2Date.setHours(23, 59, 59, 999);
|
||||
// var day1 = day1Date.getTime();
|
||||
// var day2 = day2Date.getTime();
|
||||
// var day1Date = new Date();
|
||||
// day1Date.setTime(this.getTime());
|
||||
// day1Date.setHours(0, 0, 0, 0);
|
||||
// var day2Date = new Date();
|
||||
// day2Date.setTime(otherDate.getTime());
|
||||
// day2Date.setHours(23, 59, 59, 999);
|
||||
// var day1 = day1Date.getTime();
|
||||
// var day2 = day2Date.getTime();
|
||||
|
||||
var nbrDays = Math.floor((day2 - day1) / 86400000) + 1;
|
||||
for (var i = 0; i < nbrDays; i++) {
|
||||
@@ -106,42 +106,42 @@ Date.prototype.daysUpTo = function(otherDate) {
|
||||
}
|
||||
|
||||
return days;
|
||||
}
|
||||
};
|
||||
|
||||
Date.prototype.getDayString = function() {
|
||||
var newString = this.getYear();
|
||||
if (newString < 1000) newString += 1900;
|
||||
var month = '' + (this.getMonth() + 1);
|
||||
if (month.length == 1)
|
||||
month = '0' + month;
|
||||
newString += month;
|
||||
var day = '' + this.getDate();
|
||||
if (day.length == 1)
|
||||
day = '0' + day;
|
||||
newString += day;
|
||||
var newString = this.getYear();
|
||||
if (newString < 1000) newString += 1900;
|
||||
var month = '' + (this.getMonth() + 1);
|
||||
if (month.length == 1)
|
||||
month = '0' + month;
|
||||
newString += month;
|
||||
var day = '' + this.getDate();
|
||||
if (day.length == 1)
|
||||
day = '0' + day;
|
||||
newString += day;
|
||||
|
||||
return newString;
|
||||
}
|
||||
return newString;
|
||||
};
|
||||
|
||||
Date.prototype.getHourString = function() {
|
||||
var newString = this.getHours() + '00';
|
||||
if (newString.length == 3)
|
||||
newString = '0' + newString;
|
||||
var newString = this.getHours() + '00';
|
||||
if (newString.length == 3)
|
||||
newString = '0' + newString;
|
||||
|
||||
return newString;
|
||||
}
|
||||
return newString;
|
||||
};
|
||||
|
||||
Date.prototype.getDisplayHoursString = function() {
|
||||
var hoursString = "" + this.getUTCHours();
|
||||
if (hoursString.length == 1)
|
||||
hoursString = '0' + hoursString;
|
||||
var hoursString = "" + this.getUTCHours();
|
||||
if (hoursString.length == 1)
|
||||
hoursString = '0' + hoursString;
|
||||
|
||||
var minutesString = "" + this.getUTCMinutes();
|
||||
if (minutesString.length == 1)
|
||||
minutesString = '0' + minutesString;
|
||||
var minutesString = "" + this.getUTCMinutes();
|
||||
if (minutesString.length == 1)
|
||||
minutesString = '0' + minutesString;
|
||||
|
||||
return hoursString + ":" + minutesString;
|
||||
}
|
||||
return hoursString + ":" + minutesString;
|
||||
};
|
||||
|
||||
Date.prototype.stringWithSeparator = function(separator) {
|
||||
var month = '' + (this.getMonth() + 1);
|
||||
@@ -160,81 +160,64 @@ Date.prototype.stringWithSeparator = function(separator) {
|
||||
str = day + '/' + month + '/' + year;
|
||||
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
Date.prototype.sogoFreeBusyStringWithSeparator = function(separator) {
|
||||
return this.sogoDayName() + ", " + this.stringWithSeparator(separator);
|
||||
}
|
||||
};
|
||||
|
||||
Date.prototype.addDays = function(nbrDays) {
|
||||
var milliSeconds = this.getTime();
|
||||
milliSeconds += 86400000 * nbrDays;
|
||||
this.setTime(milliSeconds);
|
||||
}
|
||||
var milliSeconds = this.getTime();
|
||||
milliSeconds += 86400000 * nbrDays;
|
||||
this.setTime(milliSeconds);
|
||||
};
|
||||
|
||||
Date.prototype.earlierDate = function(otherDate) {
|
||||
var workDate = new Date();
|
||||
workDate.setTime(otherDate.getTime());
|
||||
workDate.setHours(0);
|
||||
return ((this.getTime() < workDate.getTime())
|
||||
? this : otherDate);
|
||||
}
|
||||
var workDate = new Date();
|
||||
workDate.setTime(otherDate.getTime());
|
||||
workDate.setHours(0);
|
||||
return ((this.getTime() < workDate.getTime())
|
||||
? this : otherDate);
|
||||
};
|
||||
|
||||
Date.prototype.laterDate = function(otherDate) {
|
||||
var workDate = new Date();
|
||||
workDate.setTime(otherDate.getTime());
|
||||
workDate.setHours(23);
|
||||
workDate.setMinutes(59);
|
||||
workDate.setSeconds(59);
|
||||
workDate.setMilliseconds(999);
|
||||
return ((this.getTime() < workDate.getTime())
|
||||
? otherDate : this);
|
||||
}
|
||||
|
||||
var workDate = new Date();
|
||||
workDate.setTime(otherDate.getTime());
|
||||
workDate.setHours(23);
|
||||
workDate.setMinutes(59);
|
||||
workDate.setSeconds(59);
|
||||
workDate.setMilliseconds(999);
|
||||
return ((this.getTime() < workDate.getTime())
|
||||
? otherDate : this);
|
||||
};
|
||||
|
||||
Date.prototype.beginOfWeek = function() {
|
||||
var beginNumber;
|
||||
var dayNumber = this.getDay();
|
||||
if (weekStartIsMonday) {
|
||||
beginNumber = 1;
|
||||
if (dayNumber == 0)
|
||||
dayNumber = 7;
|
||||
}
|
||||
else
|
||||
beginNumber = 0;
|
||||
var offset = firstDayOfWeek - this.getDay();
|
||||
if (offset > 0)
|
||||
offset -= 7;
|
||||
|
||||
var beginOfWeek = new Date();
|
||||
beginOfWeek.setTime(this.getTime());
|
||||
beginOfWeek.addDays(beginNumber - dayNumber);
|
||||
beginOfWeek.setHours(0);
|
||||
beginOfWeek.setMinutes(0);
|
||||
beginOfWeek.setSeconds(0);
|
||||
beginOfWeek.setMilliseconds(0);
|
||||
|
||||
return beginOfWeek;
|
||||
}
|
||||
var beginOfWeek = new Date();
|
||||
beginOfWeek.setTime(this.getTime());
|
||||
beginOfWeek.addDays(offset);
|
||||
beginOfWeek.setHours(0);
|
||||
beginOfWeek.setMinutes(0);
|
||||
beginOfWeek.setSeconds(0);
|
||||
beginOfWeek.setMilliseconds(0);
|
||||
|
||||
return beginOfWeek;
|
||||
};
|
||||
|
||||
Date.prototype.endOfWeek = function() {
|
||||
var beginNumber;
|
||||
var dayNumber = this.getDay();
|
||||
if (weekStartIsMonday) {
|
||||
beginNumber = 1;
|
||||
if (dayNumber == 0)
|
||||
dayNumber = 7;
|
||||
}
|
||||
else
|
||||
beginNumber = 0;
|
||||
var endOfWeek = this.beginOfWeek();
|
||||
endOfWeek.addDays(6);
|
||||
|
||||
var endOfWeek = new Date();
|
||||
endOfWeek.setTime(this.getTime());
|
||||
endOfWeek.addDays(6 + beginNumber - dayNumber);
|
||||
|
||||
endOfWeek.setHours(23);
|
||||
endOfWeek.setMinutes(59);
|
||||
endOfWeek.setSeconds(59);
|
||||
endOfWeek.setMilliseconds(999);
|
||||
|
||||
return endOfWeek;
|
||||
}
|
||||
endOfWeek.setHours(23);
|
||||
endOfWeek.setMinutes(59);
|
||||
endOfWeek.setSeconds(59);
|
||||
endOfWeek.setMilliseconds(999);
|
||||
|
||||
return endOfWeek;
|
||||
};
|
||||
|
||||
String.prototype._base64_keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
String.prototype.base64encode = function () {
|
||||
@@ -357,7 +340,7 @@ String.prototype.cssSafeString = function() {
|
||||
newString = newString.replace("@", "_", "g");
|
||||
|
||||
return newString;
|
||||
}
|
||||
};
|
||||
|
||||
window.width = function() {
|
||||
if (window.innerWidth)
|
||||
@@ -366,7 +349,7 @@ window.width = function() {
|
||||
return document.body.offsetWidth;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
window.height = function() {
|
||||
if (window.innerHeight)
|
||||
@@ -375,4 +358,4 @@ window.height = function() {
|
||||
return document.body.offsetHeight;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user