allow JSON or TSV parsing

This commit is contained in:
Devin Howard 2016-03-26 14:20:49 +08:00
parent 92f78aa56a
commit 53867caae8

View file

@ -37,7 +37,16 @@ Metamaps.Import = {
$('body').bind('paste', function(e) {
var text = e.originalEvent.clipboardData.getData('text/plain');
var results = self.parseTabbedString(text);
var results;
if (text[0] === '{') {
try {
results = JSON.parse(text);
} catch (Error e) {
results = false;
}
} else {
results = self.parseTabbedString(text);
}
if (results === false) return;
var topics = results.topics;