Last active
August 29, 2015 14:12
-
-
Save cspotcode/011677f1f229d61f2926 to your computer and use it in GitHub Desktop.
JS code to launch the Doodle Wizard with fields pre-populated for today
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
// Initialize URL parameters | |
var params = { | |
type: 'date', | |
levels: 3, // 2 == yes-no poll, 3 = yes-no-ifneedbe poll | |
locale: 'en', | |
title: 'Ultimate Pickup @ The Bubble', | |
location: 'Harvard Bubble', | |
description: '', | |
name: 'Magazine Beach Pickup', | |
eMailAddress: '[email protected]' // Poll admin link is emailed to this address | |
}; | |
// Add a param where the key is today's date (yyyymmdd) and the value is a time of day ('7pm' or '8pm-10pm') | |
var today = new Date(); | |
params[(today.getYear() + 1900 + '') + ('0' + (today.getMonth() + 1)).slice(-2) + ('0' + today.getDate()).slice(-2)] = '7pm-9pm'; | |
// Build the URL | |
var url = 'http://doodle.com/create?' + Object.keys(params).map(function(key) { | |
return encodeURIComponent(key) + '=' + encodeURIComponent(params[key]); | |
}).join('&'); | |
// Redirect to the URL | |
window.location.href = url; |
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
javascript://%20Initialize%20URL%20parameters%0Avar%20params%20=%20%7B%0A%20%20%20%20type:%20'date',%0A%20%20%20%20levels:%203,%20//%202%20==%20yes-no%20poll,%203%20=%20yes-no-ifneedbe%20poll%0A%20%20%20%20locale:%20'en',%0A%20%20%20%20title:%20'Ultimate%20Pickup%20@%20The%20Bubble',%0A%20%20%20%20location:%20'Harvard%20Bubble',%0A%20%20%20%20description:%20'',%0A%20%20%20%20name:%20'Magazine%20Beach%20Pickup',%0A%20%20%20%20eMailAddress:%20'[email protected]'%20//%20Poll%20admin%20link%20is%20emailed%20to%20this%20address%0A%7D;%0A%0A//%20Add%20a%20param%20where%20the%20key%20is%20today's%20date%20(yyyymmdd)%20and%20the%20value%20is%20a%20time%20of%20day%20('7pm'%20or%20'8pm-10pm')%0Avar%20today%20=%20new%20Date();%0Aparams%5B(today.getYear()%20+%201900%20+%20'')%20+%20('0'%20+%20(today.getMonth()%20+%201)).slice(-2)%20+%20('0'%20+%20today.getDate()).slice(-2)%5D%20=%20'7pm-9pm';%0A%0A//%20Build%20the%20URL%0Avar%20url%20=%20'http://doodle.com/create?'%20+%20Object.keys(params).map(function(key)%20%7B%0A%20%20%20%20return%20encodeURIComponent(key)%20+%20'='%20+%20encodeURIComponent(params%5Bkey%5D);%0A%7D).join('&');%0A//%20Redirect%20to%20the%20URL%0Awindow.location.href%20=%20url; |
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
// A tiny node script to compile the bookmarklet | |
var fs = require('fs'); | |
fs.writeFileSync('bookmarklet.url', 'javascript:' + encodeURI(fs.readFileSync('bookmarklet-source.js', 'utf8'))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment