Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_limit.jst 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. {{# def.definitions }}
  2. {{# def.errors }}
  3. {{# def.setupKeyword }}
  4. {{# def.$data }}
  5. {{## def.setExclusiveLimit:
  6. $exclusive = true;
  7. $errorKeyword = $exclusiveKeyword;
  8. $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
  9. #}}
  10. {{
  11. var $isMax = $keyword == 'maximum'
  12. , $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum'
  13. , $schemaExcl = it.schema[$exclusiveKeyword]
  14. , $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data
  15. , $op = $isMax ? '<' : '>'
  16. , $notOp = $isMax ? '>' : '<'
  17. , $errorKeyword = undefined;
  18. if (!($isData || typeof $schema == 'number' || $schema === undefined)) {
  19. throw new Error($keyword + ' must be number');
  20. }
  21. if (!($isDataExcl || $schemaExcl === undefined
  22. || typeof $schemaExcl == 'number'
  23. || typeof $schemaExcl == 'boolean')) {
  24. throw new Error($exclusiveKeyword + ' must be number or boolean');
  25. }
  26. }}
  27. {{? $isDataExcl }}
  28. {{
  29. var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr)
  30. , $exclusive = 'exclusive' + $lvl
  31. , $exclType = 'exclType' + $lvl
  32. , $exclIsNumber = 'exclIsNumber' + $lvl
  33. , $opExpr = 'op' + $lvl
  34. , $opStr = '\' + ' + $opExpr + ' + \'';
  35. }}
  36. var schemaExcl{{=$lvl}} = {{=$schemaValueExcl}};
  37. {{ $schemaValueExcl = 'schemaExcl' + $lvl; }}
  38. var {{=$exclusive}};
  39. var {{=$exclType}} = typeof {{=$schemaValueExcl}};
  40. if ({{=$exclType}} != 'boolean' && {{=$exclType}} != 'undefined' && {{=$exclType}} != 'number') {
  41. {{ var $errorKeyword = $exclusiveKeyword; }}
  42. {{# def.error:'_exclusiveLimit' }}
  43. } else if ({{# def.$dataNotType:'number' }}
  44. {{=$exclType}} == 'number'
  45. ? (
  46. ({{=$exclusive}} = {{=$schemaValue}} === undefined || {{=$schemaValueExcl}} {{=$op}}= {{=$schemaValue}})
  47. ? {{=$data}} {{=$notOp}}= {{=$schemaValueExcl}}
  48. : {{=$data}} {{=$notOp}} {{=$schemaValue}}
  49. )
  50. : (
  51. ({{=$exclusive}} = {{=$schemaValueExcl}} === true)
  52. ? {{=$data}} {{=$notOp}}= {{=$schemaValue}}
  53. : {{=$data}} {{=$notOp}} {{=$schemaValue}}
  54. )
  55. || {{=$data}} !== {{=$data}}) {
  56. var op{{=$lvl}} = {{=$exclusive}} ? '{{=$op}}' : '{{=$op}}=';
  57. {{
  58. if ($schema === undefined) {
  59. $errorKeyword = $exclusiveKeyword;
  60. $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
  61. $schemaValue = $schemaValueExcl;
  62. $isData = $isDataExcl;
  63. }
  64. }}
  65. {{??}}
  66. {{
  67. var $exclIsNumber = typeof $schemaExcl == 'number'
  68. , $opStr = $op; /*used in error*/
  69. }}
  70. {{? $exclIsNumber && $isData }}
  71. {{ var $opExpr = '\'' + $opStr + '\''; /*used in error*/ }}
  72. if ({{# def.$dataNotType:'number' }}
  73. ( {{=$schemaValue}} === undefined
  74. || {{=$schemaExcl}} {{=$op}}= {{=$schemaValue}}
  75. ? {{=$data}} {{=$notOp}}= {{=$schemaExcl}}
  76. : {{=$data}} {{=$notOp}} {{=$schemaValue}} )
  77. || {{=$data}} !== {{=$data}}) {
  78. {{??}}
  79. {{
  80. if ($exclIsNumber && $schema === undefined) {
  81. {{# def.setExclusiveLimit }}
  82. $schemaValue = $schemaExcl;
  83. $notOp += '=';
  84. } else {
  85. if ($exclIsNumber)
  86. $schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema);
  87. if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
  88. {{# def.setExclusiveLimit }}
  89. $notOp += '=';
  90. } else {
  91. $exclusive = false;
  92. $opStr += '=';
  93. }
  94. }
  95. var $opExpr = '\'' + $opStr + '\''; /*used in error*/
  96. }}
  97. if ({{# def.$dataNotType:'number' }}
  98. {{=$data}} {{=$notOp}} {{=$schemaValue}}
  99. || {{=$data}} !== {{=$data}}) {
  100. {{?}}
  101. {{?}}
  102. {{ $errorKeyword = $errorKeyword || $keyword; }}
  103. {{# def.error:'_limit' }}
  104. } {{? $breakOnError }} else { {{?}}