Changeset 1665

Show
Ignore:
Timestamp:
11/16/07 19:03:18 (6 years ago)
Author:
jknaoya
Message:

lang/javascript/naoscheme/index.html,
lang/javascript/naoscheme/naoscheme.js:

あんまり綺麗じゃないけどログ機能をつけました><

Location:
lang/javascript/naoscheme
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/naoscheme/index.html

    r1663 r1665  
    1616                (alert e) 
    1717                (call document.body "appendChild" (call document "createTextNode" "こんにちは!")) 
     18                (add-event-listener (call document "getElementById" "top") 
     19                                    "click" 
     20                                    (lambda (e) 
     21                                        (alert (list (prop e "clientX") (prop e "clientY"))))) 
    1822            ) false) 
     23 
    1924        </script> 
    2025        <script src="naoscheme.js" type="text/javascript"></script> 
    2126    </head> 
    2227    <body> 
    23         >_&lt; 
     28        <h1 id="top">>_&lt;</h1> 
     29        <table> 
     30            <thead> 
     31                <th>Log</th> 
     32            </thead> 
     33            <tbody> 
     34            </tbody> 
     35        </table> 
    2436    </body> 
    2537</html> 
  • lang/javascript/naoscheme/naoscheme.js

    r1653 r1665  
    11 
    2 function log (s) { 
     2function log (s) { try { 
    33    if (window.console) 
    44        console.log(s); 
    5 } 
     5    var tb = document.getElementsByTagName("tbody")[0]; 
     6    if (tb) { 
     7        var tr = document.createElement("tr"); 
     8        var td = document.createElement("td"); 
     9        td.appendChild(document.createTextNode(String(s))); 
     10        tb.appendChild(td); 
     11    } 
     12} catch (e) {}} 
    613 
    714function NaoScheme () { 
     
    103110    }, 
    104111 
     112    prop : function (obj, key) { 
     113        return obj[key]; 
     114    }, 
     115 
    105116    car : function (list) { 
    106117        return list[0]; 
     
    117128    split : function (sep, list) { 
    118129        return list.split(sep); 
     130    }, 
     131 
     132    list : function (list) { 
     133        return Array.prototype.slice.call(arguments, 0); 
    119134    }, 
    120135