|
| 1 | +var section_count = 0; |
| 2 | +var secretary_name = "Damien"; |
| 3 | +var date = new Date(); |
| 4 | +var year = date.getFullYear(); |
| 5 | + |
| 6 | +function init() { |
| 7 | + $("#chead").append($("<p/>", { text: "Opening paragraph" })); |
| 8 | + $("#chead").append($("<textarea/>", { id: "chead_input" })); |
| 9 | + $("textarea").htmlarea({ toolbar: ["bold", "italic", "underline", "|", "link", "unlink"] }); |
| 10 | +} |
| 11 | + |
| 12 | +function createNewSection() { |
| 13 | + section_count++; |
| 14 | + |
| 15 | + section = $("<div/>", { id: "csection_"+section_count, class: "csection" }); |
| 16 | + section_controls = $("<div/>", { id: "csection_"+section_count+"_controls" }); |
| 17 | + |
| 18 | + section_controls_form = $("<form/>"); |
| 19 | + section_controls_form.append("Heading: "); |
| 20 | + section_controls_form.append($("<input/>", { type: "text", id: "csection_"+section_count+"_heading" })); |
| 21 | + section_controls_form.append(" "); |
| 22 | + section_controls_form.append("Subsection: "); |
| 23 | + section_controls_form.append($("<input/>", { type: "checkbox", id: "csection_"+section_count+"_sub" })); |
| 24 | + section_controls_form.append(" "); |
| 25 | + section_controls_form.append("Section filler: "); |
| 26 | + section_controls_form.append($("<input/>", { type: "checkbox", id: "csection_"+section_count+"_fill" })); |
| 27 | + section_controls_form.append(" "); |
| 28 | + section_controls_form.append("Category: "); |
| 29 | + section_controls_form_category = $("<select/>", { id: "csection_"+section_count+"_category" }); |
| 30 | + section_controls_form_category.append($("<option/>", { value: "none", text: "None" })); |
| 31 | + section_controls_form_category.append($("<option/>", { value: "about-us", text: "About Us" })); |
| 32 | + section_controls_form_category.append($("<option/>", { value: "chronicle", text: "Chronicle" })); |
| 33 | + section_controls_form_category.append($("<option/>", { value: "contact-us", text: "Contact Us" })); |
| 34 | + section_controls_form_category.append($("<option/>", { value: "events", text: "Events" })); |
| 35 | + section_controls_form_category.append($("<option/>", { value: "feedback", text: "Feedback & Enquiries" })); |
| 36 | + section_controls_form_category.append($("<option/>", { value: "for-sponsors", text: "For Sponsors" })); |
| 37 | + section_controls_form_category.append($("<option/>", { value: "freshers", text: "Freshers" })); |
| 38 | + section_controls_form_category.append($("<option/>", { value: "membership", text: "Membership" })); |
| 39 | + section_controls_form_category.append($("<option/>", { value: "mental-health", text: "Mental Health Support" })); |
| 40 | + section_controls_form_category.append($("<option/>", { value: "opportunities", text: "Opportunities" })); |
| 41 | + section_controls_form_category.append($("<option/>", { value: "speakers", text: "Speaker Series" })); |
| 42 | + section_controls_form_category.append($("<option/>", { value: "sponsorship", text: "Sponsorship" })); |
| 43 | + section_controls_form.append(section_controls_form_category); |
| 44 | + section_controls_form.append(" "); |
| 45 | + |
| 46 | + delete_button = $("<button/>", { type: "button" , text: "Delete section" }); |
| 47 | + delete_button.click(function () { $("#csection_"+section_count).remove(); }); |
| 48 | + section_controls_form.append(delete_button); |
| 49 | + |
| 50 | + section_controls.append(section_controls_form); |
| 51 | + section.append(section_controls); |
| 52 | + section.append($("<textarea/>", { id: "csection_"+section_count+"_input" })); |
| 53 | + $("#csections").append(section); |
| 54 | + $("#csection_"+section_count+"_input").htmlarea({ toolbar: ["bold", "italic", "underline", "|", "link", "unlink"] }); |
| 55 | +} |
| 56 | + |
| 57 | +function preview() { |
| 58 | + $("#code").empty(); |
| 59 | + $("#preview").empty(); |
| 60 | + var output = ""; |
| 61 | + |
| 62 | + output += "<table width='800' border='0' cellspacing='2' cellpadding='0' style='font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 1.5em; color: #444444;'>"; |
| 63 | + output += "<tr><td>"; |
| 64 | + output += "<table width='800' border='0'><tr><td width='700' valign='middle'><img src='http://www.cumsa.org/images/logo_cumsa_chronicle.jpg' alt='Cambridge University Malaysia and Singapore Association' border='0' /></td><td width='100' align='right' valign='middle'><img src='http://www.cumsa.org/images/icon_chronicle_chronicle.jpg' alt='[Chronicle]' border='0' /></td></tr></table>"; |
| 65 | + output += "</td></tr>"; |
| 66 | + |
| 67 | + output += "<tr><td style='padding: 10px;'>"; |
| 68 | + output += $.htmlClean($("#chead_input").val(), { |
| 69 | + allowedTags: ["table", "tr", "td", "img", "br", "hr", "a", "b", "i", "u", "strong", "em", "p"] |
| 70 | + }); |
| 71 | + output += "<br /><hr width='400' color='#1166ff' />"; |
| 72 | + output += "</td></tr>"; |
| 73 | + |
| 74 | + var section = 1; |
| 75 | + var subsection = 1; |
| 76 | + |
| 77 | + var menu = ""; |
| 78 | + var body = ""; |
| 79 | + |
| 80 | + for ( i = 1; i <= section_count; i++ ) { |
| 81 | + if ( $("#csection_"+i).length != 0 ) { |
| 82 | + if ( $("#csection_"+i+"_category").val() == "none" ) { |
| 83 | + icon = ""; |
| 84 | + } else { |
| 85 | + icon = "<img src='http://www.cumsa.org/images/icon_" + $("#csection_"+i+"_category").val() + "_chronicle.jpg' alt='[" +$("#csection_"+i+"_category option:selected").text() + "]' border='0' />"; |
| 86 | + } |
| 87 | + |
| 88 | + if ( $("#csection_"+i+"_sub").prop("checked") ) { |
| 89 | + if ( subsection == 1 ) { |
| 90 | + section--; |
| 91 | + } |
| 92 | + heading = section + "." + subsection + " " + $("#csection_"+i+"_heading").val(); |
| 93 | + menu += section + "." + subsection + " <a href='#csection" + i + "'>" + $("#csection_"+i+"_heading").val() + "</a><br />"; |
| 94 | + subsection++; |
| 95 | + } else { |
| 96 | + if ( subsection != 1 ) { |
| 97 | + section++; |
| 98 | + } |
| 99 | + heading = section + ". " + $("#csection_"+i+"_heading").val(); |
| 100 | + menu += section + ". <a href='#csection" + i + "'>" + $("#csection_"+i+"_heading").val() + "</a><br />"; |
| 101 | + section++; |
| 102 | + subsection = 1; |
| 103 | + } |
| 104 | + |
| 105 | + body += "<tr><td>"; |
| 106 | + body += "<table><tr>"; |
| 107 | + |
| 108 | + if ( $("#csection_"+i+"_category").val() != "none" ) { |
| 109 | + body += "<td width='100' align='center' valign='center'>" + icon + "</td>"; |
| 110 | + body += "<td id='csection" + i + "' name='csection" + i + "' width='700' valign='middle' style='padding: 10px; font-family: Georgia, serif; font-size: 21px; color: #333333; font-variant: small-caps;'>" + heading + "</td></tr></table>"; |
| 111 | + } else { |
| 112 | + body += "<td id='csection" + i + "' name='csection" + i + "' width='800' valign='middle' style='padding: 10px; font-family: Georgia, serif; font-size: 21px; color: #333333; font-variant: small-caps;'>" + heading + "</td></tr></table>"; |
| 113 | + } |
| 114 | + |
| 115 | + body += "</td></tr>"; |
| 116 | + |
| 117 | + if ( $("#csection_"+i+"_fill").prop("checked") ) { |
| 118 | + } else { |
| 119 | + body += "<tr><td style='padding: 10px;'>"; |
| 120 | + body += $.htmlClean($("#csection_"+i+"_input").val(), { |
| 121 | + allowedTags: ["table", "tr", "td", "img", "br", "hr", "a", "b", "i", "u", "strong", "em", "p"] |
| 122 | + }); |
| 123 | + body += "<br /><br /></td></tr>"; |
| 124 | + } |
| 125 | + } |
| 126 | + } |
| 127 | + |
| 128 | + output += "<tr><td style='padding: 10px;'>"; |
| 129 | + output += menu; |
| 130 | + output += "<br /><hr width='400' color='#1166ff' />"; |
| 131 | + output += "</td></tr>"; |
| 132 | + |
| 133 | + output += body; |
| 134 | + |
| 135 | + output += "<tr><td style='padding: 10px;'><hr width='400' color='#1166ff' /><br />If you have any queries, please contact me at <a href='mailto:[email protected]'>[email protected]</a>.<br /><br />Best wishes,<br />" + secretary_name + "<br /><br /><hr width='400' color='#1166ff' /></td></tr>"; |
| 136 | + |
| 137 | + // Start of Platinium and Gold Sponsors |
| 138 | + output += "<tr><td><table width='800' style='font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 1.5em; color: #444444;'>"; |
| 139 | + |
| 140 | + output += "<tr>"; // Row 1 |
| 141 | + output += "<td align='center' style='padding: 5px;'>Platinum Sponsors</td>"; |
| 142 | + output += "<td align='center' style='padding: 5px;'>Gold Sponsors</td></tr>"; |
| 143 | + output += "<tr>"; // Row2 |
| 144 | + output += "<td align='center' style='padding: 5px;'><img src='http://www.cumsa.org/images/logo_osu.png' alt='Overseas Singaporean Unit' border='0' /></td>"; |
| 145 | + output += "<td align='center' style='padding: 5px;'><img src='http://www.cumsa.org/images/logo_contactsg.jpg' alt='Contact Singapore' border='0' /></td></tr>"; |
| 146 | + output += "<tr>"; // Row 3 |
| 147 | + output += "<td align='center' style='padding: 5px;'><img src='http://www.cumsa.org/images/logo_leefoundation.png' alt='Lee Foundation' border='0' /></td>" |
| 148 | + output += "<td align='center' style='padding: 5px;'><img src='http://cumsa.org/images/logo_stee.png' alt='ST Electronics' border='0' /></td></tr>"; |
| 149 | + output += "<tr>"; // Row 4 |
| 150 | + output += "<td align='center' style='padding: 5px;'><img src='http://www.cumsa.org/images/logo_rajahtann.png' alt='Rajah and Tann' border='0' /></td>"; |
| 151 | + output += "<td align='center' style='padding: 5px;'><img src='http://www.cumsa.org/images/logo_edb.png' alt='EDB Singapore' border='0' /></td></tr>"; |
| 152 | + |
| 153 | + output += "</table></td></tr>"; |
| 154 | + |
| 155 | + //Silver Sponsors |
| 156 | + output += "<tr><td><table width='800' style='font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 1.5em; color: #444444;'>"; |
| 157 | + output += "<tr><td align='center' style='padding: 5px;'>Silver Sponsors</td>"; |
| 158 | + output += "<tr><td align='center' style='padding: 5px;'><img src='http://www.cumsa.org/images/logo_gic.png' alt='Government of Singapore Investment Corporation' border='0' /></td>"; |
| 159 | + output += "<tr><td align='center' style='padding: 5px;'><img src='http://cumsa.org/images/logo_BNP.png' alt='BNP Paribas' border='0' /></td>"; |
| 160 | + output += "</table></td></tr>"; |
| 161 | + //End of Silver Sponsors |
| 162 | + output += "<tr><td align='center' style='padding: 10px;'>"; |
| 163 | + output += "Copyright " + year + " <a href='http://www.cumsa.org/'>Cambridge University Malaysia and Singapore Association</a>"; |
| 164 | + output += "</td></tr>"; |
| 165 | + output += "</table>"; |
| 166 | + |
| 167 | + $("#code").text(output).html(); |
| 168 | + $("#preview").append(output); |
| 169 | +} |
0 commit comments