Skip to content
Permalink
Browse files

added cpg/hg19 import page

  • Loading branch information
yuj12001 committed Sep 25, 2015
1 parent 727ad02 commit e845f71c143324a7c1a3ea11860d4275b9b0763f
Showing with 123 additions and 2 deletions.
  1. +106 −0 ImportFiles.html
  2. +17 −2 dynamic_loading.php
@@ -0,0 +1,106 @@
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
</head>
<body>
<div id="uploadFile">
table name: <input type="text" id="fname"><br>
</div>
</body>
</html>

<script>
this.makeUploadForm = function() {
var fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.addEventListener('change', function (e) {
var file = fileInput.files[0];
var textType = /text.*/;
if (file.type.match(textType)) {
var reader = new FileReader();
reader.onload = function (e) {
var Data = reader.result;
var name = document.getElementById("fname").value;
uploadFile(Data,name);
}
reader.readAsText(file);
} else {
alert("File not supported!");
}
});
var f = document.createElement("form");
fileInput.style.display="inline";
f.innerHTML = "upload file:";
f.appendChild(fileInput);
document.getElementById("uploadFile").appendChild(f);
}
this.makeUploadForm();
var uploadFile = function(data,name){
var fileArray = data.split("\n");
headerArray = fileArray[0].split("\t");
dataToSend = '';
counter = 3000;
for(i = 0; i < fileArray.length; i++){
dataToSend += "\n"+ fileArray[i];
counter--;
if(counter == 0){
dataToSend = dataToSend.trim();
dataToSend = "\n"+dataToSend;
$.ajax({
url: "dynamic_loading.php",
type: 'POST',
dataType: "json",
data: {
"header": headerArray,
"upload": dataToSend,
"tableName": name
}
}).success(function (data) {
}).error(function (req, status, error) {
$("body").append(status + ": " + error);
});
dataToSend = '';
counter = 3000;
}
}
dataToSend = dataToSend.trim();
dataToSend = "\n"+dataToSend;
$.ajax({
url: "dynamic_loading.php",
type: 'POST',
dataType: "json",
data: {
"header": headerArray,
"upload": dataToSend,
"tableName": name
}
}).success(function (data) {
}).error(function (req, status, error) {
$("body").append(status + ": " + error);
});
}
</script>
@@ -19,8 +19,15 @@
if (isset($_POST["upload"])){
$timestamp = (new DateTime())->getTimestamp();
$data = parseData($_POST["upload"]);
$result = insertToDb($timestamp, $_POST["header"],$data);
ajaxReturn($result);
if(isset($_POST["tableName"])){
$result = insertToDb($_POST["tableName"], $_POST["header"],$data);
ajaxReturn($result);
}
else{
$result = insertToDb($timestamp, $_POST["header"],$data);
ajaxReturn($result);
}
}
else if (isset($_POST["processData"])){
$serviceUrl = $_POST["processData"];
@@ -853,6 +860,14 @@ function insertToDb($timestamp,$header, $data){
// echo $result;
mysqli_query ($link,$result);
}
$sql = "SELECT @n:=0";
mysqli_query ($link,$sql);
$sql = "UPDATE ".$tableName." SET ID = @n := @n + 1";
mysqli_query ($link,$sql);
return $tableName;
//echo json_encode($tableName);
}

0 comments on commit e845f71

Please sign in to comment.
You can’t perform that action at this time.