Created
June 14, 2012 06:39
-
-
Save tinybeans/2928423 to your computer and use it in GitHub Desktop.
MTのブログ記事の公開日に現在時刻をセットするボタンを挿入
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
jQuery(function($){ | |
var btn = $('<button class="button mt-edit-field-button"></button>') | |
.text('公開日を現在時刻に設定') | |
.click(function(){ | |
if (confirm('公開日時を変更していいですか!?') == false) { | |
return false; | |
} | |
stamp(); | |
return false; | |
}); | |
$('#authored_on-label').after(btn); | |
// ブログ記事のbasenameを現在時間にする | |
function stamp () { | |
toggleFile(); | |
var now = new Date(); | |
var yyyy = now.getFullYear(); | |
var mo = $.digit(now.getMonth() + 1); | |
var dd = $.digit(now.getDate()); | |
var hh = $.digit(now.getHours()); | |
var mi = $.digit(now.getMinutes()); | |
var ss = $.digit(now.getSeconds()); | |
var dateTime = '' + dd +'-'+ hh + mi + ss; | |
document.entry_form.authored_on_date.value = '' + yyyy + '-' + mo + '-' + dd; | |
document.entry_form.authored_on_time.value = '' + hh + ':' + mi + ':' + ss; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment