Created
April 2, 2017 06:52
-
-
Save muxueqz/909d94a25233fe2d9150399266d4c28b to your computer and use it in GitHub Desktop.
make luckey dog
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
namelist = ["一", "二", "三", "五", "学生某"] | |
console.log(namelist) | |
random_num = (max, min=0) -> | |
return Math.floor(Math.random() * (max - min ) ) + min | |
make_luckey_dog = -> | |
luckey_dog = (namelist[random_num(namelist.length)]) | |
"#{luckey_dog}<BR>" | |
#alert random_person | |
#document.body.innerHTML = random_person | |
#document.body.append(random_person) | |
#$.ajax | |
# url: "some.html" | |
# dataType: "html" | |
# error: (jqXHR, textStatus, errorThrown) -> | |
# $('body').append "AJAX Error: #{textStatus}" | |
# success: (data, textStatus, jqXHR) -> | |
# $('body').append "Successful AJAX call: #{data}" | |
$(document).ready -> | |
for name in namelist | |
$('div.namelist').append(name) | |
$('div.namelist').append('<BR>') | |
$('#make_random').click -> | |
# alert(random_person) | |
$('body').append(make_luckey_dog()) | |
#$(document).ready -> | |
# $('body').append "test" |
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
<html> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> | |
<head> | |
<script src="./jquery-1.6.4.js"></script> | |
<script type="text/javascript" src="./new_random.js"> </script> | |
</script> | |
<title>In-Browser test</title> | |
</head> | |
<body> | |
<h1 id="header" style="color:white">CoffeeScript is alive!</h1> | |
<div class="namelist"> | |
名单列表: | |
<BR> | |
</div> | |
<button id="make_random" >哪位同学是新的幸运儿呢?</button> | |
<BR> | |
</body> | |
</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
// Generated by CoffeeScript 1.10.0 | |
(function() { | |
var make_luckey_dog, namelist, random_num; | |
namelist = ["一", "二", "三", "五", "学生某"]; | |
console.log(namelist); | |
random_num = function(max, min) { | |
if (min == null) { | |
min = 0; | |
} | |
return Math.floor(Math.random() * (max - min)) + min; | |
}; | |
make_luckey_dog = function() { | |
var luckey_dog; | |
luckey_dog = namelist[random_num(namelist.length)]; | |
return luckey_dog + "<BR>"; | |
}; | |
$(document).ready(function() { | |
var i, len, name; | |
for (i = 0, len = namelist.length; i < len; i++) { | |
name = namelist[i]; | |
$('div.namelist').append(name); | |
$('div.namelist').append('<BR>'); | |
} | |
return $('#make_random').click(function() { | |
return $('body').append(make_luckey_dog()); | |
}); | |
}); | |
}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment