Skip to content

Instantly share code, notes, and snippets.

@akouryy
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save akouryy/204dba491245b720bfba to your computer and use it in GitHub Desktop.

Select an option

Save akouryy/204dba491245b720bfba to your computer and use it in GitHub Desktop.
A: tags, B: files
A = [
['6','千夜']
['7','シャロ']
['8','リゼ']
['9','ココア']
['0','チノ']
[]
['i','青山']
['o','マヤ']
['p','メグ']
[]
['h','ワイルドギース']
['j','あんこ']
['k','タカヒロ']
['l','ティッピー']
]
$ ->
for x, i in A
if x[0]?
$ '<input>'
.attr
id: 'check-' + i
type: 'checkbox'
name: 'tag'
value: i
.insertBefore $ '#add-tag'
$ '<label>'
.attr
for: 'check-' + i
accesskey: x[0]
.html x[1] + '(<b>' + x[0] + '</b>)'
.insertBefore $ '#add-tag'
$ '<textarea>'
.attr
id: 'tags-' + i
rows: 5
.text x[1] + "\n"
.appendTo $ 'body'
else
$('<br>').insertBefore $ '#add-tag'
bi = 0
$('#add-tag').click f = ->
try
$('input:checked').each ->
i = $(this).attr 'value'
t = $('#tags-' + i)
t.val(t.val() + B[bi] + "\n")
$(this).attr 'checked', false
catch e
console.log e
bi++;
$ 'img'
.attr
src: B[bi]
f()
return
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8"/>
<title>ぴょんぴょん</title>
<script src="jQuery.js"></script>
<script src="ぴょんぴょん.js"></script>
</head>
<body>
<h1>ぴょんぴょん</h1>
<img src="" alt="" height="400"/><br/>
<br/><button id="add-tag" accesskey="+">タグ付け(+)</button><br/>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment