Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle-qtype_stack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle-qtype_stack
Commits
8857295b
Commit
8857295b
authored
1 year ago
by
Tim Lutz
Browse files
Options
Downloads
Patches
Plain Diff
FIX: GeoGebra in STACK with STACKJS
disabling 2-way binding
parent
558fa1d5
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
corsscripts/stackgeogebra.js
+10
-136
10 additions, 136 deletions
corsscripts/stackgeogebra.js
with
10 additions
and
136 deletions
corsscripts/stackgeogebra.js
+
10
−
136
View file @
8857295b
...
...
@@ -35,48 +35,19 @@ export const stack_geogebra = {
var
tmp
=
JSON
.
stringify
([
pointx
,
pointy
]);
initialX
=
false
;
// ignore these after initial change.
initialY
=
false
;
// Avoid event when some of the coords are not valid numbers.
if
(
theInput
.
value
!=
tmp
)
{
// Avoid resetting this, as some event models mig
t
h trigger
// Avoid resetting this, as some event models migh
t
trigger
// change events even when no change actually happens.
if
(
pointx
!=
null
&&
!
Number
.
isNaN
(
pointx
)
&&
pointy
!=
null
&&
!
Number
.
isNaN
(
pointy
)){
theInput
.
value
=
tmp
;
var
e
=
new
Event
(
'
change
'
);
theInput
.
dispatchEvent
(
e
);
}
}
}
setInterval
(
updateValues
,
300
);
//time based listening is the only option because we can not listen to single objects
var
lastValue
=
JSON
.
stringify
([
appletRef
.
getXcoord
(
pointname
),
appletRef
.
getYcoord
(
pointname
)]);
// Then from input to graph. 'input' for live stuff and 'change' for other.
theInput
.
addEventListener
(
'
input
'
,
function
()
{
if
(
theInput
.
value
!=
lastValue
)
{
// Only when something changed.
try
{
var
tmp
=
JSON
.
parse
(
theInput
.
value
);
if
(
typeof
tmp
[
0
]
==
'
number
'
&&
typeof
tmp
[
1
]
==
'
number
'
)
{
appletRef
.
setCoords
(
pointname
,
tmp
);
}
}
catch
(
err
)
{
// We do not care about this.
}
lastValue
=
theInput
.
value
;
}
});
theInput
.
addEventListener
(
'
change
'
,
function
()
{
if
(
theInput
.
value
!=
lastValue
)
{
// Only when something changed.
try
{
var
tmp
=
JSON
.
parse
(
theInput
.
value
);
if
(
typeof
tmp
[
0
]
==
'
number
'
&&
typeof
tmp
[
1
]
==
'
number
'
)
{
appletRef
.
setCoords
(
pointname
,
tmp
);
}
}
catch
(
err
)
{
// We do not care about this.
}
lastValue
=
theInput
.
value
;
}
});
setInterval
(
updateValues
,
300
);
//time based listening is the only option because we can not listen to single objects
},
bind_value
:
function
(
inputRef
,
appletRef
,
valuename
)
{
// This function takes a GeoGebra name of a value object and binds its value to a given input.
...
...
@@ -103,7 +74,7 @@ export const stack_geogebra = {
}
if
(
movedInitial
)
{
var
tmp
=
JSON
.
stringify
(
appletRef
.
getValue
(
valuename
));
if
(
theInput
.
value
!=
tmp
)
{
if
(
theInput
.
value
!=
tmp
&&
tmp
!=
null
&&
typeof
tmp
===
"
number
"
&&
!
Number
.
isNaN
(
tmp
)
)
{
// Avoid resetting this, as some event models might trigger
// change events even when no change actually happens.
theInput
.
value
=
tmp
;
...
...
@@ -113,38 +84,6 @@ export const stack_geogebra = {
}
}
setInterval
(
updateValues
,
300
);
//time based listening is the only option because we can not listen to single objects
var
lastValue
=
JSON
.
stringify
(
appletRef
.
getValue
(
valuename
));
// Then from input to graph. 'input' for live stuff and 'change' for other.
theInput
.
addEventListener
(
'
input
'
,
function
()
{
if
(
theInput
.
value
!==
lastValue
)
{
// Only when something changed.
try
{
var
tmp
=
JSON
.
parse
(
theInput
.
value
);
if
(
typeof
tmp
==
'
number
'
)
{
appletRef
.
setValue
(
valuename
,
tmp
);
}
}
catch
(
err
)
{
// We do not care about this.
}
lastValue
=
theInput
.
value
;
}
});
theInput
.
addEventListener
(
'
change
'
,
function
()
{
if
(
theInput
.
value
!==
lastValue
)
{
// Only when something changed.
try
{
var
tmp
=
JSON
.
parse
(
theInput
.
value
);
if
(
typeof
tmp
==
'
number
'
)
{
appletRef
.
setValue
(
valuename
,
tmp
);
}
}
catch
(
err
)
{
// We do not care about this.
}
lastValue
=
theInput
.
value
;
}
});
},
bind_value_to_remember_JSON
:
function
(
inputRef
,
appletRef
,
valuename
)
{
//This function takes a GeoGebra name of a value object and binds its value to a given input.
...
...
@@ -201,38 +140,6 @@ export const stack_geogebra = {
}
}
setInterval
(
updateValues
,
300
);
//time based listening is the only option because we can not listen to single objects
var
lastValue
=
JSON
.
stringify
(
appletRef
.
getValue
(
valuename
));
// Then from input to graph. 'input' for live stuff and 'change' for other.
theInput
.
addEventListener
(
'
input
'
,
function
()
{
try
{
var
tmp
=
JSON
.
parse
(
theInput
.
value
);
if
(
JSON
.
stringify
(
tmp
[
valuename
])
!==
lastValue
)
{
// Only when something changed.
if
(
typeof
tmp
[
valuename
]
==
'
number
'
)
{
appletRef
.
setValue
(
valuename
,
tmp
[
valuename
]);
}
}
lastValue
=
JSON
.
stringify
(
tmp
[
valuename
]);
}
catch
(
err
)
{
// We do not care about this.
}
});
theInput
.
addEventListener
(
'
change
'
,
function
()
{
try
{
var
tmp
=
JSON
.
parse
(
theInput
.
value
);
if
(
tmp
[
valuename
]
!==
lastValue
)
{
// Only when something changed.
if
(
typeof
tmp
[
valuename
]
==
'
number
'
)
{
appletRef
.
setValue
(
valuename
,
tmp
[
valuename
]);
}
lastValue
=
JSON
.
stringify
(
tmp
[
valuename
]);
}
}
catch
(
err
){
// We do not care about this.
}
});
},
bind_point_to_remember_JSON
:
function
(
inputRef
,
appletRef
,
pointname
)
{
// This function takes a GeoGebra point object and binds its coordinates to a given STACK input.
...
...
@@ -293,40 +200,7 @@ export const stack_geogebra = {
}
}
setInterval
(
updateValues
,
300
);
//time based listening is the only option because we can not listen to single objects
var
lastValue
=
JSON
.
stringify
([
appletRef
.
getXcoord
(
pointname
),
appletRef
.
getYcoord
(
pointname
)]);
// Then from input to graph. 'input' for live stuff and 'change' for other.
theInput
.
addEventListener
(
'
input
'
,
function
()
{
try
{
var
tmp
=
JSON
.
parse
(
theInput
.
value
);
if
(
JSON
.
stringify
(
tmp
[
pointname
])
!==
lastValue
)
{
// Only when something changed.
if
(
typeof
tmp
[
pointname
][
0
]
==
'
number
'
&&
typeof
tmp
[
pointname
][
1
]
==
'
number
'
)
{
appletRef
.
setCoords
(
pointname
,
tmp
[
pointname
]);
}
lastValue
=
JSON
.
stringify
(
tmp
[
pointname
]);
}
}
catch
(
err
)
{
// We do not care about this.
}
});
theInput
.
addEventListener
(
'
change
'
,
function
()
{
try
{
var
tmp
=
JSON
.
parse
(
theInput
.
value
);
if
(
JSON
.
stringify
(
tmp
[
pointname
])
!==
lastValue
)
{
// Only when something changed.
if
(
typeof
tmp
[
pointname
][
0
]
==
'
number
'
&&
typeof
tmp
[
pointname
][
1
]
==
'
number
'
)
{
appletRef
.
setCoords
(
pointname
,
tmp
[
pointname
]);
}
lastValue
=
JSON
.
stringify
(
tmp
[
pointname
]);
}
}
catch
(
err
){
// We do not care about this.
}
});
}
};
export
default
stack_geogebra
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment