var checkInput = function() { // 检查后缀名 txt csv excel // upload_file_1数据集 var files = ["upload_file_1", "upload_file_2"]; for (file_id of files){ var obj = document.getElementById(file_id); var len = obj.files.length; var full_file_name = ""; for (var i = 0; i < len; i++) { full_file_name = obj.files[i].name; // combined.txt } var index =full_file_name.lastIndexOf("."); // 获取文件名后缀的索引 var suffix = full_file_name.substring(index+1, full_file_name.length); // txt if (suffix != "csv" && suffix != "txt" && suffix != "excel"){ window.alert("Please upload a txt, csv or excel file!"); var draw_form = document.getElementsByClassName("draw_form")[0]; draw_form.focus(); return false; } } // window.alert('email') // 检查邮件格式 var email = document.getElementById("email").value; //box var regex = /^[\w\-\.]+@[a-z0-9]+(\-[a-z0-9]+)?(\.[a-z0-9]+(\-[a-z0-9]+)?)*\.[a-z]{2,4}$/i; if (!regex.test(email)) { window.alert("Please submit the correct email address"); // document.getElementById("email").enter.focus(); var process_form = document.getElementsByClassName("draw_form")[0]; process_form.focus(); return false; } // if (email != ""){ // var regex = /^[\w\-\.]+@[a-z0-9]+(\-[a-z0-9]+)?(\.[a-z0-9]+(\-[a-z0-9]+)?)*\.[a-z]{2,4}$/i; // if (!regex.test(email)) { // window.alert("Please submit the correct email address"); // var draw_form = document.getElementsByClassName("draw_form")[0]; // draw_form.focus(); // return false; // } // } return true; } var download_example1 = function() { const fileUrl = "./example/draw_example/dumbbell_example.txt"; // 文件的实际路径 const fileName = "dumbell_example.txt"; // 下载时保存的文件名 const a = document.createElement("a"); // 创建一个 标签元素 a.href = fileUrl; // 设置下载链接 a.download = fileName; // 设置下载文件名 document.body.appendChild(a); // 将 标签添加到页面 a.click(); // 模拟点击 标签,触发下载 document.body.removeChild(a); // 删除 标签,清理DOM } var download_example2 = function() { const fileUrl = "./example/draw_example/dumbbell_barplot_example.txt"; // 文件的实际路径 const fileName = "dumbbell_barplot_example.txt"; // 下载时保存的文件名 const a = document.createElement("a"); // 创建一个 标签元素 a.href = fileUrl; // 设置下载链接 a.download = fileName; // 设置下载文件名 document.body.appendChild(a); // 将 标签添加到页面 a.click(); // 模拟点击 标签,触发下载 document.body.removeChild(a); // 删除 标签,清理DOM } var checkEmail = function() { // 判断email格式是否正确 写的不对 var email = document.getElementById("email").value; //box var regex = /^[\w\-\.]+@[a-z0-9]+(\-[a-z0-9]+)?(\.[a-z0-9]+(\-[a-z0-9]+)?)*\.[a-z]{2,4}$/i; if (email == '' || !regex.test(email)) { window.alert("Please submit the correct email address"); document.getElementById("email").enter.focus(); return false; } else { return true; } }
   

img