Copy link to clipboard
Copied
I'm using this working expire code,
function Expire()
{
// Get the current date and time
var rightNow = new Date();
// Setup End Date
var rightNow = new Date();
var beginDate = new Date("January 11, 2017 06:15:00 AM");
var endDate = new Date("January 12, 2018 11:57:00 AM");
if (rightNow < beginDate || rightNow > endDate)
{
app.alert("you are not allowed to view this doc.", 1, 0);
this.closeDoc(true)
}
}
Expire();
what I'd like to know is can I modify the endDate to expire right now when I click a button. If that can be done can someone let me know how? Thanks for your help.
PS: I know all the possible workarounds to defeat the code so please don't reveal them if you reply. I just don't want to educate those unscrupulous people looking for that kind of help.
Yes, that's it. If you want to make the file usable for a while after the button is clicked and before it is closed you can use the setTimeOut method to delay the execution of the closeDoc command.
Copy link to clipboard
Copied
You don't need all of it to do that... Just the closeDoc command.
Copy link to clipboard
Copied
You mean like so,
{
app.alert("you are not allowed to view this doc.", 1, 0);
this.closeDoc(true)
}
Copy link to clipboard
Copied
Yes, that's it. If you want to make the file usable for a while after the button is clicked and before it is closed you can use the setTimeOut method to delay the execution of the closeDoc command.
Copy link to clipboard
Copied
I understand the closeDoc, but I don't know how to do this bit. Could you show me how to do it so I can try it out and play around with it? Thanks, Try.
Copy link to clipboard
Copied
Read the documentation of the setTimeOut method of the app object. It's explained there in detail, including examples.
Copy link to clipboard
Copied
You mean you want it to remember that the button was clicked for the next open? Very challenging, you’d have to save the file.
Copy link to clipboard
Copied
Saving the doc isn't a concern for me. The doc should just slam shut when the button is clicked after a date. I got a little closer with Try's help. But, after using it and trying it out I became aware that the doc should be usable for a period of time, even if the close button is clicked. But, then if I don't want the user to use the doc anymore, then the close code would be effective and shut the doc.
Sounds a bit confusing I know but even with the original expire I mix it up with other script (like the reset feature) then I obfuscate all the code, then password the doc. Seems to help a little and nothing is perfected, but we must try to protect the code.