Last active
August 29, 2015 14:04
-
-
Save moqada/5382e2a879830741b723 to your computer and use it in GitHub Desktop.
[Bookmarklet] Add batch action for updating due per List
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
(function(authToken){ | |
var containerClsName = 'batch_due_action_container'; | |
var initialize = function() { | |
$('.' + containerClsName).remove(); | |
$('.list').each(function(){ | |
var $list = $(this); | |
var $form = $('<form class="' + containerClsName + '">') | |
.appendTo($list.find('.list-header')); | |
var $input = $('<input type="text" placeholder="YYYYMMDD" maxlength="8" size="10">') | |
.appendTo($form); | |
$form.on('submit', function(e){ | |
e.preventDefault(); | |
var dateStr = $input.val(); | |
var date = new Date(0); | |
date.setFullYear(parseInt(dateStr.slice(0, 4))); | |
date.setMonth(parseInt(dateStr.slice(4, 6)) - 1); | |
date.setDate(parseInt(dateStr.slice(6))); | |
$list.find('.list-card .list-card-details .list-card-title') | |
.each(function(){ | |
Trello.put('cards/' + $(this).attr('href').split('/')[2], { | |
due: date.getTime() | |
}); | |
}); | |
}); | |
}); | |
}; | |
$.getScript('https://trello.com/1/client.js?key=' + authToken, function(){ | |
Trello.authorize({ | |
interactive: false, | |
success: initialize, | |
error: function(){ | |
alert('You need to authorize Trello'); | |
Trello.authorize({ | |
type: "popup", | |
expiration: "never", | |
scope: { read: true, write: true }, | |
success: initialize | |
}); | |
} | |
}); | |
}); | |
})('<API Key>'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment