fc1c8034 by Jeremy Groot

fix to postal code lookup tool

1 parent 484c3dfc
1 /*! 1 /*!
2 * Understrap v1.2.2 (https://understrap.com) 2 * Understrap v1.2.2 (https://understrap.com)
3 * Copyright 2013-2023 The UnderStrap Authors (https://github.com/understrap/understrap/graphs/contributors) 3 * Copyright 2013-2024 The UnderStrap Authors (https://github.com/understrap/understrap/graphs/contributors)
4 * Licensed under GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) 4 * Licensed under GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
5 */ 5 */
6 (function (global, factory) { 6 (function (global, factory) {
...@@ -24553,9 +24553,9 @@ ...@@ -24553,9 +24553,9 @@
24553 // shouldSort: true, 24553 // shouldSort: true,
24554 // includeMatches: false, 24554 // includeMatches: false,
24555 // findAllMatches: false, 24555 // findAllMatches: false,
24556 // minMatchCharLength: 1, 24556 minMatchCharLength: 3,
24557 // location: 0, 24557 // location: 0,
24558 threshold: 0.2, 24558 threshold: 0.0,
24559 // distance: 100, 24559 // distance: 100,
24560 // useExtendedSearch: false, 24560 // useExtendedSearch: false,
24561 // ignoreLocation: false, 24561 // ignoreLocation: false,
...@@ -24595,14 +24595,20 @@ ...@@ -24595,14 +24595,20 @@
24595 if ($(this).val().length < 3) { 24595 if ($(this).val().length < 3) {
24596 $('.preferred').val(''); 24596 $('.preferred').val('');
24597 } else { 24597 } else {
24598 var results = fuse.search($(this).val()); 24598 $('.preferred').val('NOT KNOWN');
24599 for (var i = 0; i < results.length; ++i) { 24599 var search_val = $(this).val().replace(/ /g, '');
24600 if (results[i].item['PREFERRED'] == 'YES') { 24600 var results = fuse.search(search_val);
24601 $('.preferred').val('YES'); 24601 if (results.length <= 3) {
24602 } else if (results[i].item['PREFERRED'] == 'NO') { 24602 console.log("LENGTH == " + results.length);
24603 $('.preferred').val('NO'); 24603 for (var i = 0; i < results.length; ++i) {
24604 } else { 24604 if (results[i].item['PREFERRED'] == 'YES') {
24605 $('.preferred').val('NOT AVAILABLE'); 24605 console.log(results[i].item);
24606 $('.preferred').val('YES');
24607 } else if (results[i].item['PREFERRED'] == 'NO') {
24608 $('.preferred').val('NO');
24609 } else {
24610 $('.preferred').val('NOT AVAILABLE');
24611 }
24606 } 24612 }
24607 } 24613 }
24608 } 24614 }
......
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
...@@ -3,6 +3,7 @@ import Fuse from 'fuse.js' ...@@ -3,6 +3,7 @@ import Fuse from 'fuse.js'
3 3
4 (function( $ ) { 4 (function( $ ) {
5 5
6
6 var list = JSON.parse($('.postal-search-data').val()); 7 var list = JSON.parse($('.postal-search-data').val());
7 8
8 const fuseOptions = { 9 const fuseOptions = {
...@@ -11,9 +12,9 @@ import Fuse from 'fuse.js' ...@@ -11,9 +12,9 @@ import Fuse from 'fuse.js'
11 // shouldSort: true, 12 // shouldSort: true,
12 // includeMatches: false, 13 // includeMatches: false,
13 // findAllMatches: false, 14 // findAllMatches: false,
14 // minMatchCharLength: 1, 15 minMatchCharLength: 3,
15 // location: 0, 16 // location: 0,
16 threshold: 0.2, 17 threshold: 0.0,
17 // distance: 100, 18 // distance: 100,
18 // useExtendedSearch: false, 19 // useExtendedSearch: false,
19 // ignoreLocation: false, 20 // ignoreLocation: false,
...@@ -58,18 +59,29 @@ import Fuse from 'fuse.js' ...@@ -58,18 +59,29 @@ import Fuse from 'fuse.js'
58 $('.preferred').val(''); 59 $('.preferred').val('');
59 } else { 60 } else {
60 61
61 var results = fuse.search($(this).val()); 62 $('.preferred').val('NOT KNOWN');
63
64 var search_val = $(this).val().replace(/ /g,'');
62 65
63 for(var i = 0;i < results.length;++i) { 66 var results = fuse.search(search_val);
67 if(results.length <= 3) {
68 console.log("LENGTH == " + results.length);
69 for(var i = 0;i < results.length;++i) {
64 70
65 if(results[i].item['PREFERRED'] == 'YES') { 71
66 $('.preferred').val('YES'); 72 if(results[i].item['PREFERRED'] == 'YES') {
67 } else if(results[i].item['PREFERRED'] == 'NO') { 73 console.log(results[i].item);
68 $('.preferred').val('NO'); 74 $('.preferred').val('YES');
69 } else { 75 } else if(results[i].item['PREFERRED'] == 'NO') {
70 $('.preferred').val('NOT AVAILABLE'); 76 $('.preferred').val('NO');
71 } 77 } else {
78 $('.preferred').val('NOT AVAILABLE');
79 }
80
72 } 81 }
82
83
84 }
73 85
74 } 86 }
75 87
......
...@@ -66,7 +66,7 @@ function theme_broker_enqueue_scripts() ...@@ -66,7 +66,7 @@ function theme_broker_enqueue_scripts()
66 // } 66 // }
67 67
68 // wp_enqueue_script('icheck', get_bloginfo('template_url') . '/scripts/icheck.min.js', [], "0.0.1", true); 68 // wp_enqueue_script('icheck', get_bloginfo('template_url') . '/scripts/icheck.min.js', [], "0.0.1", true);
69 wp_enqueue_script('main-js', get_bloginfo('template_url') . '/dev/js/theme.min.js?v=1.12', [], filemtime(get_bloginfo('template_url') . '/dev/js/theme.min.js'), true); 69 wp_enqueue_script('main-js', get_bloginfo('template_url') . '/dev/js/theme.min.js?v=1.1611', [], filemtime(get_bloginfo('template_url') . '/dev/js/theme.min.js'), true);
70 // wp_enqueue_script('script', get_bloginfo('template_url') . '/scripts/script.js', [], "0.0.12", true); 70 // wp_enqueue_script('script', get_bloginfo('template_url') . '/scripts/script.js', [], "0.0.12", true);
71 wp_enqueue_style('main-css', get_bloginfo('template_url') . '/dev/css/theme.min.css?v=1.1', [], filemtime(get_bloginfo('template_url') . '/dev/css/theme.min.css')); 71 wp_enqueue_style('main-css', get_bloginfo('template_url') . '/dev/css/theme.min.css?v=1.1', [], filemtime(get_bloginfo('template_url') . '/dev/css/theme.min.css'));
72 72
......