config.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. class ConfigObject {
  2. constructor () {
  3. this.decimalPlaces = 8;
  4. this.intConvertRoundMode = 2;
  5. this.default_lang = 'pt';
  6. this.enable_type_casting = true;
  7. this.idle_input_interval = 5000;
  8. this.suspend_threshold = 100;
  9. // this.max_instruction_count = 350250; - automated evaluation limit
  10. this.max_instruction_count = Number.MAX_SAFE_INTEGER;
  11. this.programming_type = "visual";
  12. this.ui_settings = [{"name":"integer_data_type","value":"on"},
  13. {"name":"real_data_type","value":"on"},{"name":"text_data_type","value":"on"},
  14. {"name":"boolean_data_type","value":"on"},{"name":"void_data_type","value":"on"},
  15. {"name":"commands_read","value":"on"},{"name":"commands_write","value":"on"},
  16. {"name":"commands_comment","value":"on"},{"name":"commands_attribution","value":"on"},
  17. {"name":"commands_functioncall","value":"on"},{"name":"commands_iftrue","value":"on"},
  18. {"name":"commands_repeatNtimes","value":"on"},{"name":"commands_while","value":"on"},
  19. {"name":"commands_dowhile","value":"on"},{"name":"commands_switch","value":"on"},
  20. {name:"functions_creation", value: "on"},{name:"filter_active", value:"off"}];
  21. }
  22. isSettingEnabled (setting_name) {
  23. for(const setting_obj in this.ui_settings) {
  24. if(setting_obj.name == setting_name) {
  25. return setting_obj.value == "on";
  26. }
  27. }
  28. return false;
  29. }
  30. getSetting (setting_name) {
  31. for (const setting_obj in this.ui_settings) {
  32. if (setting_obj.name == setting_name) {
  33. return setting_obj.value;
  34. }
  35. }
  36. return undefined;
  37. }
  38. setSetting (setting_name, value) {
  39. for(const setting_obj in this.ui_settings) {
  40. if(setting_obj.name == setting_name) {
  41. setting_obj.value = value;
  42. return;
  43. }
  44. }
  45. this.ui_settings.push({name: setting_name, value: value});
  46. }
  47. setConfig (opts) {
  48. for (const key in opts) {
  49. if(Object.prototype.hasOwnProperty.call(this, key)){
  50. this[key] = opts[key];
  51. }
  52. }
  53. }
  54. }
  55. const config = new ConfigObject();
  56. export const Config = config;