tag:support.primatelabs.com,2011-01-31:/discussions/voodoopad/10324-changing-the-date-formatPrimate Labs: Discussion 2018-09-04T13:11:34Ztag:support.primatelabs.com,2011-01-31:Comment/459887022018-08-29T22:11:04Z2018-08-29T22:11:04Zchanging the date format<div><p>Try this:</p>
<pre>
<code>function pageWasCreated(document, item) {
var attString = item.dataAsAttributedString();
attString.mutableString().appendString("\nThis page was created on " + (new Date().toString()).replace(/ \w+-\d+ \(.*\)$/,"")));
item.setDataWithAttributedString(attString);
}</code>
</pre>
<p>This should give you the second date format. Let me know if you run into any issues.</p></div>Sarahtag:support.primatelabs.com,2011-01-31:Comment/459887022018-08-31T08:05:00Z2018-08-31T08:05:00Zchanging the date format<div><p>Many thanks, but this still returns:</p>
<pre>
<code>This page was created on Fri Aug 31 2018 09:03:16 GMT+0100 (BST)</code>
</pre></div>svstag:support.primatelabs.com,2011-01-31:Comment/459887022018-08-31T15:14:08Z2018-08-31T15:14:08Zchanging the date format<div><p>Did you remove the previous script completely from the VPPageEventScript? If so, have you tried closing and reopening VoodooPad, and then attempting to create a new page?</p></div>Sarahtag:support.primatelabs.com,2011-01-31:Comment/459887022018-08-31T16:02:51Z2018-08-31T16:02:51Zchanging the date format<div><p>Yes tried that and still no joy. My VPPageEventScript contains the<br>
following:</p>
<pre>
<code>function makeOrphanedPage(document) {
var linkedPages = {}; // using a hash table here because it's</code>
</pre>
<p>convenient.<br>
var orphanedPages = []; var summaryPageName = "Orphaned Pages";</p>
<pre>
<code> /* Collect all linked pages. */
var keys = document.keys();
for (i = 0; i < keys.length; i++) {
var page = document.pageForKey(keys[i]);
if (!page.isText() || (page.key() == "orphaned pages")) {
continue;
}
var pageContent = page.dataAsAttributedString();
var linkedPageNames =</code>
</pre>
<p>document.linkedPageNamesInAttributedString(pageContent);</p>
<pre>
<code> for (j = 0; j < linkedPageNames.length; j++) {
linkedKey = linkedPageNames[j].vpkey();
// ignore self links.
if (!linkedKey.isEqualToString(page.key())) {
linkedPages[linkedKey] = "";
}
}
}
/* Now compare the linked pages with all pages to find the orphaned</code>
</pre>
<p>ones. */<br>
for (i = 0; i < keys.length; i++) { var key = keys[i]; if (linkedPages[key] == null) { orphanedPages.push(key); } }</p>
<pre>
<code> /* Create a summary page and open it. */
var summaryPage = document.createNewPageWithName(summaryPageName);
summaryPage.setDataAsString(summaryPageName + "\n\n" +</code>
</pre>
<p>orphanedPages.join("\n"));<br>
}</p>
<pre>
<code>function pageWasOpened(document, page) {
if (page.key() == "orphaned pages") {
makeOrphanedPage(document);
}
}
function pageWasCreated(document, item) {
var attString = item.dataAsAttributedString();
attString.mutableString().appendString("\nThis page was created on</code>
</pre>
<p>" + (new Date().toString()).replace(/ \w+-\d+ (.*)$/,""))); item.setDataWithAttributedString(attString); }</p>
<p>and a new page returns:</p>
<pre>
<code>This page was created on Fri Aug 31 2018 17:02:17 GMT+0100 (BST)</code>
</pre></div>svstag:support.primatelabs.com,2011-01-31:Comment/459887022018-08-31T20:20:11Z2018-08-31T20:20:11Zchanging the date format<div><p>Do you have any other event script pages within that document?</p></div>Sarahtag:support.primatelabs.com,2011-01-31:Comment/459887022018-09-01T09:41:26Z2018-09-01T09:41:26Zchanging the date format<div><p>No, just the one: <a href="https://d.pr/i/G6kIkH">https://d.pr/i/G6kIkH</a></p></div>svstag:support.primatelabs.com,2011-01-31:Comment/459887022018-09-04T13:11:30Z2018-09-04T13:11:30Zchanging the date format<div><p>I see. What version of VoodooPad are you currently using? And which device and macOS version?</p>
<p>Does anything change if you delete the current VPPageEventScript and create a new one with the above script?</p></div>Sarah