Last active
November 15, 2021 15:46
-
-
Save scripting/acb9762e5d6969a26780367c75834574 to your computer and use it in GitHub Desktop.
The source for the Drummer oldSchool.getCursorLink verb.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getCursorLink: function () { | |
var headers = opGetHeaders (), urlWebsite; | |
if (headers.urlBlogWebsite !== undefined) { | |
urlWebsite = headers.urlBlogWebsite; | |
} | |
else { | |
urlWebsite = "http://oldschool.scripting.com/" + twitter.getMyScreenname () + "/"; | |
return (undefined); | |
} | |
function pad (n) { | |
return (padWithZeros (n, 2)); | |
} | |
function getPostNode () { | |
var barcursor = opGetBarCursor (), postNode = barcursor; | |
barcursor.visitToSummit (function (theNode) { | |
if (theNode.attributes.getOne ("type") == "calendarDay") { | |
return (false); | |
} | |
postNode = theNode; | |
return (true); //keep looking | |
}); | |
return (postNode); | |
} | |
var whenCursor = new Date (opGetOneAtt ("created")); | |
var postNode = getPostNode (); | |
var whenPost = new Date (postNode.attributes.getOne ("created")); | |
var timeZoneOffset = (headers.timeZoneOffset === undefined) ? "-5" : headers.timeZoneOffset; | |
whenPost = date.convertToTimeZone (whenPost, timeZoneOffset); | |
var url = urlWebsite + whenPost.getFullYear () + "/" + pad (whenPost.getMonth () + 1) + "/" + pad (whenPost.getDate ()) + ".html"; | |
url += "#a" + pad (whenCursor.getUTCHours ()) + pad (whenCursor.getUTCMinutes ()) + pad (whenCursor.getUTCSeconds ()); | |
return (url) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment