Created
May 23, 2012 18:52
-
-
Save ChewingPencils/2777049 to your computer and use it in GitHub Desktop.
External Drafts Bookmarklet js file.
This file contains 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
/* | |
Drafts App Bookmarklets (http://agiletortoise.com/drafts) | |
Author: Sean Korzdorfer | |
Date: 13:51:29 Wed May 23 2012 | |
Re: https://gist.github.com/gists/2579288 | |
Most of the Date functions used snippets I created from: | |
http://www.webdevelopersnotes.com/tips/html/10_ways_to_format_time_and_date_using_javascript.php3 | |
*/ | |
function formatDate(d){ | |
var d_names = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday","Friday", "Saturday"); | |
var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); | |
var curr_day = d.getDay(); | |
var curr_date = d.getDate(); | |
var curr_month = d.getMonth(); | |
var curr_year = d.getFullYear(); | |
return d_names[curr_day] + ", " + m_names[curr_month] + " " + curr_date + ", " + curr_year; | |
} | |
function formatTime(d){ | |
var curr_hour = d.getHours(); | |
var curr_min = d.getMinutes(); | |
var curr_sec = d.getSeconds(); | |
var a_p = ""; | |
if (curr_hour < 12){a_p = "AM";} | |
else {a_p = "PM";} | |
if (curr_hour == 0){curr_hour = 12;} | |
if (curr_hour > 12){curr_hour = curr_hour - 12;} | |
if (curr_min < 10){curr_min = "0" + curr_min;} | |
if (curr_sec < 10){curr_sec = "0" + curr_sec;} | |
return curr_hour + ":" + curr_min + ":" + curr_sec + " " + a_p; | |
} | |
var d = new Date(); | |
var dateString = formatDate(d); | |
var timeString = formatTime(d); | |
//document.getElementById("demo").innerHTML= dateString +" " + timeString; | |
window.location='drafts://x-callback-url/create?text=[' + encodeURIComponent(document.title)+ ']('+ encodeURIComponent(document.location.href)+')' + '%0A:%09'+ dateString + " " + timeString + '%0A%0A'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment