Advertisement
k0mZ

Untitled

Oct 21st, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.93 KB | None | 0 0
  1. <template lang="html">
  2. <div>
  3.  
  4. <div class="row container-fluid" id="vezbaDatum">
  5.  
  6. <!-- * make a regexp to check for the exercise name to be
  7. * only letters !!
  8. -->
  9.  
  10. <input class="col-md-6 col-lg-4 col-lg-offset-2 " id ="exerciseName"
  11. v-model="exerciseInfo.name" type="text" name="" value="" placeholder="insert exercise">
  12.  
  13. <input class="col-md-6 col-lg-4 " id="dateOfWork" type="date" v-model="exerciseInfo.datum"
  14. v-on:change="isActive = true">
  15. </div>
  16.  
  17. <div id="muscleGroup" class="row container-fluid">
  18. <select v-model="exerciseInfo.group" class="selectpicker col-md-3 col-lg-1 col-lg-offset-2" name="">
  19. <optgroup label="GroupMucles">
  20. <option v-for="muscle in groupMuscles" >{{muscle}}</option>
  21. </optgroup>
  22. </select>
  23. </div>
  24. <div class="container" id="setsContainer">
  25.  
  26. <div class="row container-fluid" id="firstSet">
  27. <label for="">
  28. <input type="checkbox" name="" value="1"
  29. v-on:change="ckdBox(1,$event)">
  30. First Set Info
  31. </label>
  32. <label v-bind:class="{active:isFirstActive,notActive:!isFirstActive}">
  33. <input type="text" name="" value="" v-model="exerciseInfo.firstSet.reps"> x
  34. <input type="text" name="" value="" v-model="exerciseInfo.firstSet.kgs"> kg
  35. </label>
  36. </div>
  37.  
  38. <div class="row container-fluid" id="secondSet">
  39. <label for="">
  40. <input type="checkbox" name="" value="2"
  41. v-on:change="ckdBox(2,$event)">
  42. Second Set Info
  43. </label>
  44. <label v-bind:class="{active:isSecondActive,notActive:!isSecondActive}">
  45. <input type="text" name="" value="" v-model="exerciseInfo.secondSet.reps"> x
  46. <input type="text" name="" value="" v-model="exerciseInfo.secondSet.kgs"> kg
  47. </label>
  48. </div>
  49.  
  50. <div class="row container-fluid" id="thirdSet">
  51. <label for="">
  52. <input type="checkbox" name="" value="3"
  53. v-on:change="ckdBox(3,$event)">
  54. Third Set Info
  55. </label>
  56. <label v-bind:class="{active:isThirdActive,notActive:!isThirdActive}">
  57. <input type="text" name="" value="" v-model="exerciseInfo.thirdSet.reps"> x
  58. <input type="text" name="" value="" v-model="exerciseInfo.thirdSet.kgs"> kg
  59. </label>
  60. </div>
  61.  
  62. </div>
  63.  
  64. <div id="submitInf">
  65. <button type="submit" class="btn btn-primary" name="button" v-on:click="submitInfo">Submit info</button>
  66. </div>
  67.  
  68.  
  69. <div id="preview" class="row container-fluid">
  70. <h1>Preview of Info </h1>
  71. <p>{{exerciseInfo.name}}</p>
  72. <p>{{exerciseInfo.group}}</p>
  73. <p v-bind:class="{active:isActive,notActive:!isActive}">
  74. {{exerciseInfo.datum | momentFormat}}</p>
  75. <h2 v-if="isFirstActive">First Set</h2>
  76. <p v-if="isFirstActive">{{exerciseInfo.firstSet.reps}} reps x {{exerciseInfo.firstSet.kgs}}kg </p>
  77. <h2 v-if="isSecondActive">Second Set</h2>
  78. <p v-if="isSecondActive">{{exerciseInfo.secondSet.reps}} reps x {{exerciseInfo.secondSet.kgs}}kg </p>
  79. <h2 v-if="isThirdActive">Third Set</h2>
  80. <p v-if="isThirdActive">{{exerciseInfo.thirdSet.reps}} reps x {{exerciseInfo.thirdSet.kgs}}kg </p>
  81.  
  82. </div>
  83. </div>
  84. </template>
  85.  
  86. <script>
  87.  
  88. const mysql = require('mysql');
  89. var moment = require('moment');
  90.  
  91. export default {
  92. data:function(){
  93. return {
  94. exerciseInfo:{
  95. name:"",
  96. group:"",
  97. datum: moment().format("DD-MMM-YYYY"),
  98.  
  99. //Sets contain obj
  100. //{setNum:...,reps:...,kgs:...}
  101. firstSet:{
  102. reps:null,
  103. kgs:null
  104. },
  105. secondSet:{
  106. reps:null,
  107. kgs:null
  108. },
  109. thirdSet:{
  110. reps:null,
  111. kgs:null
  112. }
  113. },
  114. isActive:false,
  115. isFirstActive:false,
  116. isSecondActive:false,
  117. isThirdActive:false,
  118. groupMuscles:['Chest','Back','Arms','Shoulders','Legs']
  119. }
  120. },
  121. methods:{
  122. submitInfo:function(){
  123.  
  124. var mysql = require('mysql');
  125. var connection = mysql.createConnection({
  126. host : 'localhost',
  127. user : 'me',
  128. password : 'secret',
  129. database : 'my_db'
  130. });
  131.  
  132. connection.connect();
  133.  
  134. },
  135. ckdBox : function(arg,e)
  136. {
  137. if(arg === 1){
  138. this.isFirstActive = !this.isFirstActive;
  139. }
  140. if(arg === 2 ){
  141. if(this.isFirstActive){
  142. this.isSecondActive = !this.isSecondActive ;
  143. }
  144. else {
  145. e.target.checked = false;
  146. }
  147. }
  148.  
  149. if(arg === 3){
  150. if(this.isFirstActive && this.isSecondActive){
  151. this.isThirdActive = !this.isThirdActive;
  152. }
  153. else {
  154. e.target.checked = false;
  155. }
  156. }
  157. }
  158.  
  159.  
  160. },
  161. filters: {
  162. momentFormat: function (date) {
  163. return moment(date).format('DD-MMM-YYYY');
  164. }
  165. }
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement