Changeset 191 for trunk/phpbms/common
- Timestamp:
- 02/22/07 10:44:47 (5 years ago)
- Location:
- trunk/phpbms/common
- Files:
-
- 7 modified
-
javascript/common.js (modified) (1 diff)
-
javascript/datepicker.js (modified) (1 diff)
-
javascript/fields.js (modified) (1 diff)
-
javascript/timepicker.js (modified) (1 diff)
-
stylesheet/mozilla/base.css (modified) (1 diff)
-
stylesheet/mozilla/boxes.css (modified) (3 diffs)
-
stylesheet/mozilla/sizes.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpbms/common/javascript/common.js
r146 r191 215 215 } 216 216 217 /* DATE AND TIME --------------------------------------------------------------- */ 218 /* ----------------------------------------------------------------------------- */ 219 function stringToDate(sDate,format){ 220 if (!format) format=DATE_FORMAT; 221 var thedate=""; 222 223 if(sDate){ 224 var sep; 225 var month; 226 var day; 227 var year; 228 switch(format){ 229 case "SQL": 230 sep="-"; 231 year=parseInt(sDate.substring(0,sDate.indexOf(sep)),10); 232 month=parseInt(sDate.substring(sDate.indexOf(sep)+1,sDate.indexOf(sep,sDate.indexOf(sep)+1)),10)-1; 233 day=parseInt(sDate.substring(sDate.lastIndexOf(sep)+1),10); 234 break; 235 case "English, US": 236 sep="/"; 237 month=parseInt(sDate.substring(0,sDate.indexOf(sep)),10)-1; 238 day=parseInt(sDate.substring(sDate.indexOf(sep)+1,sDate.indexOf(sep,sDate.indexOf(sep)+1)),10); 239 year=parseInt(sDate.substring(sDate.lastIndexOf(sep)+1),10); 240 if(year<100) year+=2000; 241 break; 242 } 243 thedate=new Date(year,month,day); 244 } 245 return thedate 246 } 247 248 249 function dateToString(thedate,format){ 250 if(!format) format=DATE_FORMAT; 251 var sdate=""; 252 253 if(thedate){ 254 var sep; 255 switch(format){ 256 case "SQL": 257 sep="-"; 258 sdate= thedate.getFullYear()+sep+(thedate.getMonth()+1)+sep+thedate.getDate(); 259 break; 260 261 case "English, US": 262 sep="/"; 263 sdate= (thedate.getMonth()+1)+sep+thedate.getDate()+sep+thedate.getFullYear(); 264 break; 265 } 266 } 267 return sdate; 268 } 269 270 function stringToTime(sTime,format){ 271 if(!format) format=TIME_FORMAT; 272 var thetime=""; 273 if(sTime){ 274 var timeArray; 275 switch(format){ 276 case "24 Hour": 277 timeArray=sTime.split(":"); 278 if(timeArray.length=3) 279 thetime=new Date(0,0,0,parseInt(timeArray[0],10),parseInt(timeArray[1],10),parseInt(timeArray[2],10)); 280 break; 281 282 case "12 Hour": 283 timeadd=0; 284 if(sTime.indexOf(" PM")) 285 timeadd=12; 286 sTime=sTime.replace(/ AM/,""); 287 sTime=sTime.replace(/ PM/,""); 288 timeArray=sTime.split(":"); 289 if(timeArray.length=2){ 290 var hour=parseInt(timeArray[0],10); 291 if (hour!=12) 292 hour=hour+timeadd; 293 thetime=new Date(0,0,0,hour,parseInt(timeArray[1],10)); 294 } 295 break; 296 } 297 } 298 return thetime; 299 } 300 301 function timeToString(thetime,format){ 302 sTime=""; 303 if(!format) format=TIME_FORMAT; 304 if(thetime){ 305 var hours=thetime.getHours(); 306 var minutes=thetime.getMinutes(); 307 var seconds=thetime.getSeconds(); 308 var sep=":" 309 switch(format){ 310 case "24 Hour": 311 if(hours<10) hours="0"+hours; 312 if(minutes<10) minutes="0"+minutes; 313 if(seconds<10) seconds="0"+seconds; 314 sTime=hours+sep+minutes+sep+seconds; 315 break; 316 317 case "12 Hour": 318 var ampm=" AM"; 319 if(hours>12) 320 hours=hours-12; 321 if(hours>11) 322 ampm=" PM"; 323 if (hours=0) hours=12; 324 if(minutes<10) minutes="0"+minutes; 325 sTime=hours+sep+minutes+ampm; 326 break; 327 } 328 } 329 return sTime; 330 } 331 332 /* MODAL ----------------------------------------------------------------------- */ 217 333 /* ----------------------------------------------------------------------------- */ 218 334 -
trunk/phpbms/common/javascript/datepicker.js
r145 r191 116 116 } 117 117 118 function stringToDate(sDate){119 var sep="/";120 var month=sDate.substring(0,sDate.indexOf(sep))121 var day=sDate.substring(sDate.indexOf(sep)+1,sDate.indexOf(sep,sDate.indexOf(sep)+1))122 var year=sDate.substring(sDate.lastIndexOf(sep)+1);123 year=parseInt(year,10);124 if(year<100) year+=2000;125 return new Date(year,parseInt(month,10)-1,parseInt(day,10));126 }127 128 function mysqlstringToDate(sDate){129 var sep="-";130 var year=sDate.substring(0,sDate.indexOf(sep))131 var month=sDate.substring(sDate.indexOf(sep)+1,sDate.indexOf(sep,sDate.indexOf(sep)+1))132 var day=sDate.substring(sDate.lastIndexOf(sep)+1);133 134 return Date(year,month,day);135 }136 137 function dateToString(thedate){138 var sep="/";139 return (thedate.getMonth()+1)+sep+thedate.getDate()+sep+thedate.getFullYear();140 }141 118 142 119 function formatDateField(thefield){ 143 if(validateDate(thefield.value)){ 144 thefield.value=thefield.value.replace(/\-/g,"/"); 145 var thedate=stringToDate(thefield.value); 146 thefield.value=dateToString(thedate); 147 } else 148 thefield.value=""; 120 thefield.value=dateToString(stringToDate(thefield.value)); 149 121 } -
trunk/phpbms/common/javascript/fields.js
r186 r191 148 148 //validate a time (12 hour) 149 149 function validateTime(strValue){ 150 var objRegExp= /^([1-9]|1[0-2]|0[1-9]){1}(:[0-5][0-9]\ [aApP][mM]){1}$/; 151 if(!objRegExp.test(strValue)) 152 return false; 153 else 154 return true; 150 return (strValue == timeToString(stringToTime(strValue))) 155 151 } 156 152 157 153 // validate dates 158 154 function validateDate(strValue) { 159 var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2,4}$/ 160 161 //check to see if in correct format 162 if(!objRegExp.test(strValue)) 163 return false; //doesn't match pattern, bad date 164 else{ 165 166 for (var i=1;i<strValue.length;i++){ 167 if (strValue.charAt(i)=="." || strValue.charAt(i)=="/" || strValue.charAt(i)=="-"){ 168 var strSeparator = strValue.substring(i,i+1) //find date separator 169 break; 170 } 171 } 172 var arrayDate = strValue.split(strSeparator); //split date into month, day, year 173 //create a lookup for months not equal to Feb. 174 var arrayLookup = { 1 : 31, 3 : 31, 4 : 30, 5 : 31, 6 : 30, 7 : 31, 175 8 : 31, 9 : 30, 10 : 31, 11 : 30, 12 : 31} 176 var intDay = parseInt(arrayDate[1],10); 177 //check if month value and day value agree 178 var intMonth = parseInt(arrayDate[0],10); 179 if(arrayLookup[intMonth] != null) { 180 if(intDay <= arrayLookup[intMonth] && intDay != 0) 181 return true; //found in lookup table, good date 182 } 183 184 //check for February 185 var intYear = parseInt(arrayDate[2],10); 186 if (intYear <1000) intYear=intYear+2000; 187 if( ((intYear % 4 == 0 && intDay <= 29) || (intYear % 4 != 0 && intDay <=28)) && intDay !=0 && intMonth==2) 188 return true; //Feb. had valid number of days 189 } 190 return false; //any other values, bad date 155 return (strValue == dateToString(stringToDate(strValue))); 191 156 } 192 157 -
trunk/phpbms/common/javascript/timepicker.js
r145 r191 93 93 function tpClickHour(hour){ 94 94 var timeField=getObjectFromID(showTP.timeField); 95 var ampm;96 if(!validateTime(timeField.value)) timeField.value="12:00 AM";97 95 98 var minutes=timeField.value.substr(timeField.value.indexOf(":")+1,2) 99 100 if(hour>11) {ampm=" PM"; hour=hour-12}else ampm=" AM"; 101 if (hour==0) hour=12; 102 103 timeField.value=hour+":"+minutes+ampm; 96 var thetime=stringToTime(timeField.value); 97 thetime.setHours(hour); 98 timeField.value=timeToString(thetime); 99 104 100 if(timeField.onchange) timeField.onchange(); 105 101 } 106 102 function tpClickMinute(thetd){ 107 var minutes= thetd.innerHTML;103 var minutes=parseInt(thetd.innerHTML.replace(/:/,"")); 108 104 var timeField=getObjectFromID(showTP.timeField); 109 if(!validateTime(timeField.value)) timeField.value="12:00 AM";110 111 var hours=timeField.value.substring(0,timeField.value.indexOf(":"));112 var ampm=timeField.value.substr(timeField.value.indexOf(" "));113 timeField.value=hours+minutes+ampm;105 106 var thetime=stringToTime(timeField.value); 107 thetime.setMinutes(minutes); 108 timeField.value=timeToString(thetime); 109 114 110 if(timeField.onchange) timeField.onchange(); 115 111 closeTPBox(); -
trunk/phpbms/common/stylesheet/mozilla/base.css
r145 r191 25 25 #footerAbout{float:left;} 26 26 #footerTop{float:right;} 27 28 29 /* ============================================================================== */30 /* Query Results */31 /* ============================================================================== */32 27 33 28 /* ============================================================================== */ -
trunk/phpbms/common/stylesheet/mozilla/boxes.css
r145 r191 14 14 .bodyline{ 15 15 clear:both; 16 border-color:# ABB1B1;16 border-color:#CAD1D1; 17 17 border-style:solid; 18 18 -moz-border-radius:0; … … 21 21 22 22 FIELDSET,.box{ 23 border-color:# 74879C;23 border-color:#ACB7C4; 24 24 border-width:1px; 25 25 border-style:solid; … … 30 30 .box{ 31 31 background-color:#EFF9F9; 32 border:1px solid # 999999;32 border:1px solid #CCCCCC; 33 33 } -
trunk/phpbms/common/stylesheet/mozilla/sizes.css
r165 r191 20 20 H1 { 21 21 font-family: Arial, Helvitica, sans-serif; 22 border-bottom: 1px solid #ccc;23 22 font-size:20px; 24 23 margin:3px; 25 24 padding-left:24px; 26 margin-bottom: 8px;25 margin-bottom:9px; 27 26 font-weight:normal; 28 27 background: url("image/h1graphic.png") 4px 4px no-repeat;;