开发者

How to format settings

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...


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜