discourse-legacysite-perl/site/articles/include_form.js
2024-06-17 22:44:21 +10:00

113 lines
3.2 KiB
JavaScript

<script language="javascript">
$(document).ready(function(){
$("#SelectWebsite").click(selectWebsite);
$("#SelectFile").click(selectFile);
$("#Link_Type").change(selectLinkType);
$("#modify_form").submit(checkSubmit);
});
function selectWebsite() {
$(".filecontent").hide();
$(".websitecontent").show();
}
function selectFile() {
$(".websitecontent").hide();
$(".filecontent").show();
}
function selectLinkType() {
var type = $("#Link_Type").val();
if (type == 'article') {
$("#article_photo_form").show();
$("#video_form").hide();
for (i = 1; i <= 16 ; i++) {
$("#article" + i).show();
$("#photo" + i).hide();
}
$("#article_has_video").show();
$("#photo_body").hide();
$("#photo_extra").hide();
$("#photo_large_pic").hide();
} else if (type == 'photo') {
$("#article_photo_form").show();
$("#video_form").hide();
for (i = 1; i <= 16 ; i++) {
$("#article" + i).hide();
$("#photo" + i).show();
}
$("#article_has_video").hide();
$("#photo_body").show();
$("#photo_extra").show();
$("#photo_large_pic").show();
} else {
$("#article_photo_form").hide();
$("#photo_body").show();
$("#video_form").show();
}
}
function checkSubmit() {
var type = $("#Link_Type").val();
if (type == 'article') {
VideoData(0);
} else if (type == 'photo') {
VideoData(0);
$("#Paragraph1").val($("#Main_Body").val());
} else if (type == 'video') {
if ($('#SelectWebsite').is(':checked')) {
if (! checkUrlVal("#URL") ||
$("#Image_Path").val() == "") {
if (! confirm("You haven't entered all the information. The video link may not display properly. Continue?")) {
return false;
}
}
VideoData(1);
} else {
if ($("#File_Path").val() == "") {
if (! confirm("You haven't entered all the information. The video link may not display properly. Continue?")) {
return false;
}
}
VideoData(2);
}
$("#Paragraph1").val($("#Main_Body").val());
}
return true;
}
function VideoData(index) {
if (index != 1) {
$("#URL").val("http://");
$("#Image_Path").val("");
} else {
$("#admin_convert_video").attr('checked', true);
}
if (index != 2) {
$("#File_Path").val("");
}
if (index == 0) {
$("#admin_convert_video").attr('checked', false);
}
}
function checkUrlVal(id_str) {
if ($(id_str).val() == '' || $(id_str).val() == "http://") {
return false;
}
return true;
}
</script>