-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
43 lines (32 loc) · 1009 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var erll = new ERLL()
$( '#Expression' ).value = "[name] == 'Chris' and [age] > 100 and [has_ice_cream] == false"
function onEvaluate () {
var expression = $( '#Expression' ).value
var dictionary = {
name: 'Dave',
age: 42,
has_ice_cream: true,
}
var result = null
var time = Clock.time( "ERLL", function () {
result = erll.parse( expression, dictionary )
} )
$( '#ResultOverall' ).innerText = `${ result.value ? 'Success' : 'Fail' } - ${ time }ms`
console.log(result);
if ( result.errors.length > 0 ) {
var $results = $( '#Results' )
$results.innerText = ''
var error = ''
var element = null
for ( var i = 0; i < result.errors.length; ++i ) {
error = result.errors[i]
if ( typeof error === 'string' && error.trim() !== '' ) {
element = document.createElement( 'dt' )
element.className = 'color--error';
element.innerText = error
$results.append(element)
}
element = null
}
}
}