Last active
August 29, 2015 14:07
-
-
Save thenoseman/45fb6f64c7b62ed07844 to your computer and use it in GitHub Desktop.
A Form-O-Fill rule demonstrating the use of standard JS prompts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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