Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
encyclopedia-gui
Commits
8a16f595
Commit
8a16f595
authored
Sep 11, 2018
by
Iker Hurtado
Browse files
convenience commit
parent
d1dcb01a
Changes
3
Hide whitespace changes
Inline
Side-by-side
client/bundle.js
View file @
8a16f595
...
...
@@ -7638,6 +7638,7 @@
let
MaterialList
=
__webpack_require__
(
35
);
//let PropertiesBox = require('./PropertiesBox.view.js');
let
FilterPanel
=
__webpack_require__
(
36
);
let
SwitchComponent
=
__webpack_require__
(
13
);
...
...
@@ -7695,8 +7696,7 @@
<button class="name-add-btn" >Name</button>
</div>
<div class="bool-buttons" style="width: 28%; display: inline-block" >
<button disabled >AND</button>
<button disabled >OR</button>
OR <span id="and-or-switch" ></span> AND
<button disabled >NOT</button>
<button disabled >(</button> <button disabled >)</button>
<!--<input type="checkbox" name="and-or" class="not-symbol-btn" />NOT-->
...
...
@@ -7734,6 +7734,9 @@
this
.
addPanel
=
this
.
element
.
querySelector
(
'
.add-panel
'
);
let
andOrSwitch
=
new
SwitchComponent
(
util
.
IMAGE_DIR
+
'
switch
'
);
this
.
element
.
querySelector
(
'
#and-or-switch
'
).
appendChild
(
andOrSwitch
.
element
);
this
.
elementTable
=
new
ElementTable
();
this
.
elementTable
.
setClickListener
(
elementArray
=>
{
this
.
addElementsInSearchQuery
(
elementArray
);
...
...
@@ -7817,8 +7820,7 @@
//else
let
esMatchQuery
;
if
(
this
.
formulaBox
.
getMultiplesOfFormula
()){
esMatchQuery
=
this
.
_getESSimpleMatch
(
'
formula_reduced
'
,
item
);
this
.
_reduceFormula
(
item
);
esMatchQuery
=
this
.
_getESSimpleMatch
(
'
formula_reduced
'
,
this
.
_reduceFormula
(
item
));
}
else
esMatchQuery
=
this
.
_getESSimpleMatch
(
'
formula
'
,
item
);
queryObj
.
bool
.
filter
.
push
(
esMatchQuery
);
...
...
@@ -7986,7 +7988,7 @@
let
map
=
new
Map
();
let
key
;
while
(
index
<
formula
.
length
){
console
.
log
(
'
_reduceFormula index
'
,
index
);
//
console.log('_reduceFormula index', index);
let
el2
=
formula
.
substring
(
index
,
index
+
2
);
let
el1
=
formula
.
substring
(
index
,
index
+
1
);
...
...
@@ -7994,30 +7996,24 @@
map
.
set
(
el2
,
1
);
// 1 default value
index
+=
2
;
key
=
el2
;
console
.
log
(
'
eleemnt 2chars
'
,
key
);
//
console.log('eleemnt 2chars', key);
}
else
if
(
util
.
ELEMENTS
.
indexOf
(
el1
)
>=
0
){
map
.
set
(
el1
,
1
);
// 1 default value
index
++
;
key
=
el1
;
console
.
log
(
'
eleemnt 1chars
'
,
key
);
//
console.log('eleemnt 1chars', key);
}
else
{
// It's a number
// ************ parseInt(el2)
let
num
=
parseInt
(
el2
);
//console.log('parsed number ', el2, num);
if
(
num
>=
10
){
// 2 figures number
index
+=
2
;
}
else
{
// 1 figure number
index
++
;
}
console
.
log
(
'
number
'
,
num
,
key
);
if
(
num
>=
10
)
index
+=
2
;
// 2 figures number
else
index
++
;
// 1 figure number
//console.log('number ', num, key);
map
.
set
(
key
,
num
);
}
console
.
log
(
'
FINAL LOOP
'
,
map
,
index
);
//
console.log('FINAL LOOP', map, index);
}
let
counter
=
0
;
while
(
!
checkIfReduced
(
map
)
){
console
.
log
(
'
Reducing
'
,
map
);
while
(
!
checkIfReduced
(
map
)
){
// console.log('Reducing', map);
let
div
=
1
;
if
(
isDivisibleBy
(
map
,
2
))
div
=
2
;
else
if
(
isDivisibleBy
(
map
,
3
))
div
=
3
;
...
...
@@ -8026,11 +8022,9 @@
else
if
(
isDivisibleBy
(
map
,
11
))
div
=
11
;
map
.
forEach
(
(
value
,
key
)
=>
{
value
=
value
/
div
;
map
.
set
(
key
,
(
value
/
div
));
});
console
.
log
(
'
Reducing DIV
'
,
map
);
//console.log('Reducing DIV', map);
counter
++
;
if
(
counter
>
5
)
break
;
}
...
...
@@ -8050,8 +8044,13 @@
});
return
div
;
}
//console.log('_reduceFormula', map);
return
formula
;
let
newFormula
=
''
;
map
.
forEach
(
(
value
,
key
)
=>
{
newFormula
+=
key
+
(
value
===
1
?
''
:
value
);
});
console
.
log
(
'
_reduceFormula RETURN:
'
,
map
,
newFormula
);
return
newFormula
;
}
...
...
@@ -9120,6 +9119,16 @@
} `;
*/
postQuery
=
`
{
"bool" : {
"should" : [
{"match":{"formula":"H4O2"}},
{"match":{"atom_labels":"Sc"}}
]
}
} `
;
console
.
log
(
'
SENDING:
'
,
postQuery
);
...
...
client/src/search-mod/MaterialList.view.js
View file @
8a16f595
...
...
@@ -140,6 +140,16 @@ class MaterialList {
} `;
*/
postQuery
=
`
{
"bool" : {
"should" : [
{"match":{"formula":"H4O2"}},
{"match":{"atom_labels":"Sc"}}
]
}
} `
;
console
.
log
(
'
SENDING:
'
,
postQuery
);
...
...
client/src/search-mod/NewSearchMod.js
View file @
8a16f595
...
...
@@ -31,6 +31,7 @@ let ElementTable = require('./ElemenTable.view.js');
let
MaterialList
=
require
(
'
./MaterialList.view.js
'
);
//let PropertiesBox = require('./PropertiesBox.view.js');
let
FilterPanel
=
require
(
'
./FilterPanel.view.js
'
);
let
SwitchComponent
=
require
(
'
../common/SwitchComponent.js
'
);
...
...
@@ -88,8 +89,7 @@ class NewSearchMod {
<button class="name-add-btn" >Name</button>
</div>
<div class="bool-buttons" style="width: 28%; display: inline-block" >
<button disabled >AND</button>
<button disabled >OR</button>
OR <span id="and-or-switch" ></span> AND
<button disabled >NOT</button>
<button disabled >(</button> <button disabled >)</button>
<!--<input type="checkbox" name="and-or" class="not-symbol-btn" />NOT-->
...
...
@@ -127,6 +127,9 @@ class NewSearchMod {
this
.
addPanel
=
this
.
element
.
querySelector
(
'
.add-panel
'
);
let
andOrSwitch
=
new
SwitchComponent
(
util
.
IMAGE_DIR
+
'
switch
'
);
this
.
element
.
querySelector
(
'
#and-or-switch
'
).
appendChild
(
andOrSwitch
.
element
);
this
.
elementTable
=
new
ElementTable
();
this
.
elementTable
.
setClickListener
(
elementArray
=>
{
this
.
addElementsInSearchQuery
(
elementArray
);
...
...
@@ -210,8 +213,7 @@ class NewSearchMod {
//else
let
esMatchQuery
;
if
(
this
.
formulaBox
.
getMultiplesOfFormula
()){
esMatchQuery
=
this
.
_getESSimpleMatch
(
'
formula_reduced
'
,
item
);
this
.
_reduceFormula
(
item
);
esMatchQuery
=
this
.
_getESSimpleMatch
(
'
formula_reduced
'
,
this
.
_reduceFormula
(
item
));
}
else
esMatchQuery
=
this
.
_getESSimpleMatch
(
'
formula
'
,
item
);
queryObj
.
bool
.
filter
.
push
(
esMatchQuery
);
...
...
@@ -379,7 +381,7 @@ class NewSearchMod {
let
map
=
new
Map
();
let
key
;
while
(
index
<
formula
.
length
){
console
.
log
(
'
_reduceFormula index
'
,
index
);
//
console.log('_reduceFormula index', index);
let
el2
=
formula
.
substring
(
index
,
index
+
2
);
let
el1
=
formula
.
substring
(
index
,
index
+
1
);
...
...
@@ -387,30 +389,24 @@ class NewSearchMod {
map
.
set
(
el2
,
1
);
// 1 default value
index
+=
2
;
key
=
el2
;
console
.
log
(
'
eleemnt 2chars
'
,
key
);
//
console.log('eleemnt 2chars', key);
}
else
if
(
util
.
ELEMENTS
.
indexOf
(
el1
)
>=
0
){
map
.
set
(
el1
,
1
);
// 1 default value
index
++
;
key
=
el1
;
console
.
log
(
'
eleemnt 1chars
'
,
key
);
//
console.log('eleemnt 1chars', key);
}
else
{
// It's a number
// ************ parseInt(el2)
let
num
=
parseInt
(
el2
);
//console.log('parsed number ', el2, num);
if
(
num
>=
10
){
// 2 figures number
index
+=
2
;
}
else
{
// 1 figure number
index
++
;
}
console
.
log
(
'
number
'
,
num
,
key
);
if
(
num
>=
10
)
index
+=
2
;
// 2 figures number
else
index
++
;
// 1 figure number
//console.log('number ', num, key);
map
.
set
(
key
,
num
);
}
console
.
log
(
'
FINAL LOOP
'
,
map
,
index
);
//
console.log('FINAL LOOP', map, index);
}
let
counter
=
0
;
while
(
!
checkIfReduced
(
map
)
){
console
.
log
(
'
Reducing
'
,
map
);
while
(
!
checkIfReduced
(
map
)
){
// console.log('Reducing', map);
let
div
=
1
;
if
(
isDivisibleBy
(
map
,
2
))
div
=
2
;
else
if
(
isDivisibleBy
(
map
,
3
))
div
=
3
;
...
...
@@ -419,11 +415,9 @@ class NewSearchMod {
else
if
(
isDivisibleBy
(
map
,
11
))
div
=
11
;
map
.
forEach
(
(
value
,
key
)
=>
{
value
=
value
/
div
;
map
.
set
(
key
,
(
value
/
div
));
});
console
.
log
(
'
Reducing DIV
'
,
map
);
//console.log('Reducing DIV', map);
counter
++
;
if
(
counter
>
5
)
break
;
}
...
...
@@ -443,8 +437,13 @@ class NewSearchMod {
});
return
div
;
}
//console.log('_reduceFormula', map);
return
formula
;
let
newFormula
=
''
;
map
.
forEach
(
(
value
,
key
)
=>
{
newFormula
+=
key
+
(
value
===
1
?
''
:
value
);
});
console
.
log
(
'
_reduceFormula RETURN:
'
,
map
,
newFormula
);
return
newFormula
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment