- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
// Define the man site module
define(function(require) {
// Require function that runs when button is clicked
var run = require('./run').run;
// Where the application starts its work
var genTextButton = document.getElementById("button-gen-text");
genTextButton.onclick = run;
});
define(function(require) {
// Require value error
var ValueError = require('./errors/value_errors').ValueError;
// Require EmptyListError
var EmptyListError = require('./errors/property_errors').EmptyListError;
// Require functions that returns data for text generation
var getData = require('./utils/get_data');
var getTextLength = getData.getTextLength;
var getTemplateList = getData.getTemplateList;
var getWordList = getData.getWordList;
var getStyleOption = getData.getStyleOption;
// Require function for setting output text
var makeText = require('./utils/set_text');
// Require function for validating form and validate form
var validateForm = require('./utils/validateForm');
validateForm({
formId : 'form-text-gen',
inputErrorClass : 'input-error',
formInvalidClass : 'form-invalid'
});
// Runs tasks for text generation
var run = function() {
try {
var textLength = getTextLength();
var templateList = getTemplateList();
var wordList = getWordList();
var styleOption = getStyleOption();
makeText({
styleOption : styleOption,
textLength : textLength,
templateList : templateList,
wordList : wordList
});
} catch (error) {
if (error instanceof ValueError) {
console.log(error.stack);
} else if (error instanceof EmptyListError) {
console.log(error.stack);
} else {
throw error;
}
}
}
return {
run : run
}
});
JaneBurt 08.05.2021 01:18 # +1
guest6 08.05.2021 01:25 # +1
ES6, прийди