Advertisement
Aiaa

edit

Apr 25th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 59.80 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5. <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  6. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  7. <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  8. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  9. <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
  10. <script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
  11. <script>
  12. $(function() {
  13. $( "#taskDate" ).datepicker();
  14. });
  15. </script>
  16. <style>
  17. div.ui.page #myTable tr td div.hoverDes{display: none;}
  18. div.ui.page #myTable tr:hover td div.hoverDes{display: inline-block;}
  19. /*
  20. h4:hover {
  21. display: inline;
  22.  
  23. }*/
  24. .ui-datepicker {
  25. background: white;
  26. /*border: 1px solid #555;*/
  27. color: black;
  28. }
  29. /* The Modal (background) */
  30.  
  31. .modal {
  32. display: none;
  33. /* Hidden by default */
  34. position: fixed;
  35. /* Stay in place */
  36. z-index: 1;
  37. /* Sit on top */
  38. padding-top: 100px;
  39. /* Location of the box */
  40. left: 0;
  41. top: 0;
  42. width: 100%;
  43. /* Full width */
  44. height: 100%;
  45. /* Full height */
  46. overflow: auto;
  47. /* Enable scroll if needed */
  48. background-color: rgb(0, 0, 0);
  49. /* Fallback color */
  50. background-color: rgba(0, 0, 0, 0.4);
  51. /* Black w/ opacity */
  52. }
  53. /* Modal Content */
  54.  
  55. .modal-content {
  56. background-color: #fefefe;
  57. margin: auto;
  58. padding: 20px;
  59. border: 1px solid #888;
  60. width: 80%;
  61. }
  62. /* The Close Button */
  63.  
  64. .close {
  65. color: #aaaaaa;
  66. float: right;
  67. font-size: 28px;
  68. font-weight: bold;
  69. }
  70.  
  71. .close:hover,
  72. .close:focus {
  73. color: #000;
  74. text-decoration: none;
  75. cursor: pointer;
  76. }
  77.  
  78. .button {
  79. background-color: grey;
  80. /* Green */
  81. border: none;
  82. color: white;
  83. padding: 4px 6px;
  84. text-align: center;
  85. text-decoration: none;
  86. display: inline-block;
  87. font-size: 16px;
  88. margin: 4px 2px;
  89. -webkit-transition-duration: 0.4s;
  90. /* Safari */
  91. transition-duration: 0.4s;
  92. cursor: pointer;
  93. }
  94.  
  95. .button1 {
  96. background-color: #e7e7e7;
  97. color: black;
  98. }
  99.  
  100. .button1:hover {
  101. background-color: #555555;
  102. }
  103.  
  104. .nav-side-menu {
  105. overflow: auto;
  106. font-family: verdana;
  107. font-size: 12px;
  108. font-weight: 200;
  109. background-color: #2e353d;
  110. position: fixed;
  111. top: 40px;
  112. width: 18%;
  113. height: 100%;
  114. color: #e1ffff;
  115. }
  116.  
  117. .myButton {
  118. background-color: #2e353d;
  119. border: none;
  120. color: white;
  121. padding: 15px 35%;
  122. text-align: center;
  123. text-decoration: none;
  124. display: inline-block;
  125. font-size: 14px;
  126. margin: 15px 4px;
  127. cursor: pointer;
  128. top: 50%;
  129. }
  130.  
  131. .myButton2 {
  132. background-color: lawngreen;
  133. border: none;
  134. color: black;
  135. padding: 15px 35%;
  136. text-align: center;
  137. text-decoration: none;
  138. display: inline-block;
  139. font-size: 14px;
  140. margin: 15px 4px;
  141. cursor: pointer;
  142. top: 50%;
  143. }
  144. .myButton2:hover {
  145. background-color: darkred;
  146. color: white;
  147. }
  148. /*#butAdd {*/
  149. /*width: XXpx;
  150. height: YYpx;*/
  151. /*position: absolute;*/
  152. /*top: Y&#37;;*/
  153. /*left: 20%;*/
  154. /*}*/
  155.  
  156.  
  157. /*#presenter{*/
  158. /*font-family: verdana;*/
  159. /*font-size: 12px;*/
  160. /*font-weight: 200;*/
  161. /*background-color: lightgrey;*/
  162. /*position: fixed;*/
  163. /*top: 40px;*/
  164. /*width: 80%;*/
  165. /*height: 10%;*/
  166. /*color: #e1ffff;*/
  167.  
  168. /*}*/
  169.  
  170.  
  171. </style>
  172. </head>
  173.  
  174.  
  175.  
  176.  
  177. <body>
  178.  
  179.  
  180.  
  181. <div class="nav-side-menu">
  182. <button class="myButton" id="butAll" onclick="drawTable1(allTasks,1); boldedAll(); deSelect();" ></button><br>
  183. <button class="myButton" id="butPro" onclick="drawTable2(inProgressTasks,2); boldedProg(); deSelect();"></button><br>
  184. <button class="myButton" id="butcom" onclick="drawTable3(finishedTasks,3); boldedFin(); deSelect();" ></button><br>
  185. <button class="myButton" id="butArc" onclick="drawTable4(archivedTasks,4); boldedArch(); deSelect(); " ></button><br>
  186. <button class="myButton" id="butArc" onclick="drawTable4(archivedTasks,4); boldedArch(); deSelect();" ></button><br>
  187.  
  188. <button class="myButton2" id="butAdd" ><span class="glyphicon glyphicon-plus"></span>Add Task</button>
  189. <button class="myButton2" onclick = "DeleteMultipleRows()" id="butremoveall" >Remove All Tasks</button>
  190.  
  191.  
  192. </div>
  193.  
  194.  
  195. <!-- Trigger/Open The Modal -->
  196. <!-- The Modal -->
  197. <div id="myModal" class="modal">
  198. <!-- Modal content -->
  199. <div class="modal-content">
  200. <span class="close">x</span>
  201. <br> Add Task:<br>
  202. <input type="text" id="addTask" size="50">
  203. <br> Date:<br>
  204. <input type="text" id="taskDate" size="20">
  205. <br>Description<br>
  206. <input type="text" id="description" size="70">
  207. <br><br>
  208. <button type="button" class="button button1" onclick="assignVals(); drawTable1(allTasks,1); ">Add Task!</button>
  209. <button type="button" class="button button3" onclick="cancelBut(); ">Cancel input</button>
  210.  
  211. </div>
  212. </div>
  213. <div id="myModal2" class="modal">
  214. <!-- Modal content -->
  215. <div class="modal-content">
  216. <span class="close">x</span>
  217. <br> Add Task:<br>
  218. <input type="text" id="addTask" size="50">
  219. <br> Date:<br>
  220. <input type="text" id="taskDate" size="20">
  221. <br>Description<br>
  222. <input type="text" id="description" size="70">
  223. <br><br>
  224. <button type="button" id="editConf" class="button button1" onclick="assignVals(); drawTable1(allTasks,1); ">Edit Task</button>
  225. <button type="button" class="button button3" onclick="cancelBut(); ">Cancel input</button>
  226.  
  227. </div>
  228. </div>
  229.  
  230. <br><br><br>
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237. <div id="presenter" align="center" style="width: 100%; height: 50px; background-color: lightgrey; font-size: 30px; font-weight: bold; ">
  238.  
  239. <p id="present"></p>
  240.  
  241.  
  242. </div>
  243.  
  244.  
  245.  
  246.  
  247.  
  248. <div id="page" class="page">
  249.  
  250. <header class="item header margin-top-0 padding-bottom-0" id="header5">
  251.  
  252. <div class="wrapper">
  253.  
  254.  
  255. <nav role="navigation" class="navbar navbar-inverse navbar-embossed navbar-lg navbar-fixed-top">
  256.  
  257. <div class="container">
  258.  
  259. <div class="navbar-header">
  260.  
  261. <a class="navbar-brand brand">TO DO '19</a>
  262. </div>
  263.  
  264.  
  265. </div>
  266. <!-- /.container -->
  267.  
  268. </nav>
  269. <h1 >
  270.  
  271.  
  272. <table align="right" width="80%" >
  273. <td>
  274. <ui>
  275. </ui>
  276. </td>
  277. <td>
  278. <p id="myTable" />
  279. </td>
  280. </table>
  281. <br><br><br>
  282.  
  283.  
  284.  
  285.  
  286. </div>
  287. <!-- /.wrapper -->
  288. </header>
  289. <!-- /.item -->
  290. </div>
  291. <!-- /#page -->
  292.  
  293.  
  294.  
  295.  
  296.  
  297. <script>
  298.  
  299. function cancelBut(){
  300. document.getElementById("addTask").value="";
  301. document.getElementById("taskDate").value="";
  302. document.getElementById("description").value="";
  303. disappear();
  304. }
  305.  
  306.  
  307.  
  308. function boldedAll(){
  309. document.getElementById("present").innerHTML="All Tasks";
  310.  
  311. }
  312. function boldedProg(){
  313. document.getElementById("present").innerHTML="In progress";
  314.  
  315. }
  316. function boldedFin(){
  317. document.getElementById("present").innerHTML="Finished";
  318.  
  319. }
  320. function boldedArch(){
  321. document.getElementById("present").innerHTML="Archived";
  322.  
  323. }
  324. //MODAL START
  325. // Get the modal
  326. var modal = document.getElementById('myModal');
  327.  
  328. // Get the button that opens the modal
  329. var btn = document.getElementById("butAdd");
  330.  
  331. // Get the <span> element that closes the modal
  332. var span = document.getElementsByClassName("close")[0];
  333.  
  334. // When the user clicks the button, open the modal
  335. btn.onclick = function() {
  336. modal.style.display = "block";
  337. }
  338.  
  339. // When the user clicks on <span> (x), close the modal
  340. span.onclick = function() {
  341. modal.style.display = "none";
  342. }
  343.  
  344. // When the user clicks anywhere outside of the modal, close it
  345. window.onclick = function(event) {
  346. if (event.target == modal) {
  347. modal.style.display = "none";
  348. }
  349. }
  350. function disappear() {
  351. modal.style.display = "none";
  352. }
  353.  
  354. // $('.modal').on('hidden.bs.modal', function(){
  355. // $(this).find('form')[0].reset();
  356. // });
  357. //MODAL END
  358.  
  359.  
  360. var allTasks = [];
  361. var inProgressTasks = [];
  362. var archivedTasks = [];
  363. var finishedTasks = [];
  364. var store=[];
  365.  
  366.  
  367. printButtons();
  368.  
  369.  
  370.  
  371. //object of the input
  372. function inputObj(name,date,description){
  373. this.name=name;
  374. this.date=date;
  375. this.description=description;
  376. }
  377. //inserting in the array of all tasks and in progress by default
  378. function assignVals(){
  379.  
  380. var createObj = new inputObj(document.getElementById("addTask").value,document.getElementById("taskDate").value,document.getElementById("description").value)
  381.  
  382. var here=false;
  383.  
  384.  
  385. for(var i=0;i<allTasks.length&&here==false&&allTasks.length>0;i++){
  386. if(allTasks[i].name==createObj.name
  387. && allTasks[i].date==createObj.date
  388. )
  389. {
  390. here=true;
  391. alert("Task already available")
  392. }
  393.  
  394.  
  395. }
  396.  
  397. var hereA=false;
  398. for(var i=0;i<archivedTasks.length&&hereA==false&&archivedTasks.length>0;i++){
  399. if(archivedTasks[i].name==createObj.name
  400. && archivedTasks[i].date==createObj.date
  401. )
  402. {
  403. hereA=true;
  404. alert("Task is already archived")
  405. }
  406.  
  407.  
  408. }
  409.  
  410. if(document.getElementById("addTask").value==""||document.getElementById("taskDate").value==""){
  411. alert("Name or date panel or both are empty");
  412. }else if(document.getElementById("addTask").value.trim()==""||document.getElementById("taskDate").value.trim()==""){
  413. alert("Name or date panel or both are empty");
  414. }
  415. else if(here==false&&hereA==false){
  416. allTasks.push(createObj);
  417. inProgressTasks.push(createObj);
  418. disappear();
  419. cancelBut();
  420.  
  421.  
  422. }
  423.  
  424. printButtons();
  425. }
  426.  
  427.  
  428.  
  429.  
  430. //delete fx
  431. function deleteTask (index){
  432.  
  433.  
  434. var workOnArray=[] ;
  435.  
  436. for(var j=0;j<store.length;j++){
  437.  
  438. var obj = new inputObj(store[j].name,store[j].date,store[j].description);
  439. workOnArray.push(obj);
  440. }
  441.  
  442.  
  443.  
  444. if (confirm("Are you Sure that you want to delete?") == true) {
  445.  
  446.  
  447. var here1=false;
  448. var itIsHere;
  449. for(var i=0;i<allTasks.length&&here1==false&&allTasks.length>0;i++){
  450.  
  451. if(allTasks[i].name==workOnArray[index-1].name
  452. && allTasks[i].date==workOnArray[index-1].date
  453. && allTasks[i].description==workOnArray[index-1].description )
  454. {
  455. here1=true;
  456. itIsHere=i;
  457.  
  458. }
  459.  
  460. }
  461.  
  462.  
  463. if(here1==true){
  464. allTasks.splice(itIsHere,1);
  465. drawTable1(allTasks,1);
  466.  
  467. var flag=false;
  468. for(var i=0;i<inProgressTasks.length && flag==false;i++){
  469. if (inProgressTasks[i].name==workOnArray[index-1].name
  470. && inProgressTasks[i].date==workOnArray[index-1].date
  471. && inProgressTasks[i].description==workOnArray[index-1].description){
  472.  
  473. flag=true;
  474. inProgressTasks.splice(i,1);
  475.  
  476. }
  477.  
  478. }
  479.  
  480.  
  481.  
  482. for(var i=0;i<finishedTasks.length && flag==false;i++){
  483. if (finishedTasks[i].name==workOnArray[index-1].name
  484. && finishedTasks[i].date==workOnArray[index-1].date
  485. && finishedTasks[i].description==workOnArray[index-1].description){
  486. flag=true;
  487. finished.splice(i,1);
  488.  
  489. }
  490.  
  491. }
  492.  
  493.  
  494.  
  495. }else if (archivedTasks.length>=index && archivedTasks[index-1].name==workOnArray[index-1].name
  496. && archivedTasks[index-1].date==workOnArray[index-1].date
  497. && archivedTasks[index-1].description==workOnArray[index-1].description){
  498.  
  499. archivedTasks.splice(index-1,1);
  500. drawTable4(archivedTasks,4);
  501.  
  502.  
  503. }
  504.  
  505.  
  506.  
  507. }
  508. printButtons();
  509.  
  510. }
  511. function markAsDone(index){
  512. editBool = true ;
  513. var index2 = index-1;
  514. if(myKey==1){
  515. searchFini(index);
  516.  
  517. drawTable1(allTasks,1);
  518. }
  519. else{
  520. if(myKey==2){
  521. var createObj = new inputObj (inProgressTasks[index2].name,inProgressTasks[index2].date,inProgressTasks[index2].description);
  522. delete2(index);
  523.  
  524.  
  525. if(true){
  526.  
  527. finishedTasks.push(createObj);
  528. drawTable2(inProgressTasks,2);
  529.  
  530. }
  531.  
  532. printButtons();
  533.  
  534. }
  535. else if(myKey==4){
  536. var createObj = new inputObj (archivedTasks[index2].name,archivedTasks[index2].date,archivedTasks[index2].description);
  537.  
  538. delete4(index);
  539.  
  540.  
  541. if(true){
  542.  
  543. finishedTasks.push(createObj);
  544. drawTable4(archivedTasks);
  545.  
  546. }
  547.  
  548. printButtons();
  549. }
  550.  
  551.  
  552.  
  553. }
  554.  
  555. }
  556.  
  557.  
  558. function archiving(index){
  559. editBool = true ;
  560. var index2 = index-1;
  561. if(myKey==1){
  562. search2(index);
  563. drawTable1(allTasks,1);
  564. }else{
  565. if(myKey==2){
  566. var createObj = new inputObj (inProgressTasks[index2].name,inProgressTasks[index2].date,inProgressTasks[index2].description);
  567. delete2(index);
  568.  
  569. if(true){
  570.  
  571. archivedTasks.push(createObj);
  572.  
  573. }
  574.  
  575. printButtons();
  576. drawTable2(inProgressTasks,2);
  577. }
  578. else if(myKey==3){
  579. var createObj = new inputObj (archivedTasks[index2].name,archivedTasks[index2].date,archivedTasks[index2].description);
  580.  
  581. delete3(index);
  582.  
  583.  
  584. if(true){
  585.  
  586. archivedTasks.push(createObj);
  587.  
  588. }
  589.  
  590. printButtons();
  591. drawTable3(finishedTasks,3);
  592. }
  593.  
  594.  
  595. }
  596. editBool = false;
  597. }
  598. var editBool = false ;
  599.  
  600.  
  601. function deleteTask (index){
  602. if(editBool == true){
  603. var index2 = index - 1 ;
  604. if(myKey==1){
  605. var here1=false;
  606. var itIsHere1;
  607. var current = new inputObj (allTasks[index2].name,allTasks[index2].date,allTasks[index2].description);
  608. for(var i=0;i<allTasks.length&&here1==false&&allTasks.length>0;i++){
  609.  
  610. if(allTasks[i].name==current.name
  611. && allTasks[i].date==current.date
  612. && allTasks[i].description==current.description )
  613. {
  614.  
  615. here1=true;
  616. itIsHere1=i;
  617.  
  618. }
  619.  
  620. }
  621. if(here1==true){
  622. allTasks.splice(itIsHere1,1);
  623. var here2=false;
  624. var itIsHere2;
  625. for(var i=0;i<inProgressTasks.length&&here2==false&&inProgressTasks.length>0;i++){
  626.  
  627. if(inProgressTasks[i].name==current.name
  628. && inProgressTasks[i].date==current.date
  629. && inProgressTasks[i].description==current.description )
  630. {
  631.  
  632. here2=true;
  633. itIsHere2=i;
  634.  
  635. }
  636.  
  637. }
  638.  
  639. if(here2==true){
  640. inProgressTasks.splice(itIsHere2,1);
  641. }
  642. var here3=false;
  643. var itIsHere3;
  644. for(var i=0;i<finishedTasks.length&&here3==false&&finishedTasks.length>0;i++){
  645.  
  646. if(finishedTasks[i].name==current.name
  647. && finishedTasks[i].date==current.date
  648. && finishedTasks[i].description==current.description )
  649. {
  650.  
  651. here3=true;
  652. itIsHere3=i;
  653.  
  654. }
  655.  
  656. }
  657. if(here3==true){
  658. finishedTasks.splice(itIsHere3,1);
  659.  
  660. }
  661. var here4=false;
  662. var itIsHere4;
  663. for(var i=0;i<archivedTasks.length&&here4==false&&archivedTasks.length>0;i++){
  664.  
  665. if(archivedTasks[i].name==current.name
  666. && archivedTasks[i].date==current.date
  667. && archivedTasks[i].description==current.description )
  668. {
  669.  
  670. here4=true;
  671. itIsHere4=i;
  672.  
  673. }
  674.  
  675. }
  676. if(here4==true){
  677. archivedTasks.splice(itIsHere4,1);
  678.  
  679. }
  680.  
  681.  
  682.  
  683. }
  684.  
  685.  
  686.  
  687.  
  688. }
  689. else{
  690.  
  691. if (myKey ==2){
  692. var current = new inputObj (inProgressTasks[index2].name,inProgressTasks[index2].date,inProgressTasks[index2].description);
  693. var here2=false;
  694. var itIsHere2;
  695. for(var i=0;i<inProgressTasks.length&&here2==false&&inProgressTasks.length>0;i++){
  696.  
  697. if(inProgressTasks[i].name==current.name
  698. && inProgressTasks[i].date==current.date
  699. && inProgressTasks[i].description==current.description )
  700. {
  701.  
  702. here2=true;
  703. itIsHere2=i;
  704.  
  705. }
  706.  
  707. }
  708. if(here2==true){
  709. inProgressTasks.splice(itIsHere2,1);
  710. var here1=false;
  711. var itIsHere1;
  712. for(var i=0;i<allTasks.length&&here1==false&&allTasks.length>0;i++){
  713.  
  714. if(allTasks[i].name==current.name
  715. && allTasks[i].date==current.date
  716. && allTasks[i].description==current.description )
  717. {
  718.  
  719. here1=true;
  720. itIsHere1=i;
  721.  
  722. }
  723.  
  724. }
  725. if(here1==true){
  726. allTasks.splice(itIsHere1,1);
  727. }
  728. }
  729. }
  730. else if (myKey ==3){
  731. var current = new inputObj (finishedTasks[index2].name,finishedTasks[index2].date,finishedTasks[index2].description);
  732. var here3=false;
  733. var itIsHere3;
  734. for(var i=0;i<finishedTasks.length&&here3==false&&finishedTasks.length>0;i++){
  735.  
  736. if(finishedTasks[i].name==current.name
  737. && finishedTasks[i].date==current.date
  738. && finishedTasks[i].description==current.description )
  739. {
  740.  
  741. here3=true;
  742. itIsHere3=i;
  743.  
  744. }
  745.  
  746. }
  747. if(here3==true){
  748. finishedTasks.splice(itIsHere3,1);
  749. var here1=false;
  750. var itIsHere1;
  751. for(var i=0;i<allTasks.length&&here1==false&&allTasks.length>0;i++){
  752.  
  753. if(allTasks[i].name==current.name
  754. && allTasks[i].date==current.date
  755. && allTasks[i].description==current.description )
  756. {
  757.  
  758. here1=true;
  759. itIsHere1=i;
  760.  
  761. }
  762.  
  763. } if(here1==true){
  764. allTasks.splice(itIsHere1,1);}
  765.  
  766. }
  767. }
  768. else if (myKey ==4){
  769. var current = new inputObj (archivedTasks[index2].name,archivedTasks[index2].date,archivedTasks[index2].description);
  770. var here4=false;
  771. var itIsHere4;
  772. for(var i=0;i<archivedTasks.length&&here4==false&&archivedTasks.length>0;i++){
  773.  
  774. if(archivedTasks[i].name==current.name
  775. && archivedTasks[i].date==current.date
  776. && archivedTasks[i].description==current.description )
  777. {
  778.  
  779. here4=true;
  780. itIsHere4=i;
  781.  
  782. }
  783.  
  784. }
  785. if(here4==true){
  786. archivedTasks.splice(itIsHere4,1);
  787. var here1=false;
  788. var itIsHere1;
  789. for(var i=0;i<allTasks.length&&here1==false&&allTasks.length>0;i++){
  790.  
  791. if(allTasks[i].name==current.name
  792. && allTasks[i].date==current.date
  793. && allTasks[i].description==current.description )
  794. {
  795.  
  796. here1=true;
  797. itIsHere1=i;
  798.  
  799. }
  800.  
  801. }
  802. if(here1==true){
  803. allTasks.splice(itIsHere1,1);}
  804.  
  805. }
  806. }
  807.  
  808. }
  809.  
  810. }
  811. else{
  812. if (confirm("Are you Sure that you want to delete?") == true) {
  813. var index2 = index - 1 ;
  814. if(myKey==1){
  815. var here1=false;
  816. var itIsHere1;
  817. var current = new inputObj (allTasks[index2].name,allTasks[index2].date,allTasks[index2].description);
  818. for(var i=0;i<allTasks.length&&here1==false&&allTasks.length>0;i++){
  819.  
  820. if(allTasks[i].name==current.name
  821. && allTasks[i].date==current.date
  822. && allTasks[i].description==current.description )
  823. {
  824.  
  825. here1=true;
  826. itIsHere1=i;
  827.  
  828. }
  829.  
  830. }
  831. if(here1==true){
  832. allTasks.splice(itIsHere1,1);
  833. var here2=false;
  834. var itIsHere2;
  835. for(var i=0;i<inProgressTasks.length&&here2==false&&inProgressTasks.length>0;i++){
  836.  
  837. if(inProgressTasks[i].name==current.name
  838. && inProgressTasks[i].date==current.date
  839. && inProgressTasks[i].description==current.description )
  840. {
  841.  
  842. here2=true;
  843. itIsHere2=i;
  844.  
  845. }
  846.  
  847. }
  848.  
  849. if(here2==true){
  850. inProgressTasks.splice(itIsHere2,1);
  851. }
  852. var here3=false;
  853. var itIsHere3;
  854. for(var i=0;i<finishedTasks.length&&here3==false&&finishedTasks.length>0;i++){
  855.  
  856. if(finishedTasks[i].name==current.name
  857. && finishedTasks[i].date==current.date
  858. && finishedTasks[i].description==current.description )
  859. {
  860.  
  861. here3=true;
  862. itIsHere3=i;
  863.  
  864. }
  865.  
  866. }
  867. if(here3==true){
  868. finishedTasks.splice(itIsHere3,1);
  869.  
  870. }
  871. var here4=false;
  872. var itIsHere4;
  873. for(var i=0;i<archivedTasks.length&&here4==false&&archivedTasks.length>0;i++){
  874.  
  875. if(archivedTasks[i].name==current.name
  876. && archivedTasks[i].date==current.date
  877. && archivedTasks[i].description==current.description )
  878. {
  879.  
  880. here4=true;
  881. itIsHere4=i;
  882.  
  883. }
  884.  
  885. }
  886. if(here4==true){
  887. archivedTasks.splice(itIsHere4,1);
  888.  
  889. }
  890.  
  891.  
  892.  
  893. }
  894.  
  895.  
  896.  
  897.  
  898. }
  899. else{
  900.  
  901. if (myKey ==2){
  902. var current = new inputObj (inProgressTasks[index2].name,inProgressTasks[index2].date,inProgressTasks[index2].description);
  903. var here2=false;
  904. var itIsHere2;
  905. for(var i=0;i<inProgressTasks.length&&here2==false&&inProgressTasks.length>0;i++){
  906.  
  907. if(inProgressTasks[i].name==current.name
  908. && inProgressTasks[i].date==current.date
  909. && inProgressTasks[i].description==current.description )
  910. {
  911.  
  912. here2=true;
  913. itIsHere2=i;
  914.  
  915. }
  916.  
  917. }
  918. if(here2==true){
  919. inProgressTasks.splice(itIsHere2,1);
  920. var here1=false;
  921. var itIsHere1;
  922. for(var i=0;i<allTasks.length&&here1==false&&allTasks.length>0;i++){
  923.  
  924. if(allTasks[i].name==current.name
  925. && allTasks[i].date==current.date
  926. && allTasks[i].description==current.description )
  927. {
  928.  
  929. here1=true;
  930. itIsHere1=i;
  931.  
  932. }
  933.  
  934. }
  935. if(here1==true){
  936. allTasks.splice(itIsHere1,1);
  937. }
  938. }
  939. }
  940. else if (myKey ==3){
  941. var current = new inputObj (finishedTasks[index2].name,finishedTasks[index2].date,finishedTasks[index2].description);
  942. var here3=false;
  943. var itIsHere3;
  944. for(var i=0;i<finishedTasks.length&&here3==false&&finishedTasks.length>0;i++){
  945.  
  946. if(finishedTasks[i].name==current.name
  947. && finishedTasks[i].date==current.date
  948. && finishedTasks[i].description==current.description )
  949. {
  950.  
  951. here3=true;
  952. itIsHere3=i;
  953.  
  954. }
  955.  
  956. }
  957. if(here3==true){
  958. finishedTasks.splice(itIsHere3,1);
  959. var here1=false;
  960. var itIsHere1;
  961. for(var i=0;i<allTasks.length&&here1==false&&allTasks.length>0;i++){
  962.  
  963. if(allTasks[i].name==current.name
  964. && allTasks[i].date==current.date
  965. && allTasks[i].description==current.description )
  966. {
  967.  
  968. here1=true;
  969. itIsHere1=i;
  970.  
  971. }
  972.  
  973. } if(here1==true){
  974. allTasks.splice(itIsHere1,1);}
  975.  
  976. }
  977. }
  978. else if (myKey ==4){
  979. var current = new inputObj (archivedTasks[index2].name,archivedTasks[index2].date,archivedTasks[index2].description);
  980. var here4=false;
  981. var itIsHere4;
  982. for(var i=0;i<archivedTasks.length&&here4==false&&archivedTasks.length>0;i++){
  983.  
  984. if(archivedTasks[i].name==current.name
  985. && archivedTasks[i].date==current.date
  986. && archivedTasks[i].description==current.description )
  987. {
  988.  
  989. here4=true;
  990. itIsHere4=i;
  991.  
  992. }
  993.  
  994. }
  995. if(here4==true){
  996. archivedTasks.splice(itIsHere4,1);
  997. var here1=false;
  998. var itIsHere1;
  999. for(var i=0;i<allTasks.length&&here1==false&&allTasks.length>0;i++){
  1000.  
  1001. if(allTasks[i].name==current.name
  1002. && allTasks[i].date==current.date
  1003. && allTasks[i].description==current.description )
  1004. {
  1005.  
  1006. here1=true;
  1007. itIsHere1=i;
  1008.  
  1009. }
  1010.  
  1011. }
  1012. if(here1==true){
  1013. allTasks.splice(itIsHere1,1);}
  1014.  
  1015. }
  1016.  
  1017. }
  1018. }
  1019. }
  1020. }
  1021. }
  1022.  
  1023. function deleteAndPrint(index,num) {
  1024. deleteTask(index);
  1025. if(myKey==1){
  1026. drawTable1(allTasks,myKey);
  1027. }
  1028. else if (myKey ==2){
  1029. drawTable2(inProgressTasks,myKey);
  1030. }
  1031. else if(myKey == 3){
  1032. drawTable3(finishedTasks,myKey);
  1033. }
  1034. else{
  1035. drawTable4(archivedTasks,myKey);
  1036. }
  1037. printButtons();
  1038. }
  1039. function searchFini(index) {
  1040.  
  1041. var index2 = index-1;
  1042. var createObj = new inputObj (allTasks[index2].name,allTasks[index2].date,allTasks[index2].description);
  1043.  
  1044.  
  1045. var here2=false;
  1046. var itIsHere2;
  1047. for(var i=0;i<inProgressTasks.length&&here2==false&&inProgressTasks.length>0;i++){
  1048.  
  1049. if(inProgressTasks[i].name==createObj.name
  1050. && inProgressTasks[i].date==createObj.date
  1051. && inProgressTasks[i].description==createObj.description )
  1052. {
  1053.  
  1054. here2=true;
  1055. itIsHere2=i;
  1056.  
  1057. }
  1058.  
  1059. }
  1060.  
  1061. var here4=false;
  1062.  
  1063. for(var i=0;i<archivedTasks.length&&here4==false&&archivedTasks.length>0;i++){
  1064.  
  1065. if(archivedTasks[i].name==createObj.name
  1066. && archivedTasks[i].date==createObj.date
  1067. && archivedTasks[i].description==createObj.description )
  1068. {
  1069.  
  1070. here4=true;
  1071. itIsHere2=i;
  1072.  
  1073. }
  1074.  
  1075. }
  1076. if(here4 == true){
  1077. delete4(itIsHere2+1);
  1078. }
  1079. else if(here2 == true){
  1080. delete2(itIsHere2+1);
  1081. }
  1082.  
  1083.  
  1084.  
  1085.  
  1086. if(true){
  1087.  
  1088. finishedTasks.push(createObj);
  1089.  
  1090. }
  1091.  
  1092. printButtons();
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100. editBool = false ;
  1101. }
  1102. function delete2(index){
  1103. inProgressTasks.splice(index - 1,1);
  1104. }
  1105. function delete3(index){
  1106. finishedTasks.splice(index - 1,1);
  1107. }
  1108. function delete4(index){
  1109. archivedTasks.splice(index - 1,1);
  1110. }
  1111.  
  1112. function search2(index) {
  1113. var index2 = index-1;
  1114. var createObj = new inputObj (allTasks[index2].name,allTasks[index2].date,allTasks[index2].description);
  1115.  
  1116.  
  1117.  
  1118.  
  1119. var here2=false;
  1120. var itIsHere2;
  1121. for(var i=0;i<inProgressTasks.length&&here2==false&&inProgressTasks.length>0;i++){
  1122.  
  1123. if(inProgressTasks[i].name==createObj.name
  1124. && inProgressTasks[i].date==createObj.date
  1125. && inProgressTasks[i].description==createObj.description )
  1126. {
  1127.  
  1128. here2=true;
  1129. itIsHere2=i;
  1130.  
  1131. }
  1132.  
  1133. }
  1134.  
  1135. var here3=false;
  1136.  
  1137. for(var i=0;i<finishedTasks.length&&here3==false&&finishedTasks.length>0;i++){
  1138.  
  1139. if(finishedTasks[i].name==createObj.name
  1140. && finishedTasks[i].date==createObj.date
  1141. && finishedTasks[i].description==createObj.description )
  1142. {
  1143.  
  1144. here3=true;
  1145. itIsHere2=i;
  1146.  
  1147. }
  1148.  
  1149. }
  1150. if(here3 == true){
  1151. delete3(itIsHere2+1);
  1152. }
  1153. else if(here2 == true){
  1154. delete2(itIsHere2+1);
  1155. }
  1156.  
  1157.  
  1158.  
  1159.  
  1160. if(true){
  1161.  
  1162. archivedTasks.push(createObj);
  1163.  
  1164. }
  1165.  
  1166. printButtons();
  1167.  
  1168.  
  1169.  
  1170. }
  1171.  
  1172.  
  1173.  
  1174. var sortN1 = false;
  1175. var sortD1 = false;
  1176. var sortN2 = false;
  1177. var sortD2 = false;
  1178. var sortN3 = false;
  1179. var sortD3 = false;
  1180. var sortN4 = false;
  1181. var sortD4 = false;
  1182.  
  1183.  
  1184. function sortDate(num) {
  1185.  
  1186. if(num==1){
  1187. sortD1 = true ;
  1188. sortN1 = false;
  1189. allTasks.sort(function(a, b){
  1190. var nameA=a.date; var nameB=b.date;
  1191. if (nameA < nameB) //sort string ascending
  1192. return -1 ;
  1193. if (nameA > nameB)
  1194. return 1;
  1195. return 0 ;//default return value (no sorting)
  1196. })
  1197. drawTable1(allTasks,num);
  1198.  
  1199.  
  1200. }else if(num==2){
  1201. sortD2 = true ;
  1202. sortN2 = false;
  1203. inProgressTasks.sort(function(a, b){
  1204. var nameA=a.date; var nameB=b.date;
  1205. if (nameA < nameB) //sort string ascending
  1206. return -1 ;
  1207. if (nameA > nameB)
  1208. return 1;
  1209. return 0 ;//default return value (no sorting)
  1210. })
  1211. drawTable2(inProgressTasks,num);
  1212.  
  1213. }else if(num==3){
  1214. sortD3 = true;
  1215. sortN3 = false;
  1216. finishedTasks.sort(function(a, b){
  1217. var nameA=a.date; var nameB=b.date;
  1218. if (nameA < nameB) //sort string ascending
  1219. return -1 ;
  1220. if (nameA > nameB)
  1221. return 1;
  1222. return 0 ;//default return value (no sorting)
  1223. })
  1224. drawTable3(finishedTasks,num);
  1225. }else if(num==4){
  1226. sortD4 = true;
  1227. sortN4 = false;
  1228. archrivedTasks.sort(function(a, b){
  1229. var nameA=a.date; var nameB=b.date;
  1230. if (nameA < nameB) //sort string ascending
  1231. return -1 ;
  1232. if (nameA > nameB)
  1233. return 1;
  1234. return 0 ;//default return value (no sorting)
  1235. })
  1236. drawTable4(archivedTasks,num);
  1237. }
  1238.  
  1239.  
  1240. }
  1241.  
  1242. function sortName(num) {
  1243.  
  1244. if(num==1){
  1245. sortN1 = true ;
  1246. sortD1 = false ;
  1247. allTasks.sort(function(a, b){
  1248. var nameA=a.name.toLowerCase(); var nameB=b.name.toLowerCase();
  1249. if (nameA < nameB) //sort string ascending
  1250. return -1 ;
  1251. if (nameA > nameB)
  1252. return 1;
  1253. return 0 ;//default return value (no sorting)
  1254. })
  1255. drawTable1(allTasks,num);
  1256.  
  1257.  
  1258. }else if(num==2){
  1259. sortN2 = true ;
  1260. sortD2 = false ;
  1261. inProgressTasks.sort(function(a, b){
  1262. var nameA=a.name.toLowerCase(); var nameB=b.name.toLowerCase();
  1263. if (nameA < nameB) //sort string ascending
  1264. return -1 ;
  1265. if (nameA > nameB)
  1266. return 1;
  1267. return 0 ;//default return value (no sorting)
  1268. })
  1269. drawTable2(inProgressTasks,num);
  1270.  
  1271. }else if(num==3){
  1272. sortN3 = true ;
  1273. sortD3 = false ;
  1274. finishedTasks.sort(function(a, b){
  1275. var nameA=a.name.toLowerCase(); var nameB=b.name.toLowerCase();
  1276. if (nameA < nameB) //sort string ascending
  1277. return -1 ;
  1278. if (nameA > nameB)
  1279. return 1;
  1280. return 0 ;//default return value (no sorting)
  1281. })
  1282. drawTable3(finishedTasks,num);
  1283. }else if(num==4){
  1284. sortN4 = true ;
  1285. sortD4 = false ;
  1286. archrivedTasks.sort(function(a, b){
  1287. var nameA=a.name.toLowerCase(); var nameB=b.name.toLowerCase();
  1288. if (nameA < nameB) //sort string ascending
  1289. return -1 ;
  1290. if (nameA > nameB)
  1291. return 1;
  1292. return 0 ;//default return value (no sorting)
  1293. })
  1294. drawTable4(archivedTasks,num);
  1295. }
  1296.  
  1297.  
  1298. }
  1299. function drawTable3(workOnArray,num){
  1300. if(sortD3== true){
  1301. sortD3 = true ;
  1302. sortN3 = false;
  1303. finishedTasks.sort(function(a, b){
  1304. var nameA=a.date; var nameB=b.date;
  1305. if (nameA < nameB) //sort string ascending
  1306. return -1 ;
  1307. if (nameA > nameB)
  1308. return 1;
  1309. return 0 ;//default return value (no sorting)
  1310. })
  1311. }
  1312. if(sortN3== true){
  1313. sortN3 = true ;
  1314. sortD3 = false ;
  1315. finishedTasks.sort(function(a, b){
  1316. var nameA=a.name.toLowerCase(); var nameB=b.name.toLowerCase();
  1317. if (nameA < nameB) //sort string ascending
  1318. return -1 ;
  1319. if (nameA > nameB)
  1320. return 1;
  1321. return 0 ;//default return value (no sorting)
  1322. })
  1323. }
  1324. for(var j=0;j<workOnArray.length;j++){
  1325.  
  1326. var create = new inputObj(workOnArray[j].name,workOnArray[j].date,workOnArray[j].description);
  1327. store.push(create);
  1328. }
  1329.  
  1330. myKey = num ;
  1331. var text = "<table class=\"table table-hover\" >";
  1332. text += "<th></th>";
  1333. text += "<th>Task Name </th>";
  1334. text += "<th>Date</th>";
  1335. text += "<th>Description</th>";
  1336. text += "<th></th>";
  1337. text += "<th></th>";
  1338. text+="<td></div align=\"right\"><div class=\"dropdown\" align=\"right\"><button class=\"btn btn-primary dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" align=\"right\">Sort<span class=\"caret\" align=\"right\"></span></button><ul class=\"dropdown-menu dropdown-menu-right\" ><li><a onclick=\"sortName(myKey)\">Sort by name</a></li><li><a onclick=\"sortDate(myKey)\">Sort by date</a></li></ul></div></td>";
  1339.  
  1340. for(var i = 0; i< workOnArray.length; i++){
  1341.  
  1342.  
  1343. text += "<tr>";
  1344. text += "<td></td>";
  1345.  
  1346. text += "<td>"+workOnArray[i].name + "</td>";
  1347.  
  1348.  
  1349. text += "<td>"+workOnArray[i].date + "</td>";
  1350. text += "<td>"+workOnArray[i].description + "</td>";
  1351. text += "<td><h4 style display=\"none\" >"+workOnArray[i].description + "</h4></td>";
  1352. text += "<td><input type=\"checkbox\" onclick='selecting(this,this.parentNode.parentNode)' id=\"myCheck\ ></td>";
  1353. text += "<td><div class=\"container\"><div class=\"dropdown\"><button class=\"btn btn-default dropdown-toggle\"type=\"button\" data-toggle=\"dropdown\">Options<span class=\"caret\"></span></button><ul class=\"dropdown-menu \"><li><a onclick=\"archiving(this.parentNode.parentNode.parentNode.parentNode.parentNode.rowIndex)\">Archive</a></li><li><a type=\"button\" data-toggle=\"modal\" data-target=\"#myModal2\" onclick=\"edit(this.parentNode.parentNode.parentNode.parentNode.parentNode.rowIndex)\" id=\"butEdit\" >Edit</a></li><li><a onclick=\"deleteAndPrint(this.parentNode.parentNode.parentNode.parentNode.parentNode.rowIndex,myKey)\">Delete</a></li></ul></div></div></td>";
  1354.  
  1355.  
  1356. text += "</tr>"; }
  1357.  
  1358. text+= "</table>";
  1359. document.getElementById("myTable").innerHTML = text;
  1360. printButtons();
  1361. }
  1362. function drawTable4(workOnArray,num){
  1363. if(sortD4== true){
  1364. sortD4 = true ;
  1365. sortN4 = false;
  1366. archivedTasks.sort(function(a, b){
  1367. var nameA=a.date; var nameB=b.date;
  1368. if (nameA < nameB) //sort string ascending
  1369. return -1 ;
  1370. if (nameA > nameB)
  1371. return 1;
  1372. return 0 ;//default return value (no sorting)
  1373. })
  1374. }
  1375. if(sortN4== true){
  1376. sortN4 = true ;
  1377. sortD4 = false ;
  1378. archivedTasks.sort(function(a, b){
  1379. var nameA=a.name.toLowerCase(); var nameB=b.name.toLowerCase();
  1380. if (nameA < nameB) //sort string ascending
  1381. return -1 ;
  1382. if (nameA > nameB)
  1383. return 1;
  1384. return 0 ;//default return value (no sorting)
  1385. })
  1386. }
  1387.  
  1388. for(var j=0;j<workOnArray.length;j++){
  1389.  
  1390. var create = new inputObj(workOnArray[j].name,workOnArray[j].date,workOnArray[j].description);
  1391. store.push(create);
  1392. }
  1393.  
  1394. myKey = num ;
  1395. var text = "<table class=\"table table-hover\" >";
  1396. text += "<th></th>";
  1397. text += "<th>Task Name </th>";
  1398. text += "<th>Date</th>";
  1399. text += "<th>Description</th>";
  1400. text += "<th></th>";
  1401. text += "<th></th>";
  1402. text+="<td></div align=\"right\"><div class=\"dropdown\" align=\"right\"><button class=\"btn btn-primary dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" align=\"right\">Sort<span class=\"caret\" align=\"right\"></span></button><ul class=\"dropdown-menu dropdown-menu-right\" ><li><a onclick=\"sortName(myKey)\">Sort by name</a></li><li><a onclick=\"sortDate(myKey)\">Sort by date</a></li></ul></div></td>";
  1403.  
  1404. for(var i = 0; i< workOnArray.length; i++){
  1405.  
  1406.  
  1407. text += "<tr>";
  1408. text += "<td></td>";
  1409. if(myKey==3){
  1410.  
  1411. text += "<td><strike>"+workOnArray[i].name + "</strike></td>";
  1412.  
  1413.  
  1414.  
  1415. }else{
  1416. text += "<td>"+workOnArray[i].name + "</td>";
  1417.  
  1418. }
  1419. text += "<td>"+workOnArray[i].date + "</td>";
  1420. text += "<td>"+workOnArray[i].description + "</td>";
  1421. text += "<td><h4 style display=\"none\" >"+workOnArray[i].description + "</h4></td>";
  1422. text += "<td><input type=\"checkbox\" onclick='selecting(this,this.parentNode.parentNode)' id=\"myCheck\ ></td>";
  1423. text += "<td><div class=\"container\"><div class=\"dropdown\"><button class=\"btn btn-default dropdown-toggle\"type=\"button\" data-toggle=\"dropdown\">Options<span class=\"caret\"></span></button><ul class=\"dropdown-menu \"><li><a type=\"button\" data-toggle=\"modal\" data-target=\"#myModal2\" onclick=\"edit(this.parentNode.parentNode.parentNode.parentNode.parentNode.rowIndex)\" id=\"butEdit\" >Edit</a></li><li><a onclick=\"deleteAndPrint(this.parentNode.parentNode.parentNode.parentNode.parentNode.rowIndex,myKey)\">Delete</a></li><li><a onclick=\"markAsDone(this.parentNode.parentNode.parentNode.parentNode.parentNode.rowIndex)\">Mark as done</a></li></ul></div></div></td>";
  1424.  
  1425. text += "</tr>"; }
  1426.  
  1427. text+= "</table>";
  1428. document.getElementById("myTable").innerHTML = text;
  1429. printButtons();
  1430. }
  1431.  
  1432. function drawTable2(workOnArray,num){
  1433. if(sortD2== true){
  1434. sortD2 = true ;
  1435. sortN2 = false;
  1436. inProgressTasks.sort(function(a, b){
  1437. var nameA=a.date; var nameB=b.date;
  1438. if (nameA < nameB) //sort string ascending
  1439. return -1 ;
  1440. if (nameA > nameB)
  1441. return 1;
  1442. return 0 ;//default return value (no sorting)
  1443. })
  1444. }
  1445. if(sortN2== true){
  1446. sortN2 = true ;
  1447. sortD2 = false ;
  1448. inProgressTasks.sort(function(a, b){
  1449. var nameA=a.name.toLowerCase(); var nameB=b.name.toLowerCase();
  1450. if (nameA < nameB) //sort string ascending
  1451. return -1 ;
  1452. if (nameA > nameB)
  1453. return 1;
  1454. return 0 ;//default return value (no sorting)
  1455. })
  1456. }
  1457. for(var j=0;j<workOnArray.length;j++){
  1458.  
  1459. var create = new inputObj(workOnArray[j].name,workOnArray[j].date,workOnArray[j].description);
  1460. store.push(create);
  1461. }
  1462.  
  1463. myKey = num ;
  1464. var text = "<table class=\"table table-hover\" >";
  1465. text += "<th></th>";
  1466. text += "<th>Task Name </th>";
  1467. text += "<th>Date</th>";
  1468. text += "<th>Description</th>";
  1469. text += "<th></th>";
  1470. text += "<th></th>";
  1471. text+="<td></div align=\"right\"><div class=\"dropdown\" align=\"right\"><button class=\"btn btn-primary dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" align=\"right\">Sort<span class=\"caret\" align=\"right\"></span></button><ul class=\"dropdown-menu dropdown-menu-right\" ><li><a onclick=\"sortName(myKey)\">Sort by name</a></li><li><a onclick=\"sortDate(myKey)\">Sort by date</a></li></ul></div></td>";
  1472.  
  1473. for(var i = 0; i< workOnArray.length; i++){
  1474.  
  1475.  
  1476. text += "<tr>";
  1477. text += "<td></td>";
  1478. if(myKey==3){
  1479.  
  1480. text += "<td><strike>"+workOnArray[i].name + "</strike></td>";
  1481.  
  1482.  
  1483.  
  1484. }else{
  1485. text += "<td>"+workOnArray[i].name + "</td>";
  1486.  
  1487. }
  1488. text += "<td>"+workOnArray[i].date + "</td>";
  1489. text += "<td>"+workOnArray[i].description + "</td>";
  1490. text += "<td><h4 style display=\"none\" >"+workOnArray[i].description + "</h4></td>";
  1491. text += "<td><input type=\"checkbox\" onclick='selecting(this,this.parentNode.parentNode)' id=\"myCheck\ ></td>";
  1492. text += "<td><div class=\"container\"><div class=\"dropdown\"><button class=\"btn btn-default dropdown-toggle\"type=\"button\" data-toggle=\"dropdown\">Options<span class=\"caret\"></span></button><ul class=\"dropdown-menu \"><li><a onclick=\"archiving(this.parentNode.parentNode.parentNode.parentNode.parentNode.rowIndex)\">Archive</a></li><li><a type=\"button\" data-toggle=\"modal\" data-target=\"#myModal2\" onclick=\"edit(this.parentNode.parentNode.parentNode.parentNode.parentNode.rowIndex)\" id=\"butEdit\" >Edit</a></li><li><a onclick=\"deleteAndPrint(this.parentNode.parentNode.parentNode.parentNode.parentNode.rowIndex,myKey)\">Delete</a></li><li><a onclick=\"markAsDone(this.parentNode.parentNode.parentNode.parentNode.parentNode.rowIndex)\">Mark as done</a></li></ul></div></div></td>";
  1493.  
  1494. text += "</tr>"; }
  1495.  
  1496. text+= "</table>";
  1497. document.getElementById("myTable").innerHTML = text;
  1498. printButtons();
  1499. }
  1500. function drawTable1(workOnArray,num){
  1501. if(sortD1== true){
  1502. sortD1 = true ;
  1503. sortN1 = false;
  1504. allTasks.sort(function(a, b){
  1505. var nameA=a.date; var nameB=b.date;
  1506. if (nameA < nameB) //sort string ascending
  1507. return -1 ;
  1508. if (nameA > nameB)
  1509. return 1;
  1510. return 0 ;//default return value (no sorting)
  1511. })
  1512. }
  1513. if(sortN1== true){
  1514. sortN1 = true ;
  1515. sortD1 = false ;
  1516. allTasks.sort(function(a, b){
  1517. var nameA=a.name.toLowerCase(); var nameB=b.name.toLowerCase();
  1518. if (nameA < nameB) //sort string ascending
  1519. return -1 ;
  1520. if (nameA > nameB)
  1521. return 1;
  1522. return 0 ;//default return value (no sorting)
  1523. })
  1524. }
  1525.  
  1526. for(var j=0;j<workOnArray.length;j++){
  1527.  
  1528. var create = new inputObj(workOnArray[j].name,workOnArray[j].date,workOnArray[j].description);
  1529. store.push(create);
  1530. }
  1531.  
  1532. myKey = num ;
  1533. var text = "<table class=\"table table-hover\" id=\"tablehov\">";
  1534. text += "<th></th>";
  1535. text += "<th>Task Name </th>";
  1536. text += "<th>Date</th>";
  1537. text += "<th>Description</th>";
  1538. text += "<th></th>";
  1539. text += "<th></th>";
  1540. text+="<td></div align=\"right\"><div class=\"dropdown\" align=\"right\"><button class=\"btn btn-primary dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" align=\"right\">Sort<span class=\"caret\" align=\"right\"></span></button><ul class=\"dropdown-menu dropdown-menu-right\" ><li><a onclick=\"sortName(myKey)\">Sort by name</a></li><li><a onclick=\"sortDate(myKey)\">Sort by date</a></li></ul></div></td>";
  1541.  
  1542. for(var i = 0; i< workOnArray.length; i++){
  1543.  
  1544.  
  1545.  
  1546. var hereSr = false;
  1547. for (var ii = 0; ii < finishedTasks.length; ii++) {
  1548. if(workOnArray[i].name == finishedTasks[ii].name
  1549. &&workOnArray[i].date == finishedTasks[ii].date
  1550. &&workOnArray[i].description == finishedTasks[ii].description
  1551. ){text += "<tr>";
  1552. text += "<td></td>";
  1553. text += "<td><strike>"+workOnArray[i].name + "</strike></td>";
  1554. text += "<td><strike>"+workOnArray[i].date + "</strike></td>";
  1555. text += "<td><strike>"+workOnArray[i].description + "</strike></td>";
  1556. text += "<td><div id=\"hoverDes\" >"+workOnArray[i].description + "</div></td>";
  1557.  
  1558.  
  1559. text += "<td><input type=\"checkbox\" onclick='selecting(this,this.parentNode.parentNode)' id=\"myCheck\ ></td>";
  1560. text += "<td><div class=\"container\"><div class=\"dropdown\"><button class=\"btn btn-default dropdown-toggle\"type=\"button\" data-toggle=\"dropdown\">Options<span class=\"caret\"></span></button><ul class=\"dropdown-menu \"><li><a onclick=\"archiving(this.parentNode.parentNode.parentNode.parentNode.parentNode.rowIndex)\">Archive</a></li><li><a type=\"button\" data-toggle=\"modal\" data-target=\"#myModal2\" onclick=\"edit(this.parentNode.parentNode.parentNode.parentNode.parentNode.rowIndex)\" id=\"butEdit\" >Edit</a></li><li><a onclick=\"deleteAndPrint(this.parentNode.parentNode.parentNode.parentNode.parentNode.rowIndex,myKey)\">Delete</a></li></ul></div></div></td>";
  1561. text += "</tr>";
  1562.  
  1563. hereSr = true;
  1564. }
  1565. }
  1566. var hereSr2 = false;
  1567. for (var ii = 0; ii < archivedTasks.length; ii++) {
  1568. if(workOnArray[i].name == archivedTasks[ii].name
  1569. &&workOnArray[i].date == archivedTasks[ii].date
  1570. &&workOnArray[i].description == archivedTasks[ii].description
  1571. ){
  1572.  
  1573. hereSr2 = true;
  1574. }
  1575. }
  1576. if(hereSr== false && hereSr2 == false){
  1577.  
  1578.  
  1579. text += "<tr>";
  1580. text += "<td></td>";
  1581.  
  1582. text += "<td>"+workOnArray[i].name + "</td>";
  1583. text += "<td>"+workOnArray[i].date + "</td>";
  1584. text += "<td>"+workOnArray[i].description + "</td>";
  1585. text += "<td><div id=\"hoverDes\" >"+workOnArray[i].description + "</div></td>";
  1586. text += "<td><input type=\"checkbox\" onclick='selecting(this,this.parentNode.parentNode)' id=\"myCheck\ ></td>";
  1587. text += "<td><div class=\"container\"><div class=\"dropdown\"><button class=\"btn btn-default dropdown-toggle\"type=\"button\" data-toggle=\"dropdown\">Options<span class=\"caret\"></span></button><ul class=\"dropdown-menu \"><li><a onclick=\"archiving(this.parentNode.parentNode.parentNode.parentNode.parentNode.rowIndex)\">Archive</a></li><li><a type=\"button\" data-toggle=\"modal\" data-target=\"#myModal2\" onclick=\"edit(this.parentNode.parentNode.parentNode.parentNode.parentNode.rowIndex)\" id=\"butEdit\" >Edit</a></li><li><a onclick=\"deleteAndPrint(this.parentNode.parentNode.parentNode.parentNode.parentNode.rowIndex,myKey)\">Delete</a></li><li><a onclick=\"markAsDone(this.parentNode.parentNode.parentNode.parentNode.parentNode.rowIndex)\">Mark as done</a></li></ul></div></div></td>";
  1588. text += "</tr>";
  1589. }
  1590. }
  1591.  
  1592. text+= "</table>";
  1593. document.getElementById("myTable").innerHTML = text;
  1594. printButtons();
  1595. }
  1596.  
  1597. function printButtons(){
  1598. var allLength = allTasks.length - archivedTasks.length ;
  1599. document.getElementById("butAll").innerHTML="All Tasks "+allLength;
  1600. document.getElementById("butPro").innerHTML="Progress "+inProgressTasks.length;
  1601. document.getElementById("butcom").innerHTML="Finished "+finishedTasks.length;
  1602. document.getElementById("butArc").innerHTML="Archived "+archivedTasks.length;
  1603. }
  1604.  
  1605. var x=true;
  1606.  
  1607. $(document).ready(function(){
  1608. $("#editConf").click(function(){
  1609. $("#myModal2").show();
  1610.  
  1611.  
  1612. });
  1613. });
  1614. $(document).ready(function(){
  1615. $("#butEdit").click(function(){
  1616. $("#myModal2").hide();
  1617.  
  1618.  
  1619. });
  1620. });
  1621.  
  1622. function edit(index){
  1623. var editable = new inputObj();
  1624. var index2 = index - 1;
  1625. var indexIn ;
  1626. if(myKey==1){
  1627. var createObj = new inputObj (allTasks[index2].name,allTasks[index2].allTasks[index2].description);
  1628. allTasks[index2].name = createObj.name ;
  1629. allTasks[index2].date = createObj.date;
  1630. allTasks[index2].description = createObj.description;
  1631. for (var i = 0; i < inProgressTasks.length; i++) {
  1632. if(inProgressTasks[i].name==createObj.name
  1633. && inProgressTasks[i].date==createObj.date
  1634. && inProgressTasks[i].description==createObj.description ){
  1635. indexIn = i ;
  1636. }
  1637. }
  1638. inProgressTasks[indexIn].name = createObj.name;
  1639. inProgressTasks[indexIn].date = createObj.date;
  1640. inProgressTasks[indexIn].description = createObj.description;
  1641. for (var i = 0; i < finishedTasks.length; i++) {
  1642. if(finishedTasks[i].name==createObj.name
  1643. && finishedTasks[i].date==createObj.date
  1644. && finishedTasks[i].description==createObj.description ){
  1645. indexIn = i ;
  1646. }
  1647. }
  1648. finishedTasks[indexIn].name = createObj.name;
  1649. finishedTasks[indexIn].date = createObj.date;
  1650. finishedTasks[indexIn].description = createObj.description;
  1651. for (var i = 0; i < archivedTasks.length; i++) {
  1652. if(archivedTasks[i].name==createObj.name
  1653. && archivedTasks[i].date==createObj.date
  1654. && archivedTasks[i].description==createObj.description ){
  1655. indexIn = i ;
  1656. }
  1657. }
  1658.  
  1659. archivedTasks[indexIn].name = createObj.name;
  1660. archivedTasks[indexIn].date = createObj.date;
  1661. archivedTasks[indexIn].description = createObj.description;
  1662.  
  1663. }else if(myKey==2){
  1664. var createObj = new inputObj (inProgressTasks[index2].name,inProgressTasks[index2].date,inProgressTasks[index2].description);
  1665. inProgressTasks[index2].name = createObj.name;
  1666. inProgressTasks[index2].date = createObj.date;
  1667. inProgressTasks[index2].description = createObj.description;
  1668.  
  1669. for (var i = 0; i < allTasks.length; i++) {
  1670. if(allTasks[i].name==createObj.name
  1671. && allTasks[i].date==createObj.date
  1672. && allTasks[i].description==createObj.description ){
  1673. indexIn = i ;
  1674. }
  1675. }
  1676. allTasks[indexIn].name = createObj.name ;
  1677. allTasks[indexIn].date = createObj.date;
  1678. allTasks[indexIn].description = createObj.description;
  1679.  
  1680. }else if(myKey==3){
  1681. var createObj = new inputObj (finishedTasks[index2].name,finishedTasks[index2].date,finishedTasks[index2].description);
  1682. finishedTasks[index2].name = createObj.name;
  1683. finishedTasks[index2].date = createObj.date;
  1684. finishedTasks[index2].description = createObj.description;
  1685. for (var i = 0; i < allTasks.length; i++) {
  1686. if(allTasks[i].name==createObj.name
  1687. && allTasks[i].date==createObj.date
  1688. && allTasks[i].description==createObj.description ){
  1689. indexIn = i ;
  1690. }
  1691. }
  1692. allTasks[indexIn].name = createObj.name ;
  1693. allTasks[indexIn].date = createObj.date;
  1694. allTasks[indexIn].description = createObj.description;
  1695. }
  1696. if(myKey==4){
  1697. var createObj = new inputObj (archivedTasks[index2].name,archivedTasks[index2].date,archivedTasks[index2].description);
  1698. archivedTasks[index2].name = createObj.name;
  1699. archivedTasks[index2].date = createObj.date;
  1700. archivedTasks[index2].description = createObj.description;
  1701. for (var i = 0; i < allTasks.length; i++) {
  1702. if(allTasks[i].name==createObj.name
  1703. && allTasks[i].date==createObj.date
  1704. && allTasks[i].description==createObj.description ){
  1705. indexIn = i ;
  1706. }
  1707. }
  1708. allTasks[indexIn].name = createObj.name ;
  1709. allTasks[indexIn].date = createObj.date;
  1710. allTasks[indexIn].description = createObj.description;
  1711. }
  1712.  
  1713.  
  1714. }
  1715. function deleteAndPrint2(index,myKey){
  1716. var index2 = index - 1 ;
  1717. if(myKey==1){
  1718. var here1=false;
  1719. var itIsHere1;
  1720. var current = new inputObj (allTasks[index2].name,allTasks[index2].date,allTasks[index2].description);
  1721. for(var i=0;i<allTasks.length&&here1==false&&allTasks.length>0;i++){
  1722.  
  1723. if(allTasks[i].name==current.name
  1724. && allTasks[i].date==current.date
  1725. && allTasks[i].description==current.description )
  1726. {
  1727.  
  1728. here1=true;
  1729. itIsHere1=i;
  1730.  
  1731. }
  1732.  
  1733. }
  1734. if(here1==true){
  1735. allTasks.splice(itIsHere1,1);
  1736. var here2=false;
  1737. var itIsHere2;
  1738. for(var i=0;i<inProgressTasks.length&&here2==false&&inProgressTasks.length>0;i++){
  1739.  
  1740. if(inProgressTasks[i].name==current.name
  1741. && inProgressTasks[i].date==current.date
  1742. && inProgressTasks[i].description==current.description )
  1743. {
  1744.  
  1745. here2=true;
  1746. itIsHere2=i;
  1747.  
  1748. }
  1749.  
  1750. }
  1751.  
  1752. if(here2==true){
  1753. inProgressTasks.splice(itIsHere2,1);
  1754. }
  1755. var here3=false;
  1756. var itIsHere3;
  1757. for(var i=0;i<finishedTasks.length&&here3==false&&finishedTasks.length>0;i++){
  1758.  
  1759. if(finishedTasks[i].name==current.name
  1760. && finishedTasks[i].date==current.date
  1761. && finishedTasks[i].description==current.description )
  1762. {
  1763.  
  1764. here3=true;
  1765. itIsHere3=i;
  1766.  
  1767. }
  1768.  
  1769. }
  1770. if(here3==true){
  1771. finishedTasks.splice(itIsHere3,1);
  1772.  
  1773. }
  1774. var here4=false;
  1775. var itIsHere4;
  1776. for(var i=0;i<archivedTasks.length&&here4==false&&archivedTasks.length>0;i++){
  1777.  
  1778. if(archivedTasks[i].name==current.name
  1779. && archivedTasks[i].date==current.date
  1780. && archivedTasks[i].description==current.description )
  1781. {
  1782.  
  1783. here4=true;
  1784. itIsHere4=i;
  1785.  
  1786. }
  1787.  
  1788. }
  1789. if(here4==true){
  1790. archivedTasks.splice(itIsHere4,1);
  1791.  
  1792. }
  1793.  
  1794.  
  1795.  
  1796. }
  1797.  
  1798.  
  1799.  
  1800.  
  1801. }
  1802. else{
  1803.  
  1804. if (myKey ==2){
  1805. var current = new inputObj (inProgressTasks[index2].name,inProgressTasks[index2].date,inProgressTasks[index2].description);
  1806. var here2=false;
  1807. var itIsHere2;
  1808. for(var i=0;i<inProgressTasks.length&&here2==false&&inProgressTasks.length>0;i++){
  1809.  
  1810. if(inProgressTasks[i].name==current.name
  1811. && inProgressTasks[i].date==current.date
  1812. && inProgressTasks[i].description==current.description )
  1813. {
  1814.  
  1815. here2=true;
  1816. itIsHere2=i;
  1817.  
  1818. }
  1819.  
  1820. }
  1821. if(here2==true){
  1822. inProgressTasks.splice(itIsHere2,1);
  1823. var here1=false;
  1824. var itIsHere1;
  1825. for(var i=0;i<allTasks.length&&here1==false&&allTasks.length>0;i++){
  1826.  
  1827. if(allTasks[i].name==current.name
  1828. && allTasks[i].date==current.date
  1829. && allTasks[i].description==current.description )
  1830. {
  1831.  
  1832. here1=true;
  1833. itIsHere1=i;
  1834.  
  1835. }
  1836.  
  1837. }
  1838. if(here1==true){
  1839. allTasks.splice(itIsHere1,1);
  1840. }
  1841. }
  1842. }
  1843. else if (myKey ==3){
  1844. var current = new inputObj (finishedTasks[index2].name,finishedTasks[index2].date,finishedTasks[index2].description);
  1845. var here3=false;
  1846. var itIsHere3;
  1847. for(var i=0;i<finishedTasks.length&&here3==false&&finishedTasks.length>0;i++){
  1848.  
  1849. if(finishedTasks[i].name==current.name
  1850. && finishedTasks[i].date==current.date
  1851. && finishedTasks[i].description==current.description )
  1852. {
  1853.  
  1854. here3=true;
  1855. itIsHere3=i;
  1856.  
  1857. }
  1858.  
  1859. }
  1860. if(here3==true){
  1861. finishedTasks.splice(itIsHere3,1);
  1862. var here1=false;
  1863. var itIsHere1;
  1864. for(var i=0;i<allTasks.length&&here1==false&&allTasks.length>0;i++){
  1865.  
  1866. if(allTasks[i].name==current.name
  1867. && allTasks[i].date==current.date
  1868. && allTasks[i].description==current.description )
  1869. {
  1870.  
  1871. here1=true;
  1872. itIsHere1=i;
  1873.  
  1874. }
  1875.  
  1876. } if(here1==true){
  1877. allTasks.splice(itIsHere1,1);}
  1878.  
  1879. }
  1880. }
  1881. else if (myKey ==4){
  1882. var current = new inputObj (archivedTasks[index2].name,archivedTasks[index2].date,archivedTasks[index2].description);
  1883. var here4=false;
  1884. var itIsHere4;
  1885. for(var i=0;i<archivedTasks.length&&here4==false&&archivedTasks.length>0;i++){
  1886.  
  1887. if(archivedTasks[i].name==current.name
  1888. && archivedTasks[i].date==current.date
  1889. && archivedTasks[i].description==current.description )
  1890. {
  1891.  
  1892. here4=true;
  1893. itIsHere4=i;
  1894.  
  1895. }
  1896.  
  1897. }
  1898. if(here4==true){
  1899. archivedTasks.splice(itIsHere4,1);
  1900. var here1=false;
  1901. var itIsHere1;
  1902. for(var i=0;i<allTasks.length&&here1==false&&allTasks.length>0;i++){
  1903.  
  1904. if(allTasks[i].name==current.name
  1905. && allTasks[i].date==current.date
  1906. && allTasks[i].description==current.description )
  1907. {
  1908.  
  1909. here1=true;
  1910. itIsHere1=i;
  1911.  
  1912. }
  1913.  
  1914. }
  1915. if(here1==true){
  1916. allTasks.splice(itIsHere1,1);}
  1917.  
  1918. }
  1919.  
  1920. }
  1921. }
  1922.  
  1923. if(myKey == 1){
  1924. drawTable1(allTasks,1);
  1925. }
  1926. else if(myKey == 2){
  1927. drawTable2(inProgressTasks,2);
  1928. }
  1929. else if (myKey == 3){
  1930. drawTable3(finishedTasks,3);
  1931. }
  1932. else if (myKey == 4){
  1933. drawTable4(archivedTasks,4);
  1934. }
  1935. printButtons();
  1936.  
  1937. }
  1938.  
  1939. function DeleteMultipleRows() {
  1940. var list = $(".Checked");
  1941. var i=0;
  1942. var numb ;
  1943. if (confirm("Are you Sure that you want to delete?") == true) {
  1944. for(numb = 0 ; numb <list.length;numb++) {
  1945. deleteAndPrint2(list[numb].rowIndex - i,myKey);
  1946. i++;
  1947. }
  1948. $("#butAdd").show();
  1949. $("#butremoveall").hide();
  1950. }
  1951.  
  1952. }
  1953. function deSelect() {
  1954. // body...
  1955.  
  1956. $("#butAdd").show();
  1957. $("#butremoveall").hide();
  1958. }
  1959. function selecting(x,y) {
  1960. if (x.checked === true) {
  1961. y.className = "Checked";
  1962. $("#butAdd").hide();
  1963. $("#butremoveall").show();
  1964. } else {
  1965. y.className = "";
  1966. if ($(".Checked").length == 0) {
  1967. $("#butAdd").show();
  1968. $("#butremoveall").hide();
  1969. }
  1970. }
  1971. }
  1972.  
  1973. $("#butremoveall").hide();
  1974.  
  1975.  
  1976. function printAtFirst(){
  1977. if(x==true){
  1978. drawTable1(allTasks,1);
  1979. boldedAll();
  1980.  
  1981. }
  1982. x=false;
  1983.  
  1984. }
  1985. printAtFirst();
  1986.  
  1987.  
  1988. </script>
  1989. </body>
  1990.  
  1991. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement