Advertisement
Guest User

Untitled

a guest
May 19th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.06 KB | None | 0 0
  1. <html>
  2. <head>
  3. <style type="text/css">
  4. div {border: 1px solid;}
  5. li {float : left; display : block; }
  6. </style>
  7.  
  8. <ul>
  9. <li>Jeden</li>
  10. <li>Dwa</li>
  11. <li>Trzy</li>
  12. </ul>
  13.  
  14. <p> nienio1</p>
  15. <p> nienio1</p>
  16. <p> nienio1</p>
  17. <p> nienio1</p>
  18. <div style="position: absolute; width: 300px; height: 300px; top: 100px; left: 100px;">
  19. <div style="visibility: none; position: absolute; width: 40px; height: 40px; top: 130px; left: 130px;"></div>
  20. <div style="visibility: none; position: relative; width: 100px; height: 100px; top: 10px; left: 10px; padding:30px; margin: 0px;">
  21. </div></div>
  22.  
  23. <br><br><br><br><br>
  24.  
  25. <p id = "string" style = "font-size : 5em">Zajebisty napis</p>
  26. <p>ext 2</p>
  27. <p>Text 3</p>
  28. <p>Text 4</p>
  29. <p>Text 5</p>
  30. <div>Tekscior</div>
  31.  
  32. <script type = "text/javascript">
  33.  
  34. function Licznik1() {
  35. this.licznik = 0;
  36. this.dajWartosc = function() {
  37. return this.licznik;
  38. }
  39. this.dodaj = function() {
  40. this.licznik += 1;
  41. }
  42. }
  43.  
  44. function Licznik2() {
  45. this.dodaj = function() {
  46. var kopia = this.licznik;
  47. while (kopia > 0) {
  48. if (kopia % 10 == 1)
  49. this.licznik += 1;
  50. kopia = Math.floor(kopia / 10);
  51. }
  52. this.licznik += 1;
  53. }
  54. }
  55.  
  56. Licznik2.prototype = new Licznik1;
  57. licznik1 = new Licznik1;
  58. licznik2 = new Licznik2;
  59.  
  60. var ret = "";
  61. for (i = 0; i < 20; i++) {
  62. ret += licznik1.dajWartosc();
  63. ret += " ";
  64. ret += licznik2.dajWartosc();
  65. ret += "<br />";
  66. licznik1.dodaj();
  67. licznik2.dodaj();
  68. }
  69. document.write(ret);
  70.  
  71. function forEach(tablica, action) {
  72. for (var i = 0; i < tablica.length; i++) {
  73. action(tablica[i]);
  74. }
  75. }
  76.  
  77. var a = new Array("a", "b", "c");
  78. forEach(a, function(number) {
  79. document.write(number);
  80. });
  81.  
  82. forEach([1, 2, 3, 4, 5, 6], function(number) {
  83. document.write(number);
  84. });
  85.  
  86. document.write("<br/>" + Math.min.apply(this, [5, 6]));
  87.  
  88. function Person(name, surname, age) {
  89. this.ID = 1;
  90. this.name = name;
  91. this.surname = surname;
  92. this.age = age;
  93. this.getName = function() {
  94. return this.name;
  95. }
  96. this.getSurname = function() {
  97. return this.surname;
  98. }
  99. this.getAge = function() {
  100. return this.age;
  101. }
  102. this.saySomething = function(whatToSay) {
  103. document.write(whatToSay);
  104. }
  105. };
  106.  
  107. function Worker(position) {
  108. this.position = position;
  109. this.getPosition = function() {
  110. return this.position;
  111. }
  112. };
  113.  
  114. Worker.prototype = new Person("Name", "Surname", null);
  115. Person.prototype.surname = "Unknow";
  116.  
  117. document.write("<br/>Placek<br/>");
  118. var obiekt = new Person("John", "Smith", 90);
  119. var obiekt1 = new Worker("programmer");
  120. document.write(Array(obiekt1.getSurname(), obiekt1.getPosition()).join(" -!@!- ") + "<br/>");
  121.  
  122. document.write(obiekt.getName());
  123. document.write("<br>" + obiekt.constructor);
  124.  
  125. function malarz(tag, color) {
  126. return {
  127. maluj: function(i, j) {
  128. tags = document.getElementsByTagName(tag);
  129. for (var index = i; index <= j && index < tags.length; index++) {
  130. tags[index].style.color = color;
  131. //alert(tags[index].innerHTML);
  132. }
  133. },
  134. changeBackground: function(i, j) {
  135. tags = document.getElementsByTagName(tag);
  136. for (var index = i; index <= j && index < tags.length; index++) {
  137. tags[index].style.backgroundColor = color;
  138. tags[index].style.width = "10em";
  139. //tabs[index].style.fontWeight = "bold";
  140. //alert(tags[index].innerHTML);
  141. }
  142. }
  143. }
  144. }
  145.  
  146. var Samochod = function(model) {
  147. var that = this;
  148. that.model = model;
  149. that.kolor = "bialy";
  150.  
  151. that.jakiModel = function() {
  152. return "to " + that.model;
  153. }
  154.  
  155. that.przemalujNa = function(kolor) {
  156. this.kolor = kolor;
  157. }
  158. }
  159. var garbus = new Samochod("Volkswagen");
  160. alert(garbus.jakiModel()); // "to Volksagen"
  161. garbus.przemalujNa("czerwony");
  162. alert(garbus.kolor); //"bialy"
  163.  
  164.  
  165. var a = malarz("p", "green");
  166. a.maluj(0, 3);
  167. var b = malarz("p", "blue");
  168. b.changeBackground(0, 0);
  169. var c = malarz("p", "purple");
  170. c.maluj(4, 4);
  171.  
  172. /*
  173. // wikipedia
  174. site = { purpose : 'information' , storage : 'web' }
  175. Wikipedia = function() {
  176. this.complexity = 'vast'
  177. this.usefulness = 'notable'
  178. }
  179. Wikipedia.prototype = site
  180. Wikipedia.prototype.software = 'MediaWiki'
  181. alert((new Wikipedia).storage) // wyświetli: web
  182. alert((new Wikipedia).software) // wyświetli: MediaWiki
  183.  
  184. function makeFunc() {
  185. var name = "Mozilla" ;
  186. function displayName () {
  187. alert(name) ;
  188. }
  189. return displayName ;
  190. }
  191.  
  192. var myFunc = makeFunc();
  193. myFunc();
  194.  
  195. var Counter = (function() {
  196. var privateCounter = 0;
  197. function changeBy(val) {
  198. privateCounter += val;
  199. }
  200. return {
  201. increment: function() { changeBy(1); },
  202. decrement: function() { changeBy(-1); },
  203. value: function() { return privateCounter; }
  204. }
  205. })();
  206. Counter.increment(); alert(Counter.value());
  207.  
  208. function Employee () {
  209. this.name = "plum" ;
  210. alert("new Employee");
  211. }
  212. function WorkerBee ( ) {
  213. alert("new WorkerBee");
  214. }
  215.  
  216. WorkerBee.prototype = new Employee;
  217. amy = new WorkerBee;
  218. alert(amy.name)
  219. Employee.prototype.name = "Unknown"
  220. alert(amy.name)
  221. */
  222. </script>
  223. </head>
  224. <body>
  225. </body>
  226. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement