pentace
04-11-2007, 07:01 PM
im working on a filtering program so that an entire paragraph can be pasted in a textarea and it will be filtered. is there a way to read the variable or array each word is placed in to see if it starts with the characters "-A"? in example
var test = "-Advanced,testing,10:00pm";
gil davis
04-12-2007, 06:26 AM
This will find the first one (if any):
var ary = test.Split(",");
i=0;
while ((i<ary.length) && (ary[i].indexOf("-A") == -1))
{i++;}
if (i<ary.length)
{alert("found [" + i + "] = " + ary[i] + "!");}
else
{alert("none found!");}
pentace
04-12-2007, 02:17 PM
well its a little different than that. What the plan is, is to be able to paste a weekes schedule into a box then filter out all of the junk and create outlook calander appointments.
so i filtered everything out and seperated the sections by "," for further splitting down the line, but for now i need to have it skip over any line that starts with -A or -S because those are not needed as appointments..
example schedule before filter:
BREAK1 Apr 10 05:00 pm - Apr 10 05:15 pm
LUNCH Apr 10 06:45 pm - Apr 10 07:15 pm
BREAK2 Apr 10 08:45 pm - Apr 10 09:00 pm
STANDIND Apr 10 03:00 pm - Apr 10 03:07 pm
MEETING Apr 10 05:37 pm - Apr 10 06:07 pm
MEETING2 Apr 10 04:30 pm - Apr 10 05:00 pm
ADVISEMEETING Apr 10 03:00 pm - Apr 10 11:30 pm
SCHEDULE Apr 10 03:00 pm - Apr 10 11:30 pm
example after filter:
-BREAK1,Apr10,5:00pm,Apr10,5:15pm
-LUNCH,Apr10,6:45pm,Apr10,7:15pm
-BREAK2,Apr10,8:45pm,Apr10,9:00pm
-STANDIND,Apr10,3:00pm,Apr10,3:07pm
-MEETING,Apr10,5:37pm,Apr10,6:07pm
-MEETING2,Apr10,4:30pm,Apr10,5:00pm
-ADVISEMEETING,Apr10,3:00pm,Apr10,11:30pm
-SCHEDULE,Apr10,3:00pm,Apr10,11:30pm
what i need it to look like after filtering out the undded lines:
-BREAK1,Apr10,5:00pm,Apr10,5:15pm
-LUNCH,Apr10,6:45pm,Apr10,7:15pm
-BREAK2,Apr10,8:45pm,Apr10,9:00pm
-MEETING,Apr10,5:37pm,Apr10,6:07pm
-MEETING2,Apr10,4:30pm,Apr10,5:00pm
here is my code so far.
<html>
<head>
<script language="JavaScript">
var nameSpace = null;
var apptFolder = null;
var apptItem = null;
var tempDoc = null;
var outlookApp = null;
var start_time = "6:00pm";
var end_time = "6:30pm";
var start_date = "02/27/2007";
var end_date = "02/27/2007";
var subject_1 = start_time + "-" + end_time + " PBRK1";
var alert_me = "Outlook Appointment Created For " + start_date + " " + subject_1;
function OpenOutlookDoc(whatform) {
outlookApp = new ActiveXObject("Outlook.Application");
nameSpace = outlookApp.getNameSpace("MAPI");
apptFolder = nameSpace.getDefaultFolder(9);
apptItem = apptFolder.Items.add(whatform);
apptItem.body="Paid 15 minute break";
apptItem.subject = subject_1;
apptItem.ReminderMinutesBeforeStart = 5;
apptItem.MeetingStatus = 1;
apptItem.Start = start_date + " " + start_time;
apptItem.End = end_date + " " + end_time;
apptItem.Save();
alert(alert_me);
}
</script>
<script>
function drop(){
var info = document.all.up_apps.value ;
var info =info.replace(/ [0]/g, ",");
var info =info.replace(/ 11:/g, ",11:");
var info =info.replace(/[0-9]-[0-9]/g, "");
var info =info.replace(/0007/g, "");
var info = info.replace(/1007/g, "");
var info =info.replace(/Sunday/g, "");
var info =info.replace(/Monday/g, "");
var info =info.replace(/Tuesday/g, "");
var info =info.replace(/Wednesday/g, "");
var info =info.replace(/Thursday/g, "");
var info =info.replace(/Friday/g, "");
var info =info.replace(/Saturday/g, "");
var info =info.replace(/ /g, "");
var info = info.replace(/Apr/g, ",Apr");
var info =info.replace(/-/g, "");
var info =info.replace(/\r\n\r\n/g, "\r\n");
var info =info.replace(/\r\n\r\n/g, "\r\n");
var info =info.replace (/\r\n\r\n/g, "\r\n");
var info =info.replace(/\r\n\r\n/g, "\r\n");
var info =info.replace(/\r\n\r\n/g, "\r\n");
var info =info.replace(/\r\n\r\n/g, "\r\n");
var info =info.replace (/\r\n\r\n/g, "\r\n");
var info =info.replace(/\n/g, "-");
document.all.to_soon.value=info;
var food = info.split('-'); // Split APN's at comma when the subscriber has more than one APN
for (var i=0, ax=0; ax<1; i++,ax++) { // count i from 0 and fake 2,3,4
if (food[i]) document.aaa[ax].value = food[i];
if (food[i].match("-S"||"-A")){food[i]=""};
if (food[i].match("-S")){food[i]=""};
document.all.a1.value=food[1];
document.all.a2.value=food[2];
document.all.a3.value=food[3];
document.all.a4.value=food[4];
document.all.a5.value=food[5];
}
}
</script>
</head>
<body>
<textarea name="up_apps" value=ggg style="width:400;height:300;" onchange="drop()"></textarea>
<textarea style="width:400;height:300;" name=to_soon></textarea><br>
<form name=aaa>
<input name=a1><br>
<input name=a2><br>
<input name=a3><br>
<input name=a4><br>
<input name=a5><br>
</form>
<!--
BREAK1 Apr 10 05:00 pm - Apr 10 05:15 pm
LUNCH Apr 10 06:45 pm - Apr 10 07:15 pm
BREAK2 Apr 10 08:45 pm - Apr 10 09:00 pm
STANDIND Apr 10 03:00 pm - Apr 10 03:07 pm
MEETING Apr 10 05:37 pm - Apr 10 06:07 pm
MEETING2 Apr 10 04:30 pm - Apr 10 05:00 pm
ADVISEMEETING Apr 10 03:00 pm - Apr 10 11:30 pm
SCHEDULE Apr 10 03:00 pm - Apr 10 11:30 pm //-->
<input value="Create Outlook Appointment" type="submit" onclick="javascript:OpenOutlookDoc('IPM.Appointment.FormA')"><br>
</body>
</html>