Question

I have an extension that I want to have the user input time info into so that my extension will execute at certain times. I want to have this input be done through the global settings. The problem is that I can't find a way to either A) format the input or B) at least check for valid input.

I just want to be able to use the key to get a value like: 10:15 AM rather than something like "foo" for example...

Was it helpful?

Solution

Well, I wasn't able to get the input to be formatted in the actual preferences window. But I think I found the next best solution.

If you set up a listener for "change" (the event that Apple sends out when setting are changed), you can listen for when new input is put into a text field. Then you just have to collect it and go about formatting it yourself using javascript. I found that there are enough options inside of the String class that you can get the user to enter the right thing.

The only annoying bits are that you have to use Pop-ups to notify the user that something went wrong... But hey, we're early in the Safari Extensions development phase, maybe they'll add that in later.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top