Skip to content

Instantly share code, notes, and snippets.

@thenoseman
Last active August 29, 2015 14:07
Show Gist options
  • Save thenoseman/45fb6f64c7b62ed07844 to your computer and use it in GitHub Desktop.
Save thenoseman/45fb6f64c7b62ed07844 to your computer and use it in GitHub Desktop.
A Form-O-Fill rule demonstrating the use of standard JS prompts
var rules = [{
url: /.*test.*/,
name: "Usage of prompt()",
before: function(resolve) {
var a = prompt("Paste excel here");
// Split on \n
// Split on \t
// var data = [
// [cell, cell, cell],
// ];
// To simulate:
var results = [
[1,2,3,4,5],
[1,2,3,4,5]
];
resolve(results);
},
fields: [
{
selector: "input",
value: function(e, data) {
var $target;
// Loop over data with .forEach
data.forEach(function(row) {
// Find the field this should be put into
row.forEach(function(cell) {
$target = $("input");
$target.val(cell);
});
});
return null;
}
}]
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment