Advertisement
computeroverhauls

Untitled

Aug 7th, 2017
855
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.77 KB | None | 0 0
  1. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  2. <script>
  3. // handles the click event for link 1, sends the query
  4. function getOutput() {
  5. var model = document.getElementById('model').value;
  6. var carrier = document.getElementById('carrier').value;
  7. var condition = document.getElementById('condition').value;
  8. var storage = document.getElementById('storage').value;
  9. if(model == 'none' || carrier == 'none' || condition == 'none' || storage == 'none' || storage == null){
  10. var container = document.getElementById('output');
  11. container.innerHTML = '<h3>Please fill out all of the form fields</h3>';
  12. $('#outputcont').show(300);
  13. }else{
  14. getRequest(
  15. 'quotest/PHPExcel/getQuote.php?model=' + model + "&condition=" + condition + '&storage=' + storage + '&carrier=' + carrier , // URL for the PHP file
  16. drawOutput, // handle successful request
  17. drawError // handle error
  18. );
  19. scrollTo(0, 800);
  20. }
  21. return false;
  22. }
  23. // handles drawing an error message
  24. function drawError() {
  25. var container = document.getElementById('output');
  26. container.innerHTML = 'Please try again later or contact us at info@computeroverhauls.com';
  27. }
  28. // handles the response, adds the html
  29. function drawOutput(responseText) {
  30. $('#outputcont').show(300);
  31. var container = document.getElementById('output');
  32. container.innerHTML = responseText;
  33. }
  34. // helper function for cross-browser request object
  35. function getRequest(url, success, error) {
  36. var req = false;
  37. try{
  38. // most browsers
  39. req = new XMLHttpRequest();
  40. } catch (e){
  41. // IE
  42. try{
  43. req = new ActiveXObject("Msxml2.XMLHTTP");
  44. } catch(e) {
  45. // try an older version
  46. try{
  47. req = new ActiveXObject("Microsoft.XMLHTTP");
  48. } catch(e) {
  49. return false;
  50. }
  51. }
  52. }
  53. if (!req) return false;
  54. if (typeof success != 'function') success = function () {};
  55. if (typeof error!= 'function') error = function () {};
  56. req.onreadystatechange = function(){
  57. if(req.readyState == 4) {
  58. return req.status === 200 ?
  59. success(req.responseText) : error(req.status);
  60. }
  61. }
  62. req.open("GET", url, true);
  63. req.send('');
  64. return req;
  65. }
  66. $(document).ready(function(){
  67. $('#0').hide();
  68. $("#1").hide(); //Hides all the capacity fields
  69. $("#2").hide();
  70. $("#3").hide();
  71. $("#4").hide();
  72. $("#5").hide();
  73. $('.carriercont').hide();
  74. $('.condcont').hide();
  75. $('#model').on('change', function() { //Removes the placeholder after anything has been selected
  76. if ( this.value !== 'none') //Also fades in the next dropdown
  77. {
  78. $("#modelplaceholder").hide();
  79. //$(".storagecont").show(300);
  80. if($(this).val() == "ipadpro212"){
  81. $('#storage').val($('256GB'));
  82. $('#0').show(300);
  83. $('#0').attr('class', 'storagecont valid');
  84. $("#1").show(300);
  85. $('#1').attr("class", "storagecont valid");
  86. $("#2").hide(300);
  87. $('#2').attr("class", "storagecont invalid");
  88. $("#3").show(300);
  89. $('#3').attr("class", "storagecont valid");
  90. $("#4").hide(300);
  91. $('#4').attr("class", "storagecont invalid");
  92. $("#5").hide(300);
  93. $('#5').attr("class", "storagecont invalid");
  94. }
  95. if($(this).val() == "ipadpro210"){
  96. $('#storage').val($('256GB'));
  97. $('#0').show(300);
  98. $('#0').attr('class', 'storagecont valid');
  99. $("#1").show(300);
  100. $('#1').attr("class", "storagecont valid");
  101. $("#2").hide(300);
  102. $('#2').attr("class", "storagecont invalid");
  103. $("#3").show(300);
  104. $('#3').attr("class", "storagecont valid");
  105. $("#4").hide(300);
  106. $('#4').attr("class", "storagecont invalid");
  107. $("#5").hide(300);
  108. $('#5').attr("class", "storagecont invalid");
  109. }
  110. if($(this).val() == "ipadpro210"){
  111. $('#storage').val($('256GB'));
  112. $('#0').show(300);
  113. $('#0').attr('class', 'storagecont valid');
  114. $("#1").show(300);
  115. $('#1').attr("class", "storagecont valid");
  116. $("#2").hide(300);
  117. $('#2').attr("class", "storagecont invalid");
  118. $("#3").show(300);
  119. $('#3').attr("class", "storagecont valid");
  120. $("#4").hide(300);
  121. $('#4').attr("class", "storagecont invalid");
  122. $("#5").hide(300);
  123. $('#5').attr("class", "storagecont invalid");
  124.  
  125. }
  126. if($(this).val() == "ipadpro12"){ //Only show the right capacity field for the right model, hide all others
  127. $('#storage').val($('256GB'));
  128. $("#0").hide(300);
  129. $("#0").attr("class", 'storagecont invalid');
  130. $("#1").show(300);
  131. $('#1').attr("class", "storagecont valid");
  132. $("#2").show(300);
  133. $('#2').attr("class", "storagecont valid");
  134. $("#3").hide(300);
  135. $('#3').attr("class", "storagecont invalid");
  136. $("#4").show(300);
  137. $('#4').attr("class", "storagecont valid");
  138. $("#5").hide(300);
  139. $('#5').attr("class", "storagecont invalid");
  140. }
  141. if($(this).val() == "ipadpro9"){ //Only show the right capacity field for the right model, hide all others
  142. $('#storage').val($('256GB'));
  143. $("#0").hide(300);
  144. $("#0").attr("class", 'storagecont invalid');
  145. $("#1").show(300);
  146. $('#1').attr("class", "storagecont valid");
  147. $("#2").show(300);
  148. $('#2').attr("class", "storagecont valid");
  149. $("#3").hide(300);
  150. $('#3').attr("class", "storagecont invalid");
  151. $("#4").show(300);
  152. $('#4').attr("class", "storagecont valid");
  153. $("#5").hide(300);
  154. $('#5').attr("class", "storagecont invalid");
  155. }
  156. if($(this).val() == "ipadair2"){
  157. $('#storage').val($('128GB'));
  158. $("#0").hide(300);
  159. $("#0").attr("class", 'storagecont invalid');
  160. $("#1").hide(300);
  161. $("#1").attr("class", 'storagecont invalid');
  162. $("#2").show(300);
  163. $('#2').attr("class", "storagecont valid");
  164. $("#3").show(300);
  165. $('#3').attr("class", "storagecont valid");
  166. $("#4").hide(300);
  167. $('#4').attr("class", "storagecont invalid");
  168. $("#5").show(300);
  169. $('#5').attr("class", "storagecont valid");
  170. }
  171. if($(this).val() == "ipadair"){
  172. $('#storage').val($('128GB'));
  173. $("#0").hide(300);
  174. $("#0").attr("class", 'storagecont invalid');
  175. $("#1").hide(300);
  176. $("#1").attr("class", 'storagecont invalid');
  177. $("#2").show(300);
  178. $('#2').attr("class", "storagecont valid");
  179. $("#3").show(300);
  180. $('#3').attr("class", "storagecont valid");
  181. $("#4").show(300);
  182. $('#4').attr("class", "storagecont valid");
  183. $("#5").show(300);
  184. $('#5').attr("class", "storagecont valid");
  185. }
  186. if($(this).val() == "ipad5"){
  187. $("#0").hide(300);
  188. $("#0").attr("class", 'storagecont invalid');
  189. $("#1").hide(300);
  190. $("#1").attr("class", 'storagecont invalid');
  191. $("#2").show(300);
  192. $('#2').attr("class", "storagecont valid");
  193. $("#3").hide(300);
  194. $('#3').attr("class", "storagecont invalid");
  195. $("#4").show(300);
  196. $('#4').attr("class", "storagecont valid");
  197. $("#5").hide(300);
  198. $('#5').attr("class", "storagecont invalid");
  199. }
  200. if($(this).val() == "ipadmini4"){
  201. $('#storage').val($('128GB'));
  202. $("#0").hide(300);
  203. $("#0").attr("class", 'storagecont invalid');
  204. $("#1").hide(300);
  205. $("#1").attr("class", 'storagecont invalid');
  206. $("#2").show(300);
  207. $('#2').attr("class", "storagecont valid");
  208. $("#3").show(300);
  209. $('#3').attr("class", "storagecont valid");
  210. $("#4").show(300);
  211. $('#4').attr("class", "storagecont valid");
  212. $("#5").show(300);
  213. $('#5').attr("class", "storagecont valid");
  214. }
  215. if($(this).val() == "ipadmini3"){
  216. $('#storage').val($('128GB'));
  217. $("#0").hide(300);
  218. $("#0").attr("class", 'storagecont invalid');
  219. $("#1").hide(300);
  220. $("#1").attr("class", 'storagecont invalid');
  221. $("#2").hide(300);
  222. $('#2').attr("class", "storagecont invalid");
  223. $("#3").show(300);
  224. $('#3').attr("class", "storagecont valid");
  225. $("#4").show(300);
  226. $('#4').attr("class", "storagecont valid");
  227. $("#5").show(300);
  228. $('#5').attr("class", "storagecont valid");
  229. }
  230. if($(this).val() == "ipadmini2"){
  231. $('#storage').val($('128GB'));
  232. $("#0").hide(300);
  233. $("#0").attr("class", 'storagecont invalid');
  234. $("#1").hide(300);
  235. $("#1").attr("class", 'storagecont invalid');
  236. $("#2").show(300);
  237. $('#2').attr("class", "storagecont valid");
  238. $("#3").show(300);
  239. $('#3').attr("class", "storagecont valid");
  240. $("#4").show(300);
  241. $('#4').attr("class", "storagecont valid");
  242. $("#5").show(300);
  243. $('#5').attr("class", "storagecont valid");
  244. }
  245. if($(this).val() == "ipad4"){
  246. $('#storage').val($('128GB'));
  247. $("#0").hide(300);
  248. $("#0").attr("class", 'storagecont invalid');
  249. $("#1").hide(300);
  250. $("#1").attr("class", 'storagecont invalid');
  251. $("#2").hide(300);
  252. $('#2').attr("class", "storagecont invalid");
  253. $("#3").show(300);
  254. $('#3').attr("class", "storagecont valid");
  255. $("#4").show(300);
  256. $('#4').attr("class", "storagecont valid");
  257. $("#5").show(300);
  258. $('#5').attr("class", "storagecont valid");
  259. }
  260. if($(this).val() == "ipad3"){
  261. $('#storage').val($('128GB'));
  262. $("#0").hide(300);
  263. $("#0").attr("class", 'storagecont invalid');
  264. $("#1").hide(300);
  265. $("#1").attr("class", 'storagecont invalid');
  266. $("#2").hide(300);
  267. $('#2').attr("class", "storagecont invalid");
  268. $("#3").show(300);
  269. $('#3').attr("class", "storagecont valid");
  270. $("#4").show(300);
  271. $('#4').attr("class", "storagecont valid");
  272. $("#5").show(300);
  273. $('#5').attr("class", "storagecont valid");
  274. }
  275. $("#storageHeader").show(300);
  276. }
  277. });
  278. $('#storage').on('change', function() {
  279. if ( this.value !== 'none' && $('#carrier').val() == 'none')
  280. {
  281. $(".carriercont").show(300);
  282. $("#carrierHeader").show(300);
  283. $("#storageplaceholder").hide();
  284. }
  285. });
  286. $('#carrier').on('change', function() {
  287. if ( this.value !== 'none' && $('#condition').val() == 'none')
  288. {
  289. $("#conditionHeader").show(300);
  290. $(".condcont").show(300);
  291. $("#carrierplaceholder").hide();
  292. }
  293. });
  294. $('#condition').on('change', function() {
  295. if (this.value != 'none')
  296. {
  297. var cond = '#' + $(this).val().toLowerCase();
  298. $(".blurb:not(" + cond +")").hide(300, function(){
  299. $(cond).show(300);
  300. });
  301. $(".btn").fadeIn(300);
  302. $("#conditionplaceholder").hide();
  303. }else{
  304. $(cond).show(300);
  305. }
  306.  
  307. });
  308. $('.modelscont').on('click', function() {
  309. var model = $(this).attr("id");
  310. var modelcont = "#" + model;
  311. if($('#model').val() == "none"){
  312. $('#model').val(model);
  313. $('.modelscont').fadeOut(function() {
  314. $(modelcont).fadeIn();
  315. $('#model').change();
  316. });
  317. }else{
  318. $(modelcont).fadeOut(function(){
  319. $('.modelscont').fadeIn();
  320. $('#model').val("none");
  321. });
  322. }
  323. });
  324. $('.storagecont').on('click', function() {
  325. var storage = $(this).text();
  326. var id = $(this).attr("id");
  327. var storagecont = "#" + id;
  328. if($('#storage').val() == null){
  329. $('.storagecont').hide(300, function(){
  330. $(storagecont).show(300);
  331. $('#storage').val(storage);
  332. $('#storage').change();
  333. });
  334. }else{
  335. $('.valid').show(300);
  336. $('#storage').val(null);
  337. }
  338. });
  339. $('.carriercont').on('click', function() {
  340. var carrier = $(this).attr("name");
  341. var id = $(this).attr("id");
  342. var carriercont = "#" + id;
  343. if($('#carrier').val() == "none"){
  344. $('#carrier').val(carrier);
  345. $('.carriercont').fadeOut(function() {
  346. $(carriercont).fadeIn();
  347. $('#carrier').change();
  348. });
  349. }else{
  350. $(carriercont).fadeOut(function(){
  351. $('.carriercont').fadeIn();
  352. $('#carrier').val("none");
  353. });
  354. }
  355. });
  356. $('.condcont').on('click', function() {
  357. var condition = $(this).attr("name");
  358. var condcont = "#" + $(this).attr("id");
  359.  
  360. if($('#condition').val() == "none"){
  361. $('#condition').val(condition);
  362. $('.condcont').fadeOut(function() {
  363. $(condcont).fadeIn();
  364. $('#condition').change();
  365. });
  366. }else{
  367. $(condcont).fadeOut(function(){
  368. $('.condcont').fadeIn();
  369. $('#condition').val("none");
  370. });
  371. }
  372. });
  373. $('#restart').on('click', function(){
  374. scrollTo(0, 0);
  375. location.reload();
  376. });
  377.  
  378. });
  379.  
  380. </script>
  381. <!-- Google Code for Add to Cart Conversion Page
  382. In your html page, add the snippet and call goog_report_conversion
  383. when someone clicks on the chosen link or button. -->
  384.  
  385. <style>
  386. #model{
  387. display:none;
  388. }
  389. #jumbotron{
  390. font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
  391. }
  392. .itemcont {
  393. overflow: hidden;
  394. margin:15px;
  395. align-items: center;
  396. }
  397. .itemheader{
  398. margin-right: auto;
  399. margin-bottom:10px;
  400. }
  401. .modelscont{
  402. display:inline-block;
  403. background-color:white;
  404. border-radius:5px;
  405. padding:20px 20px 0px 20px;
  406. transition:background-color .25s, color .25s;
  407. user-select: none;
  408. -moz-user-select: none;
  409. -khtml-user-select: none;
  410. -webkit-user-select: none;
  411. -o-user-select: none;
  412. cursor:hand;
  413. margin-bottom:20px;
  414. border:solid #a5a5a5 1px;
  415. }
  416. .storagecont{
  417. display:none;
  418. display:inline-block;
  419. background-color:white;
  420. border-radius:5px;
  421. padding:10px 20px 10px 20px;
  422. transition:background-color .25s, color .25s;
  423. user-select: none;
  424. -moz-user-select: none;
  425. -khtml-user-select: none;
  426. -webkit-user-select: none;
  427. -o-user-select: none;
  428. cursor:hand;
  429. margin-bottom:20px;
  430. border:solid #a5a5a5 1px;
  431. }
  432. .storagecont:hover {
  433. background-color:rgba(121, 169, 128, 1);
  434. }
  435. .carriercont{
  436. display:none;
  437. display:inline-block;
  438. background-color:white;
  439. border-radius:5px;
  440. padding:10px 20px 10px 20px;
  441. transition:background-color .25s, color .25s;
  442. user-select: none;
  443. -moz-user-select: none;
  444. -khtml-user-select: none;
  445. -webkit-user-select: none;
  446. -o-user-select: none;
  447. cursor:hand;
  448. margin-bottom:20px;
  449. border:solid #a5a5a5 1px;
  450. }
  451. .carriercont:hover {
  452. background-color:rgba(121, 169, 128, 1);
  453. }
  454. .condcont{
  455. display:none;
  456. display:inline-block;
  457. background-color:white;
  458. border-radius:5px;
  459. padding:10px 20px 10px 20px;
  460. transition:background-color .25s, color .25s;
  461. user-select: none;
  462. -moz-user-select: none;
  463. -khtml-user-select: none;
  464. -webkit-user-select: none;
  465. -o-user-select: none;
  466. cursor:hand;
  467. margin-bottom:20px;
  468. border:solid #a5a5a5 1px;
  469. }
  470. .condcont:hover {
  471. background-color:rgba(121, 169, 128, 1);
  472. }
  473. #outputcont{
  474. display:none;
  475. margin:20px;
  476. }
  477. #output{
  478. font-size:3em;
  479. margin:20px;
  480. }
  481. .modelscont:hover {
  482. background-color:rgba(121, 169, 128, 1);
  483. }
  484. .models{
  485. height:75px;
  486. }
  487. #model{
  488. margin:0 auto;
  489. }
  490. #output{
  491. margin-top:50px;
  492. }
  493. .btn {
  494. display:none;
  495. background-color:#44c767;
  496. -moz-border-radius:28px;
  497. -webkit-border-radius:28px;
  498. border-radius:10px;
  499. border:1px solid #18ab29;
  500. cursor:pointer;
  501. color:#ffffff;
  502. font-family:Arial;
  503. font-size:17px;
  504. padding:16px 31px;
  505. text-decoration:none;
  506. text-shadow:0px 1px 0px #2f6627;
  507. outline:none;
  508. }
  509. .btn:hover {
  510. background-color:#5cbf2a;
  511. }
  512. .btn:active {
  513. background-color:#169c23;
  514. position:relative;
  515. top:1px;
  516. }
  517. #jumbotron {
  518. width:100%;
  519. margin:0 auto;
  520. text-align:center;
  521. padding:20px 0 20px 0;
  522. border-radius:3px;
  523. }
  524. #5 {
  525. display:none;
  526. }
  527. #items{
  528. width:75%;
  529. margin:0 auto;
  530. }
  531.  
  532. select {
  533. border: 1px solid #ccc;
  534. border-radius: 3px;
  535. overflow: hidden;
  536. background: #fafafa ;
  537. display:inline-block;
  538. width:100px;
  539. }
  540.  
  541. select option {
  542. padding: 5px 8px;
  543. width: 130%;
  544. border: none;
  545. box-shadow: none;
  546. background: transparent;
  547. background-image: none;
  548. -webkit-appearance: none;
  549. }
  550.  
  551. select select:focus {
  552. outline: none;
  553. }
  554. #output{
  555. transition:all .25s;
  556. }
  557. #output p{
  558. margin:0 auto;
  559. width:100%;
  560. font-size:.4em;
  561. line-height:1em;
  562. text-align:left;
  563. }
  564. .blurb{
  565. display:none;
  566. margin:15px;
  567. text-align:left;
  568. border:solid gray 2px;
  569. padding:10px;
  570. }
  571. #output h1 { font-size: 2em; margin: .67em 0;line-height:1em;}
  572. #output h2 { font-size: 2.5em; margin: .75em 0;}
  573. #output h3 { font-size: .6em; margin: .83em 0;line-height:1em;}
  574. h4 { margin: 1.12em 0 }
  575. h5 { font-size: .83em; margin: 1.5em 0 }
  576. h6 { font-size: .75em; margin: 1.67em 0 }
  577. #output ul {
  578. list-style-type:circle;
  579. }
  580. #output ul li{
  581. display:list-item;
  582. list-style:circle;
  583. margin:0 auto;
  584. font-size:.4em;
  585. line-height:1em;
  586. text-align:center;
  587. }
  588. #listcont{
  589. width:50%;
  590. margin:0 auto;
  591. }
  592. #mainhead{
  593. font-size:1.5em;
  594. margin-bottom:15px;
  595. }
  596. .checklist{
  597. display:flex;
  598. }
  599. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement