1 function open_add_picture_box(click_for_more_images_box_id, upload_more_images_section_id) { 2 document.getElementById(click_for_more_images_box_id).style.display = 'none'; 3 document.getElementById(upload_more_images_section_id).style.display = ''; 4 } 5 6 function show_submission_box(submission_box_id, show_hide_link_id) { 7 var box = document.getElementById(submission_box_id); 8 var link = document.getElementById(show_hide_link_id); 9 10 if (box.style.display == '' && link && link.style.display == 'none') { 11 return; 12 } 13 14 if (box) { 15 box.style.display = ''; 16 } 17 18 if (link) { 19 link.style.display = 'none'; 20 } 21 } 22 23 function inv_localized_string(string_id) { 24 var defaults = { 25 "submission_no_title": "Your submission must have a title.", 26 "submission_no_body": "Your submission body is empty.", 27 "submission_title_too_long": "Your submission title must be a maximum of 200 characters", 28 "submission_title_no_html": "Your submission title may not contain html", 29 "submission_body_too_long": "Your submission body must be a maximum of 10000 characters", 30 "submission_not_accepting": "Sorry, we are not accepting any new submissions at this time for this page. Please return in a few days to add your submission", 31 "submission_caption_too_long": "Your image caption must be a maximum of 200 characters", 32 "submission_caption_no_html": "Your image caption may not contain html", 33 "submission_image_file_types": "Your image must be a jpg or gif", 34 "submission_name_too_long": "Your name must be a maximum of 200 characters", 35 "submission_name_no_html": "Your name may not contain html", 36 "submission_location_too_long": "Your location must be a maximum of 200 characters", 37 "submission_cant_in_preview_mode": "This functionality not available in Preview Mode", 38 "submission_please_check_checkbox": "Please check Submission Guidelines checkbox", 39 "submission_captcha_required": "You must enter a word for the submission challenge graphic.", 40 "submission_no_name": "Please enter your name.", 41 "submission_bad_email": "Please enter a valid email address.", 42 "submission_body_no_html": "The body cannot contain HTML.", 43 "submission_location_no_html": "Your location cannot contain HTML.", 44 "submission_gdpr_age_consent": "I am at least 16 years of age.", 45 "submission_privacy_policy_link": "/privacy-policy.html", 46 "submission_privacy_policy_label": "privacy policy", 47 "submission_gdpr_usage_consent": "I understand that you will display my submission on your website.", 48 "submission_gdpr_checked_error": "Please select all privacy and usage checkboxes." 49 }; 50 51 defaults.submission_gdpr_privacy_policy_consent = "I understand and accept the <<PRIVACY_POLICY>>."; 52 defaults.submission_gdpr_privacy_policy_consent = defaults.submission_gdpr_privacy_policy_consent.replace(/<<PRIVACY_POLICY>>/, 53 '<a href="' + defaults.submission_privacy_policy_link + '" target="_blank" style="target-new: tab;">' + 54 defaults.submission_privacy_policy_label + "</a>"); 55 56 57 if (document.localized_string_invitation_map[string_id]) { 58 return document.localized_string_invitation_map[string_id]; 59 } 60 else { 61 return defaults[string_id]; 62 } 63 } 64 65 function save_submission(form) { 66 67 var errors = []; 68 var regexp = /<(script|form)/; 69 var imgregex = /(jpg|jpeg|JPEG|JPG|gif|GIF)/; 70 71 72 73 var title = form.submission_title.value; 74 if (title.length > 200) { 75 errors.push(inv_localized_string('submission_title_too_long')); 76 } 77 if (title.match(/^\s*$/)) { 78 errors.push(inv_localized_string('submission_no_title')); 79 } 80 if (title.match(regexp)) { 81 errors.push(inv_localized_string('submission_title_no_html')); 82 } 83 84 var text = form.submission_text.value; 85 if (text.length > 10000) { 86 errors.push(inv_localized_string('submission_body_too_long')); 87 } 88 if (text.match(/^\s*$/)) { 89 errors.push(inv_localized_string('submission_no_body')); 90 } 91 if (text.match(regexp)) { 92 errors.push(inv_localized_string('submission_body_no_html')); 93 } 94 95 for (var i = 1; i <= 4; i++) { 96 if(form["submission_image_" + i]) { 97 var image = form["submission_image_" + i].value; 98 if(image) { 99 if (image && !image.match(imgregex)) { 100 errors.push(inv_localized_string('submission_image_file_types')); 101 } 102 103 var image_text = form["submission_image_" + i + "_text"].value; 104 if (image_text && image_text.length > 200) { 105 errors.push(inv_localized_string('submission_caption_too_long')); 106 } 107 if (image_text && image_text.match(regexp)) { 108 errors.push(inv_localized_string('submission_caption_no_html')); 109 } 110 } 111 } 112 } 113 114 var author = form.submission_author.value; 115 if (author && author.length > 200) { 116 errors.push(inv_localized_string('submission_name_too_long')); 117 } 118 if (author && author.match(regexp)) { 119 errors.push(inv_localized_string('submission_name_no_html')); 120 } 121 122 var location = form.submission_author_location.value; 123 if (location && location.length>200) { 124 errors.push(inv_localized_string('submission_location_too_long')); 125 } 126 if (location && location.match(regexp)) { 127 errors.push(inv_localized_string('submission_location_no_html')); 128 } 129 130 if (!form.submission_guidelines.checked) { 131 errors.push(inv_localized_string('submission_please_check_checkbox')); 132 } 133 134 if (form.submission_challenge) { 135 var challenge = form.submission_challenge.value; 136 if (!challenge) { 137 errors.push(inv_localized_string('submission_captcha_required')); 138 } 139 } 140 141 // GDPR fields 142 var gdpr_all_checked = true; 143 [].forEach.call( form.querySelectorAll('li.gdpr_field input[type=checkbox]'), function(el){ 144 if ( ! el.checked ) { 145 gdpr_all_checked = false;
146 } 147 } ); 148 149 if ( false === gdpr_all_checked ) { 150 errors.push( inv_localized_string('submission_gdpr_checked_error') ); 151 } 152 153 if (errors.length > 0) { 154 alert(errors.join('\n')); 155 } 156 157 return (errors.length == 0); 158 }
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.