dimanche 3 septembre 2017

Applescript/Javascript Verify Safari Checkboxes Were Checked

With the help of a friend I managed to get together an AppleScript that can check off some boxes on an internal website. But if any of these checkboxes were skipped it would not notify me. I would like to add a verify to the javascript to check if all the checkboxes were, in fact, checked off afterwards.

I'm afraid I don't know much of anything about writing JavaScript but I'm learning.

Any guidance would be greatly appreciated!

Keep in mind the real list is over 70 checkboxes long, Here is a redacted version that works for checking off the boxes:

    set employee2 to {"Bob Smith", "Michael Smith", "John Doe", "Jane Doe", "Mike Smith", "Jon Snow"}

set theList to {} repeat with theName in employee2 copy "\"" & theName & "\"," to the end of theList end repeat

set newList to theList as string set GoodList to text 1 thru -2 of newList

tell application "Safari" to tell the front document do JavaScript " $(document).ready(function() {

var arr = [" & GoodList & "];

jQuery.each( arr, function( i, val ) {
jQuery('span[title*=\"' + val + '\"]').closest('.tree-node').find(':input').click(); });

});

var checked = document.querySelectorAll('[name=" & GoodList & "]:checked');

" end tell




Aucun commentaire:

Enregistrer un commentaire