Need some help with this code.
var myDoc = app.documents[0]
var mySel = app.selection[0]
var myStory = mySel.parentStory; // Now we are pointing to the entire story
var myHolidayStyle1 = "Holiday-Header" // Header 'day of the week'
var myHolidayStyle2 = "Holiday-Sub-Heading-Date" // Header 'month and day'
var myHolidayStyle3 = "Holiday-Header-Body" // Lead Paragraph 'default paragraph style'
if (mystory = "Monday" ) {
paragraphs(0).appliedparagraphstyles = myHolidayStyle1;
}
else if (mystory = "Tuesday") {
mystory.paragraphs(0). appliedparagraphstyles = myHoldiayStyle1;
}
else if (mystory = "Wednesday") {
mystory.papragraph(0).appliedparagraphstyles = myHolidayStyle1;
}
else if (mystory = "Thursday") {
mystory.paragraphs(0).appliedparagraphstyles = myHolidayStyle1;
}
else if (mystory = "Friday") {
mystory.paragraphs(0).appliedparagraphstyle = myHolidayStyle1;
}
else if (mystory = "Saturday") {
mystory.paragraphs(0).appliedparagrahstyles = myHolidayStyle1;
}
else if (mystory = "Sunday") {
mystory.paragraphs(0).appliedparagraphstyles = myHolidayStyle1;
}
// it finds if in the selection of the month and day if they equal for example Decmeber 15 then applies the HolidaySub-Heading-Date
if (mystory = "December 15") {
mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
}
else if (mystory = "December 15") {
mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
}
else if (mystory = "December 16") {
mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
}
else if (mystory = "December 17") {
mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
}
else if (mystory = "December 18") {
mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
}
else if (mystory = "December 19") {
mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
}
else if (mystory = "December 20") {
mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
}
else if (mystory = "December 21") {
mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
}
else if (mystory = "December 22") {
mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
}
else if (mystory = "December 23") {
mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
}
else if (mystory = "December 24") {
mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
}
else if (mystory = "December 25") {
mystory. paragraphs(1).appliedparagraphstyles = myHolidayStyle2;
}
// If text doesn't equal Day of the week like Monday and doesn't equal month and date like Decmber 14
// then the document loops into doing the the rest of the document in Holiday-Header-Body
// not sure if this loop will stop once it reaches another day of the week and then repeat the above tasks again.
if (mystory =! [myHolidayStyle0], [myHolidayStyle1]) { // not sure if I did this IF selection not equal Holidaystyle 0 and style 1 then perform loop, correctly???
for (loop=0; loop<myStory.paragraphs.length; loop++)
myStory.paragraphs[loop].appliedParagraphStyle = myHolidayStyle3;
}
=============================
==========================
I'm getting a error saying Paragraph is not a function, but nor is mystory.paragraph(0) , so i'm just trying to figure out what synax goes before that.
=============================
The text that is bold is the prolbem i'm having. I just got a Javascript bible on how to program in javascript. How would i make that function work. I'm sure its simple. I'm just hoping I have If some Then ({) command follow by what I want it to do is correct. And I'm understanding this. there is so many different syntax's to choose from, any help would be appreciated. I work for a Newspaper company, and Indesign CS3 Javascript coding is a bit diffrent from normal javascript.