MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / set

Function set

lib/web/drags.js:466–505  ·  view source on GitHub ↗
(o, p, x)

Source from the content-addressed store, hash-verified

464 return val;
465 };
466 var set = function (o, p, x) {
467 // update in animation?
468
469 console.log(" x-p = " + (x - p));
470
471 var s = start.find()
472 var e = end.find()
473
474 var text = cm.getDoc().getRange(s, e)
475
476 var currentDP = numDP(text);
477
478 var nextVal = "" + (parseFloat(text) + 4 * (Math.abs(parseFloat(text)) + Math.pow(10, -currentDP)) * (x - p)).toFixed(Math.max(2, currentDP - 1))
479
480 while (numDP(nextVal) > currentDP && nextVal.charAt(nextVal.length - 1) == '0')
481 nextVal = nextVal.substring(0, nextVal.length - 1)
482
483 console.log(nextVal);
484 console.log(s);
485 console.log(e);
486
487 nextVal = "" + nextVal
488 text = "" + text
489
490 if (nextVal.endsWith(".") && !text.endsWith(".")) nextVal = nextVal.substring(0, nextVal.length - 1);
491
492
493
494 if (text != nextVal) {
495 cm.getDoc().replaceRange(nextVal, s, e);
496
497 var f = findEnclosingPathForLine(onWord.line);
498 if (f != null) {
499 executeBracket(f, true)
500 }
501 }
502
503 val = x;
504 return val;
505 };
506
507 var up = function () {
508 return 0.5;

Callers 3

polyfill.jsFile · 0.70
getCollectionFunction · 0.70
EnumerateFunction · 0.70

Calls 8

numDPFunction · 0.85
findEnclosingPathForLineFunction · 0.85
executeBracketFunction · 0.85
logMethod · 0.80
replaceRangeMethod · 0.80
findMethod · 0.45
getRangeMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected