View
Theme
Font Style
7pt
8pt
9pt
10pt
11pt
Line Style
100%
110%
120%
130%
140%
Bold Keyword
Default
Inspector
Kkaefer
Eclipse
SQ Light
Lesser
Dark
Cobalt
Monokai
Rubyblue
Night
SQ Dark
Ambiance
Blackboard
Line Num.
Wrap Lines
Preview
Redraw
JS Tab
HTML Tab
CSS Tab
Live Tab
Prev. Tab
Next Tab
Browser
History…
Help
Edit
Settings
Auto Complete
Match Brackets
Match Highlight
Strip Whitespace
Auto Close Brackets
Auto Close Quotes
Show Print Margin
Undo
Redo
Delete
Select Line
Select All
Find & Replace
Find
Find in Repo.
Find Next
Find Previous
Replace Single
Replace All
Wrap Search
Revert
As Template
Diff Revision
Format
Compress
Text
Zen Coding
Indent
Tab Width
1
2
3
4
5
6
7
8
Indent Unit
1
2
3
4
5
6
7
8
Smart Indent
Use Tabs
Visible Tabs
Shift Left
Shift Right
Put Indent
Number
Increment by 1
Decrement by 1
Increment by 0.1
Decrement by 0.1
Increment by 10
Decrement by 10
Simple Math
Comment
Line
Move Up
Move Down
Copy Up
Copy Down
Go to Line…
Remove Line
Next Point
Prev. Point
Help
Share
Login
You can jump to the latest bin by adding
/latest
to your URL
×
z
Find
→
←
⟲
Replace
⊗
All
Replace
var ua = navigator.userAgent; var wrong = 0; var op = ['+', '-', '*']; var op_id = 0; var n1; var n2; var answer; var score = 0; var hi_score = 0; function draw_canvas() { var drawingCanvas = document.getElementById('hang-math'); if (drawingCanvas.getContext) { var ctx = drawingCanvas.getContext('2d'); ctx.clearRect(0, 0, 600, 400); ctx.beginPath(); ctx.strokeStyle = "#865028"; ctx.lineWidth = 30; ctx.moveTo(150, 0); ctx.lineTo(150, 400); ctx.moveTo(150, 200); ctx.lineTo(300, 400); ctx.moveTo(150, 200); ctx.lineTo(300, 0); ctx.moveTo(150, 10); ctx.lineTo(450, 10); ctx.stroke(); ctx.beginPath(); ctx.lineWidth = 10; ctx.moveTo(450, 0); ctx.lineTo(450, 80); ctx.stroke(); ctx.strokeStyle = "#a17355"; ctx.lineWidth = 10; if (wrong >= 1) { ctx.beginPath(); ctx.arc(450, 80, 15, 0, Math.PI * 2, true); ctx.fillStyle = '#edd6c8'; ctx.fill(); ctx.stroke() } if (wrong >= 2) { ctx.beginPath(); ctx.moveTo(450, 90); ctx.lineTo(450, 160); ctx.stroke() } if (wrong >= 3) { ctx.beginPath(); ctx.moveTo(450, 120); ctx.lineTo(410, 100); ctx.stroke() } if (wrong >= 4) { ctx.beginPath(); ctx.moveTo(450, 120); ctx.lineTo(490, 100); ctx.stroke() } if (wrong >= 5) { ctx.beginPath(); ctx.moveTo(450, 155); ctx.lineTo(410, 200); ctx.stroke() } if (wrong >= 6) { ctx.beginPath(); ctx.moveTo(450, 155); ctx.lineTo(490, 200); ctx.stroke() } if (wrong >= 7) { ctx.beginPath(); ctx.moveTo(450, 180); ctx.lineTo(450, 190); ctx.stroke() } } } $(document).ready(function () { if (ua.match(/Firefox/i) != null) { $(".d").addClass("hack"); } var rand_no = Math.floor(3 * Math.random()); genEq(); draw_canvas(); $("#menu div").click(function (e) { $("#menu").css("display", "none"); $("#game").css("display", "block"); $("#error").css("display", "block"); addKeyCheck(); addAgain() }) }); function addAgain() { $("#again").click(function (e) { score = 0; wrong = 0; draw_canvas(); $("#again").css("display", "none"); $("#question").css("display", "block"); $("#error").html(""); $("#score").html(score) }) } function addKeyCheck() { $(this).keydown(function (e) { $("#error").html(""); var n = $("#answer").html(); var k = e.keyCode; if (k == 8) { $("#answer").html(n.substring(0, n.length - 1)); e.preventDefault() } else if (k == 13) { if (isNaN(n) || n == "") { $("#error").html("Invalid input") } else { var b = checkAnswer(n); if (!b) { wrong++; if (wrong > 6) { $("#question").css("display", "none"); $("#again").css("display", "block"); $("#error").html("Sorry, answer was " + answer + ". GAME OVER!!!"); if (score > hi_score) { hi_score = score; $("#hi_score").html(hi_score) } } else { $("#error").html("Sorry, answer was " + answer) } draw_canvas() } else { $("#error").html("You're a genius!!!"); score += 100; $("#score").html(score) } $("#answer").html(""); genEq() } } else if (k >= 48 && k <= 57) { $("#answer").html(n + (e.keyCode - 48).toString()) } else if (k == 189 || k == 109) { if (n.length == 0) { $("#answer").html(n + "-") } } }) } function checkAnswer(n) { n = parseInt(n); return (n == answer) } function genEq() { op_id = Math.floor(3 * Math.random()); n1 = Math.floor(50 * Math.random()); n2 = Math.floor(50 * Math.random()); switch (op_id) { case 0: answer = n1 + n2; break; case 1: answer = n1 - n2; break; case 2: answer = n1 * n2; break } $("#q").html(n1 + " " + op[op_id] + " " + n2 + " = ") }
Hang Math
Hang Math
START
1 + 5 =
PLAY AGAIN
body, div, ul, ol, li, h1, h2, h3, p { margin:0; padding:0 } ul { list-style:none } h1, h2, h3 { font-size:100%; font-weight:bold } body { font:14px/23px Helvetica, Sans-serif; color:#FFF; background:#00ABEB } header h1 { color:#FFF; text-transform:uppercase; font-size:50px; line-height:60px; text-align:center; } h1 a { color:#FFF; text-decoration:none } header p { font-size:16px; text-align:center; } header p a { color:#FFF } section, div#menu { width:600px; margin:auto; padding:35px 0px 50px 0px; } aside { position:fixed; top:10px; right:80px; } #again { text-align:center; font-size:36px; margin:-70px 0px 50px 0px; } #game { position:fixed; bottom:100px; height:400px; width:600px; margin:auto; } #menu div { background:#5B2F0F; background:-webkit-gradient(linear, left top, left bottom, from(#865028), to(#5B2F0F)); background:-moz-linear-gradient(top, #865028, #5B2F0F); -webkit-border-radius:8px; -moz-border-radius:8px; border-radius:8px; -webkit-box-shadow:3px 3px 3px #361C09; -moz-box-shadow:3px 3px 3px #361C09; padding:10px; margin:50px auto; text-align:center; font-size:30px; line-height:100px; } #question { text-align:center; font-size:36px; margin:-70px 0px 50px 0px; } #question, #again { background:#5B2F0F; background:-webkit-gradient(linear, left top, left bottom, from(#865028), to(#5B2F0F)); background:-moz-linear-gradient(top, #865028, #5B2F0F); -webkit-border-radius:8px; -moz-border-radius:8px; border-radius:8px; -webkit-box-shadow:3px 3px 3px #361C09; -moz-box-shadow:3px 3px 3px #361C09; text-align:center; } #question #q, #again h2 { line-height:50px; } #error { position:fixed; top:65px; color:#C00; font-size:18px; font-weight:bold; } footer { background:#66CC00; background:-webkit-gradient(linear, left top, left bottom, from(#66CC00), to(#739509)); background:-moz-linear-gradient(top, #94B521, #739509); width:100%; height:100px; bottom:0; left:0; position:fixed; text-align:center; z-index:6 } footer p { margin-top:30px } footer a { color:#FFF } .hack { position:relative; left: 50%; }
Pop out
Help
About
×
×