Guest User

Untitled

a guest
May 26th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script type="text/javascript" src="jquery.js"></script>
  5. <script type="text/javascript" src="inheritance.js"></script>
  6. <script type="text/javascript">
  7. var test = {};
  8.  
  9. test.Person = Class.extend({
  10. init: function() {
  11. },
  12. });
  13.  
  14. test.Ninja = test.Person.extend({
  15. init: function() {
  16. this._super();
  17. }
  18. });
  19.  
  20. function debug_mode(namespace) {
  21. for (var i in namespace) {
  22. if (typeof namespace[i] === 'object') {
  23. //handle namespace
  24. debug_mode(namespace[i]);
  25.  
  26. } else if (typeof namespace[i] === 'function') {
  27.  
  28. //handle class constructor
  29. if (i.match(/^[A-Z]/)) {
  30. debug_mode(namespace[i].prototype);
  31. return;
  32. }
  33.  
  34. console.log('function name:' + i);
  35.  
  36. //rewrite real function
  37. var func = namespace[i];
  38. namespace[i] = function() {
  39. console.log('called:' + i);
  40. func();
  41. };
  42.  
  43. }
  44. }
  45. }
  46.  
  47. debug_mode(test);
  48.  
  49. new test.Person();
  50.  
  51. </script>
  52. </head>
  53. <body></body>
  54. </html>
Add Comment
Please, Sign In to add comment