Guest User

Untitled

a guest
Aug 30th, 2018
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.22 KB | None | 0 0
  1. <template>
  2. <main id="fullpage">
  3. <b-form @submit.prevent="validateForm($event)" id="contactForm" autocomplete="off"
  4. method="post">
  5. <section class="section contactForm">
  6. <b-form-row>
  7. <h1>{{clientMsg}}</h1>
  8. </b-form-row>
  9. <b-form-row>
  10. <b-col>
  11. <input type="radio" name="client" value="individual" @click="IndvClient"> <label for="individual">an individual?</label>
  12. </b-col>
  13. <b-col>
  14. <input type="radio" name="client" value="company" @click="CorporateClient" > <label for="company">a company?</label>
  15. </b-col>
  16. <b-col cols="12">
  17. <a class="steps text-right next" :href="sectionLinks.emailLink">Next</a>
  18. </b-col>
  19. </b-form-row>
  20. </section>
  21. <section class="section contactForm">
  22. <b-row no-gutters>
  23. <b-col>
  24. <input type="email" id="usrEmail" placeholder="Email address..." class="text-center"
  25. :pattern="emailValidation" required v-model="email" @mouseout="isValidEmail($event)" autocomplete="off">
  26. </b-col>
  27. </b-row>
  28. <b-row no-gutters>
  29. <b-col cols="6">
  30. <a href="#clientType" class="steps text-left">Previous</a>
  31. </b-col>
  32. <b-col cols="6">
  33. <a class="steps text-right next" :href="sectionLinks.nameLink">Next</a>
  34. </b-col>
  35. </b-row>
  36. </section>
  37. <section class="section contactForm">
  38. <input type="text" name="usrName" id="usrName" placeholder="Name..." class="text-center"
  39. required :pattern="textValidation" v-model="name" @mouseout="isValidName($event)" autocomplete="off">
  40. <b-row no-gutters>
  41. <b-col cols="6">
  42. <a href="#email" class="steps text-left">Previous</a>
  43. </b-col>
  44. <b-col cols="6">
  45. <a class="steps text-right next" :href="sectionLinks.titleLink">Next</a>
  46. </b-col>
  47. </b-row>
  48. </section>
  49. <section class="section contactForm">
  50. <input type="text" name="msgTitle" id="msgTitle" placeholder="Title of the message..."
  51. class="text-center" v-model="messageTitle" required :pattern="textValidation"
  52. @mouseout="isValidTitle($event)" autocomplete="off">
  53. <b-row no-gutters>
  54. <b-col cols="6">
  55. <a href="#name" class="steps text-left">Previous</a>
  56. </b-col>
  57. <b-col cols="6">
  58. <a class="steps text-right next" :href="sectionLinks.msgLink" >Next</a>
  59. </b-col>
  60. </b-row>
  61. </section>
  62. <section class="section contactForm">
  63. <b-row no-gutters>
  64. <b-col cols="12">
  65. <textarea name="" id="msgContent" cols="100" rows="7"
  66. placeholder="Message..." v-model="message" required
  67. @mouseout="isValidMsg($event)"></textarea>
  68. </b-col>
  69. </b-row>
  70. <b-row no-gutters>
  71. <b-col cols="6">
  72. <a href="#title" class="steps text-left">Previous</a>
  73. </b-col>
  74. <b-col cols="6">
  75. <a class="steps text-right next" :href="sectionLinks.msgSummaryLink">Next</a>
  76. </b-col>
  77. </b-row>
  78. </section>
  79. <section class="section contactForm formSummary">
  80. <ul class="prevFormLinks">
  81. <li v-for="section in previousLinks">
  82. <a :href="section.link">{{section.name}}</a>
  83. </li>
  84. </ul>
  85. <b-form-row>
  86. <p>{{clientMsg}}</p>
  87. </b-form-row>
  88. <b-form-row>
  89. <b-col>
  90. <input type="radio" name="userClient" value="individual"> <label for="individual">an individual?</label>
  91. </b-col>
  92. <b-col>
  93. <input type="radio" name="userClient" value="company"> <label for="company">a company?</label>
  94. </b-col>
  95. </b-form-row>
  96. <b-form-row>
  97. <b-col>
  98. <h2>Your email:</h2>
  99. </b-col>
  100. <b-col>
  101. <p>{{email}}</p>
  102. </b-col>
  103. </b-form-row>
  104. <b-form-row>
  105. <b-col>
  106. <h2>Name:</h2>
  107. </b-col>
  108. <b-col>
  109. <p>{{name}}</p>
  110. </b-col>
  111. </b-form-row>
  112. <b-form-row>
  113. <b-col>
  114. <h4>Title of the message:</h4>
  115. </b-col>
  116. <b-col>
  117. <p>{{messageTitle}}</p>
  118. </b-col>
  119. </b-form-row>
  120. <b-form-row>
  121. <b-col cols="5" id="msgSummary">
  122. <p>{{message}}</p>
  123. </b-col>
  124. </b-form-row>
  125. <b-form-row>
  126. <b-col cols="12">
  127. <input type="submit" value="Submit!">
  128. </b-col>
  129. </b-form-row>
  130. </section>
  131. </b-form>
  132. </main>
  133. </template>
  134. <script>
  135. import fullpage from 'fullpage.js'
  136. import $ from "jquery"
  137. /**
  138. Make sure you can then send an email
  139. Replace the jQuery animations with anime.js or another way of animating.
  140. There are no previous buttons for the summary section.
  141. */
  142. export default {
  143. data(){
  144. return {
  145. "clientMsg":this.$store.state.contact.TypeOfClientMsg,
  146. "name":"",
  147. "email":"",
  148. "messageTitle":"",
  149. "message":"",
  150. "emailValidation":"^([a-zA-Z0-9_-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([a-zA-Z0-9-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$",
  151. "textValidation":"[a-zA-Z ]+",
  152. "sectionLinks":{
  153. "clientLink":"#clientType",
  154. "emailLink":"#email",
  155. "nameLink": "#name",
  156. "titleLink":"#title",
  157. "msgLink":"#message",
  158. "msgSummaryLink":"#messageSummary"
  159. },
  160. "previousLinks":[
  161. {
  162. "link":"#clientType",
  163. "name":"Client"
  164. },
  165. {
  166. "link":"#email",
  167. "name":"Email"
  168. },
  169. {
  170. "link":"#name",
  171. "name":"Name"
  172. },
  173. {
  174. "link":"#title",
  175. "name":"Title"
  176. },
  177. {
  178. "link":"#message",
  179. "name":"Message"
  180. }
  181. ],
  182. "companyEmail":"salay777@hotmail.co.uk"
  183. }
  184. },
  185. methods:{
  186. IndvClient:function(){
  187. let ind = document.querySelectorAll('input[value="individual"]');
  188. let company = document.querySelectorAll('input[value="company"]'),
  189. goToEmail = document.querySelector('a[href="#email"]');
  190. (ind[0].checked == true)? ind[1].checked = true : ind[1].checked = false;
  191. $(goToEmail).fadeIn();
  192. },
  193. CorporateClient:function(){
  194. let ind = document.querySelectorAll('input[value="individual"]');
  195. let company = document.querySelectorAll('input[value="company"]'),
  196. goToEmail = document.querySelector('a[href="#email"]');
  197. (company[0].checked == true)? company[1].checked = true : company[1].checked = false;
  198. $(goToEmail).fadeIn();
  199. },
  200. isValidEmail:function(e){
  201. let goToName = document.querySelector('a[href="#name"]');
  202. (e.target.checkValidity())? $(goToName).fadeIn() : $(goToName).fadeOut();
  203. },
  204. isValidName:function(e){
  205. let goToTitle = document.querySelector('a[href="#title"]');
  206. (e.target.checkValidity())? $(goToTitle).fadeIn() : $(goToTitle).fadeOut();
  207. },
  208. isValidTitle:function(e){
  209. let goToMsg = document.querySelector('a[href="#message"]');
  210. (e.target.checkValidity())? $(goToMsg).fadeIn() : $(goToMsg).fadeOut();
  211. },
  212. isValidMsg:function(e){
  213. let goToSummary = document.querySelector('a[href="#messageSummary"]');
  214. (e.target.checkValidity())? $(goToSummary).fadeIn() : $(goToSummary).fadeOut();
  215. },
  216. validateForm:function(e){
  217. let idvClient = document.querySelector('input[value="individual"]'),
  218. corporateClient = document.querySelector('input[value="company"]'),
  219. usrEmail = document.getElementById('usrEmail'), usrName = document.
  220. getElementById('usrName'), msgTitle = document.getElementById('msgTitle'),
  221. msgContent = document.getElementById('msgContent'),
  222. socket = io.connect('http://localhost:5000/');
  223.  
  224.  
  225. if(idvClient.checked !== corporateClient.checked){
  226. console.log('client has been checked');
  227. if(usrEmail.checkValidity() == false || usrName.checkValidity() == false ||
  228. msgTitle.checkValidity() == false || msgContent.checkValidity() == false){
  229. e.preventDefault();
  230. } else {
  231. let email = {
  232. client :"",
  233. email: this.email,
  234. name: this.name,
  235. title: this.messageTitle,
  236. message: this.message
  237. };
  238. if(idvClient.checked){
  239. email.client = "[IDV]";
  240. }
  241. if(corporateClient.checked){
  242. email.client = "[CO]";
  243. }
  244.  
  245. socket.emit('email',email);
  246. alert('submitted!');
  247. }
  248. } else {
  249. console.log('you need to select a client type');
  250. e.preventDefault();
  251. }
  252. }
  253. },
  254. mounted(){
  255. let idvClient = document.querySelector('input[value="individual"]'),
  256. corporateClient = document.querySelector('input[value="company"]'),
  257. goToEmail = document.querySelector('a[href="#email"]'), form =
  258. document.querySelector('form');
  259.  
  260. form.setAttribute('autocomplete', 'off');
  261.  
  262. if(idvClient.checked == corporateClient.checked){
  263. goToEmail.style.display = 'none';
  264. }
  265. }
  266. };
  267. </script>
  268. <style>
  269.  
  270. html body #fullpage {
  271. background-color:#383838 !important;
  272. background-image: none !important;
  273. }
  274.  
  275. html, body,#fullpage {
  276. overflow: hidden !important;
  277. }
  278. .fp-tableCell{
  279. text-align:center;
  280. display:flex;
  281. justify-content: center;
  282. align-items: center;
  283. flex-direction: column;
  284.  
  285. }
  286.  
  287. .contactDetails .row {
  288. margin:0px;
  289. }
  290.  
  291. .contactForm .form-row {
  292. min-width:500px;
  293. justify-content:center;
  294. }
  295.  
  296. .contactForm .form-row a, .contactForm .row a {
  297. margin: 60px;
  298. text-decoration: none;
  299. color: #f4f4f4;
  300. font-size: 36px;
  301. font-weight: 100;
  302. transition: color .5s, font-size .2s;
  303. }
  304.  
  305. .contactForm .form-row a:hover, .contactForm .row a:hover {
  306. color:orange;
  307. font-size:40px;
  308. }
  309.  
  310. #menu {
  311. display: none !important;
  312. }
  313.  
  314. button {
  315. margin-top:20px;
  316. }
  317.  
  318. h1, h2, h3 , h4 {
  319. font-weight:100;
  320. }
  321.  
  322. .next {
  323. display: none;
  324. }
  325.  
  326. #msgSummary {
  327. word-wrap: break-word;
  328. text-align:left;
  329. }
  330.  
  331. .formSummary, .formSummary h2 , .formSummary h4,
  332. .formSummary p {
  333. text-align:left !important;
  334. }
  335.  
  336. .prevFormLinks {
  337. position:absolute;
  338. left:30px;
  339. text-align:left;
  340. margin:0px !important;
  341. padding:0px;
  342. color:white !important;
  343. }
  344.  
  345. .prevFormLinks a {
  346. font-size:20px !important;
  347. margin:0px!important;
  348. padding: 0px !important;
  349. text-decoration: none;
  350. color: white !important;
  351. font-weight:100;
  352. transition: font-size .25s, color 2s;
  353. }
  354.  
  355. .prevFormLinks a:hover {
  356. font-size: 25px !important;
  357. color: orange !important;
  358. }
  359. </style>
  360.  
  361. let transporter = nodemailer.createTransport({
  362. service : 'gmail',
  363. auth: {
  364. user:'projectgorillatransporter@gmail.com',
  365. pass'*******'
  366. }
  367. });
  368.  
  369. let setMailOptions = (from, to, subject, text)=>{
  370. return new Promise((resolve, reject)=>{
  371. mailOptions.from = from;
  372. mailOptions.to = to;
  373. mailOptions.subject = subject;
  374. mailOptions.text = text;
  375.  
  376. console.log(mailOptions);
  377. resolve(mailOptions);
  378. reject(Error('the mailOPtions object was not created'));
  379. });
  380. };
  381.  
  382. let sendEmail = (mailOptions)=>{
  383. transporter.sendMail(mailOptions, (err, info)=>{
  384. if (err) {
  385. console.log(err);
  386. } else {
  387. console.log('Email sent: ' + info.response);
  388. }
  389. });
  390. }
  391.  
  392. return {
  393. send : sendEmail,
  394. setMailOptions : setMailOptions
  395. }
  396. })(); // end of the email module
  397.  
  398. module.exports = emailModule;
  399.  
  400. let express = require('express'), app = express(), path = require('path'),
  401. socket = require('socket.io'), emailModule = require('./email.js');
  402.  
  403. let server = app.listen(5000, ()=>{
  404. console.log('listening to requests...');
  405. });
  406.  
  407.  
  408. let io = socket(server);
  409.  
  410. app.get('/', function(req, res) {
  411. res.sendFile(path.join(__dirname + '/index.html'));
  412. });
  413.  
  414. io.on('connection', (socket)=>{
  415. console.log('made a connection!');
  416.  
  417. socket.on('email', (data)=>{
  418. /**
  419. * Here you need to set your email options which includes the clients email, destination email,
  420. * subject and the text (the email content).
  421. */
  422. emailModule.setMailOptions(data.email,'salay777@hotmail.co.uk', data.client + ' ' + '(' +
  423. data.name + ')' + ' ' + data.title, data.message).then((mailOpts)=>{
  424. emailModule.send(mailOpts);
  425. console.log('email has been sent!');
  426. });
  427. });
  428. });
Add Comment
Please, Sign In to add comment