Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. var ppElement=function(str_elmt){
  2. this.tagName=str_elmt;
  3. return this.ppCreate();
  4. };
  5. ppElement.prototype={
  6. constructor:ppElement,
  7. ppCreate:function(){
  8. return document.createElement(this.tagName);
  9. },
  10. ppAppend:function(){
  11. var prntObj=arguments[0];
  12. for(var i=1;i<arguments.length;i++){
  13. prntObj.appendChild(arguments[i]);
  14. }
  15. },
  16. ppSetStyle:function(){
  17. var prntObj=arguments[0];
  18. prntObj.style.cssText=arguments[1];
  19. },
  20. ppWrapper:function(){
  21. var wrapper_Obj=ppElement.call(this,"div");
  22. var child_Obj=[];
  23. child_Obj[0]=wrapper_Obj;
  24. for(var i=0,j=1;i<arguments.length;i++,j++){
  25. child_Obj[j]=arguments[i];
  26. }
  27. this.ppAppend.apply(this,child_Obj);
  28. return wrapper_Obj;
  29. }
  30. };
  31.  
  32. var ppTable=function(row_int,coloumn_int){
  33. this.row=row_int;
  34. this.coloumn=coloumn_int;
  35. return this.ppCreateTable();
  36. };
  37. ppTable.prototype=Object.create(ppElement.prototype,{
  38. constructor:ppTable,
  39. ppCreateTable:{
  40. value:function(){
  41. var tableObj=ppElement.call(this,"div");
  42. for(var i=0;i<this.row;i++){
  43. var tableRowObj=ppElement.call(this,"div");
  44. for(var j=0;j<this.coloumn;j++){
  45. var tableColumnObj=ppElement.call(this,"div");
  46. this.ppAppend(tableRowObj,tableColumnObj);
  47. }
  48. this.ppAppend(tableObj,tableRowObj);
  49. }
  50. return tableObj;
  51. }
  52. },
  53. tableCell:{
  54. value:function(){
  55. alert("hi");
  56. }
  57. }
  58. });
  59.  
  60. var testTable=new ppTable(2,2);
  61. testTable.tableCell();
  62. document.getElementsByTagName('body')[0].appendChild(testTable);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement