Commit 2337df64 authored by 神楽坂玲奈's avatar 神楽坂玲奈

deck *****er ?

parent a8061481
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js" type="text/javascript"></script>
<script src="https://raw.github.com/allmarkedup/jQuery-URL-Parser/master/purl.js"></script>
<script type="text/javascript">
function decode(str){
var key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789*-="
var result = 0
for(var i in str){
result <<= 6
result += key.indexOf(str.charAt(i))
}
return result
}
$(document).ready(function(){
$('#name').html($.url().param('name'))
var cards_encoded = $.url().param('cards')
for(var i=0; i<cards_encoded.length; i+=5){
var decoded = decode(cards_encoded.substr(i, 5))
var side = decoded >> 29
var count = decoded >> 27 & 0x3
var id = decoded & 0x07FFFFFF
$('#cards').append($('<dt />', {text: id}))
$('#cards').append($('<dd />', {text: count}))
}
})
</script>
</head>
<body>
<div id="name"></div>
<dl id="cards"></dl>
</body>
</html>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
<html>
<head>
<meta charset="utf-8" />
<title>mycard</title>
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script>
function parse(fileinput){
var file = fileinput.files[0]
var result = './?name=' + encodeURIComponent(file.name) + '&cards='
if(file){
var reader = new FileReader()
reader.readAsText(file)
reader.onload = function(evt){
var lines = evt.target.result.split("\n")
var side = false
var last_id = 0
var count = 0
for(var i in lines){
var line = lines[i]
if(line.charAt(0) == '#'){
continue
}else if(line.substr(0,5) == '!side'){
if(last_id){
result += encode(last_id | (side << 29) | (count << 27))
}
side = true
}else{
var id = parseInt(line)
if(id){ //!=0
if(id == last_id){
count++
}else{
if(last_id){
result += encode(last_id | (side << 29) | (count << 27))
}
last_id = id
count = 1
}
}
}
}
location.href = result
}
}
}
function encode(number){
var key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789*-="
var result = ''
for(i=0;i<5;i++){
result = key.charAt(number & 0x3F) + result
number >>= 6
}
return result
}
function decode(str){
var key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789*-="
var result = 0
for(var i in str){
result <<= 6
result += key.indexOf(str.charAt(i))
}
return result
}
</script>
</head>
<body>
<form>
<input type="file" onchange="parse(this);"/>
</form>
</body>
</html>
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment