Advertisement
Guest User

Untitled

a guest
Dec 9th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.13 KB | None | 0 0
  1. ///////1 задача аудиториски 8
  2. <!doctype html>
  3. <html lang="en">
  4. <head>
  5. <meta charset="utf-8">
  6. <title>jQuery UI Dialog - Default functionality</title>
  7. <link rel="stylesheet" href="jquery/jquery-ui.css">
  8. <script src="jquery/jquery.js"></script>
  9. <script src="jquery/jquery-ui.js"></script>
  10. <script>
  11. $(document).ready(function(){
  12. $( ".selectable" ).selectable();
  13.  
  14. $('#add').click(function(){
  15. $('#source').find('.ui-selected').appendTo('#dest').removeClass('ui-selected');
  16. });
  17.  
  18. $('#remove').click(function(){
  19. $('#dest').find('.ui-selected').appendTo('#source').removeClass('ui-selected');
  20. });
  21. });
  22. </script>
  23. <style type="text/css">
  24. li:hover{cursor: pointer;}
  25. #feedback { font-size: 1.4em; }
  26. .selectable .ui-selecting{ background: #FECA40; }
  27. .selectable .ui-selected{ background: #F39814; color: white; }
  28. .selectable{ list-style-type: none; margin: 0; padding: 0; width: 40%; display: inline-block; position: absolute;}
  29. .selectable li{ margin: 3px; padding: 0.4em; font-size: 1.4em; height: 18px; }
  30. #btns{display: inline-block;top: 6px; position: absolute; left: 555px;}
  31. #dest{left: 600px;}
  32. input{margin: 5px; font-size: 30px;}
  33. </style>
  34. </head>
  35. <body>
  36.  
  37. <ol id="source" class="selectable">
  38. <li class="ui-widget-content">Item 1</li>
  39. <li class="ui-widget-content">Item 2</li>
  40. <li class="ui-widget-content">Item 3</li>
  41. <li class="ui-widget-content">Item 4</li>
  42. <li class="ui-widget-content">Item 5</li>
  43. <li class="ui-widget-content">Item 6</li>
  44. <li class="ui-widget-content">Item 7</li>
  45. </ol>
  46.  
  47. <div id="btns">
  48. <input type="button" value=">" id="add">
  49. <br/>
  50. <input type="button" value="<" id="remove">
  51. </div>
  52.  
  53. <ol id="dest" class="selectable">
  54. <li class="ui-widget-content">Item 8</li>
  55. </ol>
  56.  
  57. </body>
  58. </html>
  59. ///////////2 задача аудиториски 8
  60. <!doctype html>
  61. <html lang="en">
  62. <head>
  63. <meta charset="utf-8">
  64. <title>jQuery UI Dialog - Default functionality</title>
  65. <link rel="stylesheet" href="jquery/jquery-ui.css">
  66. <script src="jquery/jquery.js"></script>
  67. <script src="jquery/jquery-ui.js"></script>
  68. <script>
  69. $.widget( "custom.catcomplete", $.ui.autocomplete, {
  70. _create: function() {
  71. this._super();
  72. this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
  73. },
  74. _renderMenu: function( ul, items ) {
  75. var that = this,
  76. currentCategory = "";
  77. $.each( items, function( index, item ) {
  78. var li;
  79. if ( item.category != currentCategory ) {
  80. ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" );
  81. currentCategory = item.category;
  82. }
  83. li = that._renderItemData( ul, item );
  84. if ( item.category ) {
  85. li.attr( "aria-label", item.category + " : " + item.label );
  86. }
  87. });
  88. }
  89. });
  90.  
  91. $(function() {
  92. var data = [
  93. { label: "anders", category: "" },
  94. { label: "andreas", category: "" },
  95. { label: "antal", category: "" },
  96. { label: "annhhx10", category: "Products" },
  97. { label: "annk K12", category: "Products" },
  98. { label: "annttop C13", category: "Products" },
  99. { label: "anders andersson", category: "People" },
  100. { label: "andreas andersson", category: "People" },
  101. { label: "andreas johnson", category: "People" }
  102. ];
  103.  
  104. $( "#search" ).catcomplete({
  105. delay: 0,
  106. source: data
  107. });
  108. });
  109. </script>
  110. <style type="text/css">
  111. .ui-autocomplete-category {
  112. font-weight: bold;
  113. padding: .2em .4em;
  114. margin: .8em 0 .2em;
  115. line-height: 1.5;
  116. }
  117. </style>
  118. </head>
  119. <body>
  120.  
  121. <label for="search">Search: </label>
  122. <input id="search">
  123.  
  124.  
  125. </body>
  126. </html>
  127. ////////////////3 задача аудиториски 8
  128. <!doctype html>
  129. <html lang="en">
  130. <head>
  131. <meta charset="utf-8">
  132. <title>jQuery UI Dialog - Default functionality</title>
  133. <link rel="stylesheet" href="jquery/jquery-ui.css">
  134. <script src="jquery/jquery.js"></script>
  135. <script src="jquery/jquery-ui.js"></script>
  136. <script>
  137. $(function() {
  138. $( "#progressbar" ).progressbar({
  139. value: 0
  140. });
  141.  
  142. progressbarValue = $( "#progressbar" ).find( ".ui-progressbar-value" );
  143.  
  144. progressbarValue.css({
  145. "background": 'red'
  146. });
  147.  
  148. $('input[type=password').keydown(function(){
  149. var score = calculateStrength($(this).val());
  150.  
  151. if(score == 1) {
  152. progressbarValue.css({
  153. "background": 'red'
  154. });
  155. } else if(score == 2) {
  156. progressbarValue.css({
  157. "background": 'yellow'
  158. });
  159. } else if(score == 3) {
  160. progressbarValue.css({
  161. "background": 'green'
  162. });
  163. }
  164.  
  165. $( "#progressbar" ).progressbar({
  166. value: score * 33
  167. });
  168. });
  169. });
  170.  
  171. function calculateStrength(password){
  172. var result = 0;
  173. result += /[a-zA-Z]+/.test(password) ? 1 : 0;
  174. result += /[0-9]+/.test(password) ? 1 : 0;
  175. var specialChars = "<>@!#$%^&*()_+[]{}?:;|'\"\\,./~`-="
  176. var check = function(string){
  177. for(i = 0; i < specialChars.length;i++){
  178. if(string.indexOf(specialChars[i]) > -1){
  179. return true
  180. }
  181. }
  182. return false;
  183. }
  184.  
  185. result += check(password) ? 1 : 0;
  186. console.log(result);
  187. return result;
  188. }
  189.  
  190. </script>
  191. <style type="text/css">
  192. label{
  193. display: inline-block;
  194. width: 150px;
  195. margin: 5px;
  196. }
  197. input{
  198. width: 200px;
  199. margin: 5px;
  200. }
  201.  
  202. #progressbar{
  203. display: inline-block;
  204. width: 200px;
  205. height: 10px;
  206. }
  207. </style>
  208. </head>
  209. <body>
  210.  
  211. <form>
  212. <legend>Sample info:</legend>
  213. <label>Enter password:</label>
  214. <input type="password" id="first-name" placeholder="letters, digits and special signs"/>
  215. <div id="progressbar"></div>
  216. </form>
  217.  
  218.  
  219. </body>
  220. </html>
  221. /////////////////// 4 задача 8 ауд
  222. <!doctype html>
  223. <html lang="en">
  224. <head>
  225. <meta charset="utf-8">
  226. <title>jQuery UI Dialog - Default functionality</title>
  227. <link rel="stylesheet" href="jquery/jquery-ui.css">
  228. <script src="jquery/jquery.js"></script>
  229. <script src="jquery/jquery-ui.js"></script>
  230. <style type="text/css">
  231. label{
  232. display: inline-block;
  233. width: 100px;
  234. margin: 5px;
  235. }
  236. input{
  237. width: 200px;
  238. margin: 5px;
  239. }
  240. </style>
  241. </head>
  242. <body>
  243.  
  244. <form>
  245. <legend>Sample info:</legend>
  246. <label>First name:</label>
  247. <input type="text" id="first-name" placeholder="Enter first name here"/>
  248. <br/>
  249. <label>Last name:</label>
  250. <input type="text" id="first-name" placeholder="Enter last name here"/>
  251. </form>
  252.  
  253.  
  254. </body>
  255. </html>
  256. ///////////////// 5 задача 8 ауд
  257. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  258. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  259.  
  260. <head>
  261. <meta http-equiv="Content-type" content="text/html; charset=utf-8">
  262. <title>Sample</title>
  263. <style type="text/css">
  264. form{
  265. width: 30%;
  266. }
  267.  
  268. input{
  269. margin: 5px;
  270. }
  271.  
  272. label{
  273. display: inline-block;
  274. width: 100px;
  275. }
  276.  
  277. span{
  278. color: red;
  279. display: none;
  280. }
  281.  
  282. button{
  283. margin-top: 5px;
  284. float: left;
  285. }
  286.  
  287. #slider{
  288. height: 20px;
  289. width: 250px;
  290. border: 1px solid black;
  291. margin: 10px;
  292. float: left;
  293. margin-top: 5px;
  294. margin-left: 12px;
  295. }
  296.  
  297. #slider div{
  298. width: 0%;
  299. height: 20px;
  300. background: lightblue;
  301. }
  302.  
  303. </style>
  304. </head>
  305.  
  306. <body>
  307. <h3>Movie streaming site!</h3>
  308. <form>
  309. <!-- General info -->
  310. <fieldset id="general">
  311. <legend>General info:</legend>
  312. <label>Username: </label> <input type="text"> <span>*</span> <br>
  313. <label>Email: </label> <input type="text"> <span>*</span> <br>
  314. <label>Password: </label> <input type="password"> <span>*</span> <br>
  315. <label>Confirm: </label> <input type="password"> <span>*</span>
  316. </fieldset>
  317. <!-- Personal info -->
  318. <fieldset id="personal">
  319. <legend>Personal info: </legend>
  320. <label>First name: </label> <input type="text"><br>
  321. <label>Last name: </label> <input type="text"><br>
  322. <label>Date of birth: </label> <input type="date"> <span>*</span> <br>
  323. <label>Gender: </label> <input type="radio" name="gender" value="male"/>male
  324. <input type="radio" id="gender" name="gender" value="female"/>female
  325. </fieldset>
  326. <!-- Movie category info -->
  327. <fieldset id="movie">
  328. <legend>Movie category info:</legend>
  329. <input type="checkbox" name="category" value="Action"> Action <br>
  330. <input type="checkbox" name="category" value="Animation"> Animation <br>
  331. <input type="checkbox" name="category" value="Comedy"> Comedy <br>
  332. <input type="checkbox" name="category" value="Crime"> Crime <br>
  333. <input type="checkbox" name="category" value="Drama"> Drama <br>
  334. <input type="checkbox" name="category" value="Fantasy"> Fantasy <br>
  335. <input type="checkbox" name="category" value="Musical"> Musical <br>
  336. <input type="checkbox" name="category" value="Romance"> Romance <br>
  337. <input type="checkbox" name="category" value="Horror"> Horror <br>
  338. <input type="checkbox" name="category" value="Sci-Fi"> Sci-Fi <br>
  339. <input type="checkbox" name="category" value="Thriller">Thriller <br>
  340. </fieldset>
  341. <button>Register</button> <div id="slider"><div id="value"></div></div>
  342. </form>
  343. <script type="text/javascript" src="jquery/jquery.js"></script>
  344. <script type="text/javascript">
  345. $(document).ready(function(){
  346.  
  347. $('button').click(function(){
  348. updateProgress();
  349.  
  350. if(validate()){
  351. alert("You have been registered");
  352. return true;
  353. }else{
  354. alert("You have not filled mandatory fields");
  355. return false;
  356. }
  357. });
  358.  
  359. });
  360.  
  361. function validate(){
  362. var valid = true;
  363.  
  364. $('#general input, input[type=date]').each(function(index, item){
  365. if( $(item).val().trim() == "" ){
  366. $(item).next().show();
  367. valid = false;
  368. } else {
  369. $(item).next().hide();
  370. }
  371. });
  372.  
  373. var $p1 = $('input[type=password]:nth-child(1)');
  374. var $p2 = $('input[type=password]:nth-child(2)');
  375.  
  376. valid = valid && ($p1.val() != "" && $p1.val() == $p2.val());
  377.  
  378. return valid;
  379. }
  380.  
  381. function updateProgress(){
  382. var num = 0;
  383. $('input[type=text], input[type=password], input[type=date]').each(function(index, item){
  384. if($(item).val().trim() != "")
  385. num += 1;
  386. });
  387. var num2 = $('#personal input:checked').length;
  388. var num3 = $('#movie input:checked').length > 0 ? 1 : 0;
  389.  
  390. var percent = 0;
  391.  
  392. if( (num + num2 + num3) > 0 )
  393. percent = ( num + num2 + num3) / 9 * 100;
  394.  
  395. console.log(num + " " + num2 + " " + num3 + " " + percent);
  396.  
  397. $('#slider div').css('width', percent + "%");
  398. }
  399.  
  400. </script>
  401. </body>
  402.  
  403. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement