Minor ES6 improvements
Change-Id: Ibf956915d1b7769dc5cc22a870f4484f492da723
diff --git a/dev/js/src/buttongroup.js b/dev/js/src/buttongroup.js
index cb6a95c..6da1cb7 100644
--- a/dev/js/src/buttongroup.js
+++ b/dev/js/src/buttongroup.js
@@ -78,8 +78,8 @@
*
* Returns the list object.
*/
- addList : function (title, classes, itemClass) {
- var list = treeMenuClass.create([], itemClass || defaultItemClass);
+ addList : function (title, classes, itemClass = defaultItemClass) {
+ var list = treeMenuClass.create([], itemClass);
this.add(title, classes, function (e) {
list.show();
list.button(this.button);
diff --git a/dev/js/src/hint/foundries.js b/dev/js/src/hint/foundries.js
index f37cb7d..256ee76 100644
--- a/dev/js/src/hint/foundries.js
+++ b/dev/js/src/hint/foundries.js
@@ -16,7 +16,8 @@
if (!anno)
return;
- if (value.indexOf(':') < 0) {
+ // if (value.indexOf(':') < 0) {
+ if (!value.includes(':')) {
value += ' ';
// Iterate over all annotations and add the descriptions
diff --git a/dev/js/src/match/table.js b/dev/js/src/match/table.js
index 4f8abcc..969de77 100644
--- a/dev/js/src/match/table.js
+++ b/dev/js/src/match/table.js
@@ -121,7 +121,8 @@
found[foundry + "/" + layer] = [value];
}
else {
- if (found[foundry + "/" + layer].indexOf(value) === -1) {
+ // if (found[foundry + "/" + layer].indexOf(value) === -1) {
+ if (!found[foundry + "/" + layer].includes(value)) {
// Push value to foundry/layer at correct position
found[foundry + "/" + layer].push(value);
};
diff --git a/dev/js/src/menu.js b/dev/js/src/menu.js
index 9f3cf75..1685da5 100644
--- a/dev/js/src/menu.js
+++ b/dev/js/src/menu.js
@@ -222,12 +222,14 @@
var prefix = " " + prefixList[pref];
// Check if it matches at the beginning
- if ((this.item(pos).lcField().indexOf(prefix)) >= 0) {
+ // if ((this.item(pos).lcField().indexOf(prefix)) >= 0) {
+ if ((this.item(pos).lcField().includes(prefix))) {
points += 5;
}
// Check if it matches anywhere
- else if ((this.item(pos).lcField().indexOf(prefix.substring(1))) >= 0) {
+ // else if ((this.item(pos).lcField().indexOf(prefix.substring(1))) >= 0) {
+ else if ((this.item(pos).lcField().includes(prefix.substring(1)))) {
points += 1;
};
};
diff --git a/dev/js/src/panel.js b/dev/js/src/panel.js
index c2c2293..498a7f1 100644
--- a/dev/js/src/panel.js
+++ b/dev/js/src/panel.js
@@ -8,14 +8,14 @@
// TODO:
// Support classes
- create : function (viewpos) {
+ create : function (viewpos = 'up') {
return Object.create(this)._init(viewpos);
},
_init : function (viewpos) {
this.views = [];
- this._viewpos = (viewpos == 'down' ? viewpos : 'up');
+ this._viewpos = viewpos;
/**
diff --git a/dev/js/src/session.js b/dev/js/src/session.js
index 27af76d..2211fe6 100644
--- a/dev/js/src/session.js
+++ b/dev/js/src/session.js
@@ -9,10 +9,8 @@
* Create a new session.
* Expects a name or defaults to 'korap'
*/
- create : function (name) {
+ create : function (name = 'korap') {
var obj = Object.create(this);
- if (name === undefined)
- name = 'korap';
obj._name = name.toLowerCase();
obj._hash = {};
obj._parse();