Skip to content

Instantly share code, notes, and snippets.

@logontokartik
Created April 4, 2014 09:06
Show Gist options
  • Save logontokartik/9970899 to your computer and use it in GitHub Desktop.
Save logontokartik/9970899 to your computer and use it in GitHub Desktop.
<apex:page controller="ImportMSProjectCon">
<head>
<meta charset="utf-8"></meta>
<title>Bulk Insert Mailing Lists</title>
<!-- Stylesheets-->
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" />
<!-- <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" /> -->
<!-- JS Libraries for JQuery and BootStrap-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<!-- <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script> -->
<script type="text/javascript" src="{!URLFOR($Resource.X2JS)}"></script>
<script>
var x2js = new X2JS({"attributePrefix":"X_"});
var jsonObj;
$(document).ready(function(){
});
function handleFileSelect(){
if (window.File && window.FileReader && window.FileList && window.Blob) {
} else {
alert('The File APIs are not fully supported in this browser.');
return;
}
input = document.getElementById('fileinput');
if (!input) {
alert("Um, couldn't find the fileinput element.");
}
else if (!input.files) {
alert("This browser doesn't seem to support the `files` property of file inputs.");
}
else if (!input.files[0]) {
alert("Please select a file before clicking 'Load'");
}
else {
file = input.files[0];
fr = new FileReader();
fr.onload = receivedText;
fr.readAsText(file);
//fr.readAsDataURL(file);
}
}
function receivedText() {
var result = fr.result.replace('_xmlns','X_xmlns');
var xmlDoc=x2js.parseXmlString(result);
jsonObj = x2js.xml2json( xmlDoc );
document.getElementById('editor').appendChild(document.createTextNode(JSON.stringify(jsonObj)));
console.log(jsonObj);
ImportMSProjectCon.importMSProjectXML(JSON.stringify(jsonObj),function(result,event){
window.location.href = '/' + result;
});
}
</script>
</head>
<body>
<input type="file" id="fileinput"/>
<input type='button' id='btnLoad' value='Load' onclick='handleFileSelect();'/>
<div id="editor"></div>
</body>
</apex:page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment