Created
May 5, 2013 21:36
-
-
Save fukubaya/5522275 to your computer and use it in GitHub Desktop.
make a bookmarklet for mail form of sakusaku website.
https://www.tvk-yokohama.com/saku2/mail_form.html
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
/* | |
* mail_form_shortcut.js | |
* | |
* Created by FUKUBAYASHI Yuichiro on 2013/05/06 | |
* Copyright (c) 2013, FUKUBAYASHI Yuichiro | |
* | |
* last update: <2013/05/06 06:18:00> | |
*/ | |
$(document).ready(function(){ | |
var p = { | |
hname : "", | |
uname : "", | |
mailaddress : "", | |
address1 : 14, | |
address2 : "", | |
message : "", | |
age : 28, | |
gend : 0, | |
q1 : 0, | |
q2 : 0, | |
q3 : 0 | |
}; | |
/* make bookmarklet string */ | |
var get_book_marklet = function(p){ | |
return ['javascript:(function(){var f=document.forms[0];', | |
'f.hname.value="', p.hname, '";', | |
'f.uname.value="', p.uname, '";', | |
'f.mailaddress.value="', p.mailaddress, '";', | |
'f.address1.options[', p.address1, '].selected=true;', | |
'f.address2.value="', p.address2, '";', | |
'f.message.value="', p.message,'";', | |
'f.age.options[', p.age, '].selected=true;', | |
'f.gend.options[', p.gend, '].selected=true;', | |
'f.q1.options[', p.q1, '].selected=true;', | |
'f.q2.options[', p.q2, '].selected=true;', | |
'f.q3.options[', p.q3, '].selected=true;', | |
'})();'].join(''); | |
}; | |
/* make a bookmarklet */ | |
$('#btn_get_bookmarklet').click(function(){ | |
p.hname = $('#hname').val(); | |
p.uname = $('#uname').val(); | |
p.mailaddress = $('#mailaddress').val(); | |
p.address1 = $('#address1 option:selected').index(); | |
p.address2 = $('#address2').val(); | |
p.message = $('#message').val(); | |
p.message = p.message.replace(/\n/g,"\\n"); | |
p.age = $('#age option:selected').index(); | |
p.gend = $('#gend option:selected').index(); | |
p.q1 = $('#q1 option:selected').index(); | |
p.q2 = $('#q2 option:selected').index(); | |
p.q3 = $('#q3 option:selected').index(); | |
var $a = $('#a_bookmarklet'), | |
bookmarklet = get_book_marklet(p); | |
$a.attr("href", encodeURI(bookmarklet)); | |
$a.text("サクサクおたよりフォーム"); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment