Skip to content

Commit

Permalink
1.5.1 - fix filter bug for search feature
Browse files Browse the repository at this point in the history
  • Loading branch information
earthchie committed Jul 14, 2017
1 parent 62cd637 commit 4e5f496
Show file tree
Hide file tree
Showing 21 changed files with 17 additions and 16 deletions.
Empty file modified .editorconfig
100644 → 100755
Empty file.
Empty file modified CHANGELOG.md
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion index.html
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ <h2>ใหม่! โหมดค้นหา</h2>
<script type="text/javascript" src="./jquery.Thailand.js/dependencies/JQL.min.js"></script>
<script type="text/javascript" src="./jquery.Thailand.js/dependencies/typeahead.bundle.js"></script>

<script type="text/javascript" src="./jquery.Thailand.js/dist/jquery.Thailand.min.js"></script>
<script type="text/javascript" src="./jquery.Thailand.js/src/jquery.Thailand.js"></script>

<script type="text/javascript">
/******************\
Expand Down
Empty file modified jquery.Thailand.js/database/db.json
100644 → 100755
Empty file.
Empty file modified jquery.Thailand.js/database/db.zip
100644 → 100755
Empty file.
Empty file modified jquery.Thailand.js/database/geodb.json
100644 → 100755
Empty file.
Empty file modified jquery.Thailand.js/database/geodb.zip
100644 → 100755
Empty file.
Empty file modified jquery.Thailand.js/database/raw_database/database.json
100644 → 100755
Empty file.
Empty file modified jquery.Thailand.js/database/raw_database/database.xls
100644 → 100755
Empty file.
Empty file modified jquery.Thailand.js/database/tools/convert.js
100644 → 100755
Empty file.
Empty file modified jquery.Thailand.js/database/tools/words.txt
100644 → 100755
Empty file.
Empty file modified jquery.Thailand.js/dependencies/JQL.min.js
100644 → 100755
Empty file.
Empty file modified jquery.Thailand.js/dependencies/typeahead.bundle.js
100644 → 100755
Empty file.
Empty file modified jquery.Thailand.js/dependencies/zip.js/inflate.js
100644 → 100755
Empty file.
Empty file modified jquery.Thailand.js/dependencies/zip.js/z-worker.js
100644 → 100755
Empty file.
Empty file modified jquery.Thailand.js/dependencies/zip.js/zip.js
100644 → 100755
Empty file.
Empty file modified jquery.Thailand.js/dist/jquery.Thailand.min.css
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions jquery.Thailand.js/dist/jquery.Thailand.min.js
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 13 additions & 12 deletions jquery.Thailand.js/src/jquery.Thailand.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @name jquery.Thailand.js
* @version 1.5.0
* @update Apr 20, 2017
* @version 1.5.1
* @update Jul 14, 2017
* @website https://github.com/earthchie/jquery.Thailand.js
* @license WTFPL v.2 - http://www.wtfpl.net/
*
Expand Down Expand Up @@ -285,18 +285,17 @@ $.Thailand = function (options) {
i;
try {
possibles = new JQL(possibles
.concat(DB.select('*').where('district').match(str).fetch())
.concat(DB.select('*').where('amphoe').match(str).fetch())
.concat(DB.select('*').where('province').match(str).fetch())
.concat(DB.select('*').where('zipcode').match(str).fetch())
.filter(function (self, index, parent) { // remove duplicated data
for (i = 0; i < parent.length; i = i + 1) {
if (index !== i && parent[i].amphoe === self.amphoe && parent[i].district === self.district) {
return false;
}
}
return true;
.concat(DB.select('*').where('province').match(str).fetch())
.concat(DB.select('*').where('amphoe').match(str).fetch())
.concat(DB.select('*').where('district').match(str).fetch())
.map(function(item){
return JSON.stringify(item);
}).filter(function(item, pos, self){
return self.indexOf(item) == pos;
}).map(function (self) { // give a likely score, will use to sort data later

self = JSON.parse(self);
self.likely = [
similar_text(str, self.district) * 5,
similar_text(str, self.amphoe.replace(/^เมือง/, '')) * 3,
Expand All @@ -305,7 +304,9 @@ $.Thailand = function (options) {
].reduce(function (a, b) {
return Math.max(a, b);
});

return self;

})).select('*').orderBy('likely desc').fetch();
} catch (e) {}

Expand Down
Empty file modified jquery.Thailand.js/src/jquery.Thailand.less
100644 → 100755
Empty file.

0 comments on commit 4e5f496

Please sign in to comment.