Created
June 17, 2011 22:00
-
-
Save snay2/1032455 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| rule booklist { | |
| select when web pageview "booklist.byu.edu/cas/mybooks.cfm" | |
| pre { | |
| my_form = << | |
| <div style="display: none;"> | |
| <form id="isbnForm" onsubmit="return false"> | |
| <input name="isbn" value="nonsense" /> | |
| <input type="submit" /> | |
| </form> | |
| </div> | |
| >>; | |
| } | |
| { | |
| append("body", my_form); | |
| watch("#isbnForm", "submit"); | |
| emit <| | |
| var isbn = new Array(); | |
| var row_num = -1; | |
| $K.each($K("#Content table").contents().find("tr"), function(i, val) { | |
| // Don't take the top row, since it's a header | |
| if (row_num >= 0) { | |
| var item = $K(val).find('td:nth-child(4)'); | |
| isbn.push(item.text()); | |
| // Add this to an input | |
| $K("#isbnForm").append('<input type="text" name="isbnList[' + row_num + ']" value="' + item.text() + '" />'); | |
| } | |
| row_num++; | |
| }); | |
| $K("[name=isbn]").trigger("submit"); | |
| |>; | |
| } | |
| } |
This file contains hidden or 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
| rule handle_submit { | |
| select when web submit "#isbnForm" | |
| foreach page:param("isbnList") setting (isbn) | |
| pre { | |
| // API lookups, etc. | |
| } | |
| { | |
| // Debugging information, so we know it's working | |
| emit <| | |
| KOBJ.log('ISBN: ' + isbn); | |
| |>; | |
| // Put the price information into the proper places on the page | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment