Advertisement
Guest User

Untitled

a guest
Dec 1st, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.29 KB | None | 0 0
  1. function Kutu() {
  2. this.genislik = 50;
  3. this.yukseklik = 50;
  4. this.id = '';
  5. this.arkaplan = 'red';
  6. this.yazi = '';
  7. this.yaziBoyutu = 40;
  8. this.yaziRengi = '';
  9. this.x = 0;
  10. this.y = 0;
  11. this.ciz = function () {
  12. var div = document.getElementById(this.id);
  13.  
  14. if (div) {
  15. div.id = this.id;
  16. div.style.width = this.genislik + 'px';
  17. div.style.height = this.yukseklik + 'px';
  18. div.style.position = 'absolute';
  19. div.style.top = this.y + 'px';
  20. div.style.left = this.x + 'px';
  21. div.style.fontSize = this.yaziBoyutu + 'px';
  22. div.style.textAlign = 'center';
  23. div.style.backgroundColor = this.arkaplan;
  24. div.style.color = this.yaziRengi;
  25. div.innerText = this.yazi;
  26. div.value = this.deger;
  27. div.onclick = this.islem;
  28.  
  29. } else {
  30. div = document.createElement('div');
  31. div.id = this.id;
  32. div.style.width = this.genislik + 'px';
  33. div.style.height = this.yukseklik + 'px';
  34. div.style.position = 'absolute';
  35. div.style.top = this.y + 'px';
  36. div.style.textAlign = 'center';
  37. div.style.left = this.x + 'px';
  38. div.style.fontSize = this.yaziBoyutu + 'px';
  39. div.style.backgroundColor = this.arkaplan;
  40. div.style.color = this.yaziRengi;
  41. div.innerText = this.yazi;
  42. div.onclick = this.islem;
  43. //div.addEventListener('click', function() {
  44.  
  45. // islem();
  46. //});
  47.  
  48. document.body.appendChild(div);
  49. }
  50.  
  51. }
  52.  
  53. this.sil = function () {
  54. var element = document.getElementById(this.id);
  55. element.parentNode.removeChild(element);
  56. }
  57.  
  58. this.tiklanamazYap = function () {
  59. var element = document.getElementById(this.id);
  60. element.onclick = null;
  61. }
  62.  
  63. this.yaziGizle = function () {
  64. var element = document.getElementById(this.id);
  65. element.innerText = '';
  66. }
  67. this.yaziGoster = function () {
  68. var element = document.getElementById(this.id);
  69. element.innerText = this.deger;
  70. }
  71. this.islem;
  72.  
  73. }
  74.  
  75. function TextKutusu() {
  76. this.genislik = 100;
  77. this.yukseklik = 50;
  78. this.id = '';
  79. var _deger = '';
  80. this.deger = function(arg) {
  81.  
  82. var element = document.getElementById(this.id);
  83.  
  84. if (arg) {
  85. _deger = arg;
  86.  
  87. if (element) {
  88. element.value = arg;
  89. }
  90. }
  91.  
  92. if (element) {
  93. _deger = element.value;
  94. }
  95.  
  96. return _deger;
  97. };
  98. this.yazi = '';
  99. this.x;
  100. this.y;
  101. this.islem;
  102. this.ciz = function () {
  103. var txtbox = document.createElement('textarea');
  104. txtbox.style.height = this.genislik;
  105. txtbox.style.width = this.yukseklik;
  106. txtbox.style.position = 'absolute';
  107. txtbox.id = this.id;
  108. txtbox.value = this.deger();
  109. txtbox.style.top = this.y+'px';
  110. txtbox.style.left = this.x+'px';
  111. txtbox.innerText = this.yazi;
  112. txtbox.onchange = this.islem;
  113. document.body.appendChild(txtbox);
  114.  
  115. }
  116. }
  117. function Buton() {
  118. this.genislik = 80;
  119. this.yukseklik = 30;
  120. this.id = '';
  121. this.yazi = '';
  122. this.x;
  123. this.y;
  124. this.islem;
  125. this.ciz = function() {
  126. var btn = document.createElement('button');
  127. btntext = document.createTextNode(this.yazi);
  128. btn.style.width = this.genislik+'px';
  129. btn.style.height = this.yukseklik + 'px';
  130. btn.style.position = 'absolute';
  131. btn.text = this.yazi;
  132. btn.style.top = this.y+'px';
  133. btn.style.left = this.x+'px';
  134. btn.onclick = this.islem;
  135. btn.appendChild(btntext);
  136. document.body.appendChild(btn);
  137. }
  138. }
  139.  
  140. var araclar = {
  141. islemBagla: function(func, args) {
  142.  
  143. return function() { func(args); };
  144. },
  145. sayiyaDonustur: function(deger){
  146. return parseInt(deger);
  147. },
  148. yaziyaDonustur: function(deger){
  149. return deger.toString();
  150. },
  151. sayfayiYenile: function() {
  152. location.reload();
  153. },
  154. rasgeleSayiUret: function(altDeger,ustDeger){
  155. return Math.ceil((Math.random() * (ustDeger-altDeger)) + altDeger);
  156. },
  157. objeBul: function(id) {
  158. var element = document.getElementById(id);
  159. if (element.tagName == 'div') {
  160. var kutu = new Kutu();
  161. kutu.id = element.id;
  162. kutu.genislik = element.style.width;
  163. kutu.yukseklik = element.style.height;
  164. kutu.x = element.style.left;
  165. kutu.y = element.style.top;
  166. kutu.arkaplan = element.style.backgroundColor;
  167. kutu.yazi = element.innerText;
  168. kutu.yaziBoyutu = element.style.fontSize;
  169. kutu.yaziRengi = element.style.color;
  170. return kutu;
  171. }
  172. else if (element.tagName =='textarea') {
  173. var txt = new TextKutusu();
  174. txt.id = element.id;
  175. txt.deger = element.value;
  176. txt.genislik = element.style.width;
  177. txt.yukseklik = element.style.height;
  178. txt.yazi = element.innerText;
  179. txt.x = element.style.left;
  180. txt.y = element.style.top;
  181. return txt;
  182. }
  183. else if (element.tagName == 'button') {
  184. var btn = new Buton();
  185. btn.id = element.id;
  186. btn.genislik = element.style.width;
  187. btn.yukseklik = element.style.height;
  188. btn.yazi = element.innerText;
  189. btn.x = element.style.left;
  190. btn.y = element.style.top;
  191. return btn;
  192. }
  193. },
  194. zamaniGetir: function() {
  195. var zaman = new Date();
  196. var tamSaat = zaman.getHours() + ':' + zaman.getMinutes() + ':' + zaman.getSeconds();
  197. return tamSaat;
  198. },
  199. saatGetir: function() {
  200. var zaman = new Date();
  201. return zaman.getHours();
  202. },
  203. dakikaGetir: function() {
  204. var zaman = new Date();
  205. return zaman.getMinutes();
  206. },
  207. saniyeGetir: function() {
  208. var zaman = new Date();
  209. return zaman.getSeconds();
  210. }
  211. }
  212.  
  213. var renkler = {
  214. siyah: 'black',
  215. beyaz: 'white',
  216. kirmizi: 'red',
  217. mavi: 'blue',
  218. sari: 'yellow',
  219. kahverengi: 'brown',
  220. yesil: 'green',
  221. gri: 'grey',
  222. turuncu: 'orange',
  223. mor: 'purple'
  224.  
  225. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement