()
| 544 | }; |
| 545 | |
| 546 | function bindDebugger() { |
| 547 | var output = $("debugger-output"); |
| 548 | |
| 549 | function trace(msg) { |
| 550 | if (typeof msg === "object") { |
| 551 | var obj = {}; |
| 552 | for (var field in msg) { |
| 553 | if (typeof msg[field] !== "function") { |
| 554 | obj[field] = msg[field].toString(); |
| 555 | } else { |
| 556 | obj[field] = "[function Function]"; |
| 557 | } |
| 558 | } |
| 559 | msg = JSON.stringify(obj, undefined, 2); |
| 560 | } else if (msg === undefined) { |
| 561 | msg = "[undefined]"; |
| 562 | } else if (typeof msg !== "string") { |
| 563 | msg = msg.toString(); |
| 564 | } |
| 565 | var lines = msg.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/ /g, " ").split("\n"); |
| 566 | output.innerHTML = lines.join("<br>") + "<br>" + output.innerHTML; |
| 567 | }; |
| 568 | window.trace = trace; |
| 569 | $("debugger-input-area").addEventListener("keydown", function(e) { |
| 570 | if (e.keyCode == 9) e.preventDefault() |
| 571 | }); |
| 572 | $("debugger-input-area").addEventListener("keyup", function(e) { |
| 573 | if (e.keyCode == 9) { |
| 574 | e.preventDefault(); |
| 575 | this.innerHTML += "\t"; |
| 576 | } |
| 577 | }); |
| 578 | $("debugger-run").addEventListener("click", function() { |
| 579 | try { |
| 580 | var cm = window.cm; |
| 581 | eval($("debugger-input-area").innerText); |
| 582 | } catch (e) { |
| 583 | trace(e); |
| 584 | console.log(e); |
| 585 | } |
| 586 | }); |
| 587 | for (var x in debugs) { |
| 588 | $(x).addEventListener('click', function() { |
| 589 | $("debugger-input-area").innerHTML = debugs[this.id]; |
| 590 | }); |
| 591 | } |
| 592 | }; |
| 593 | |
| 594 | function bindVideo(video, cm) { |
| 595 | video.addEventListener("timeupdate", function() { |
no test coverage detected