View difference between Paste ID: 2kgTk0R5 and 1rcNvWBV
SHOW: | | - or go back to the newest paste.
1
$(document).ready(function(){ 
2
var groupOne = ["い", "き", "ぎ", "し", "ち", "に", "び", "み", "り"];
3
var groupThree = ["来", "きます", "します"];
4
var exceptions = ["いき"]; //use verb stems
5
var groupThreeAndExceptions = groupThree.concat(exceptions);
6
7
function isInArray(array, search) {
8
    return array.indexOf(search) >= 0;
9
}
10-
function teConjugate(verb) {
10+
11
function teConjugate() {
12
    verb = prompt("dick", "dick");
13
    //Used in console.log.
14
    var teFormIs = "The TE form of " + verb + " is "; 
15
    
16
    function printPage (input) {
17
        $("body").append(input + "<br>");
18
    }
19
    
20
    //Print the type of verb for each type, as well as whether it is an exception or not.
21
    var g1 = "Group 1";
22-
            console.log("If your verb is a " + group + " verb:");
22+
23
    var g3 = "Group 3";
24
    var ex = "exception";
25-
            console.log("If your verb is a " + group + " " + posException + " verb:");
25+
26
        if(typeof posException === 'undefined') {
27
            printPage("If your verb is a " + group + " verb:");
28
        }
29
        else {
30
            printPage("If your verb is a " + group + " " + posException + " verb:");
31
        }
32
        }
33
34
    //Useful for Group 1 verbs.
35
    var verbStemWithoutPreMasu = verb.slice(0, -3);
36
    //Get the character before "ます" of the verb (premasu). Manipulate it using its properties and methods.
37
    var preMasu = new Object();
38-
        console.log(preMasu.old + " conjugates to " + preMasu.te + ".");
38+
39-
        console.log(teFormIs + verbStemWithoutPreMasu  + preMasu.te + ".");
39+
40
    //This method conjugates the preMasu and prints a result.
41
    preMasu.change = function (conjugation) {
42
        preMasu.te = conjugation;
43
        printPage(preMasu.old + " conjugates to " + preMasu.te + ".");
44
        printPage(teFormIs + verbStemWithoutPreMasu  + preMasu.te + ".");
45
    };
46
    
47-
        console.log(teFormIs + verbStemTe + ".");
47+
48
    var verbStem = verb.slice(0, -2);   
49
    function printVerbStemTe() {
50
        
51
        var verbStemTe = verbStem + "て";
52-
        console.log("This verb, " + verb + ", means \"" + definition + "\".");
52+
        printPage(teFormIs + verbStemTe + ".");
53
    } 
54
    
55
    //Specify what a verb means to differentiate it from a possible alternative.
56
    function specify(definition) {
57-
    console.log("Your initial input is " + verb + ".");
57+
        printPage("This verb, " + verb + ", means \"" + definition + "\".");
58-
    console.log("");
58+
59
    
60
    
61
    //What is the verb we're manipulating?
62
    printPage("Your initial input is " + verb + ".");
63
    printPage("");
64
    
65
    //Check if it's a group three verb and conjugate accordingly. 
66
    if (isInArray(groupThree, verb) || isInArray(groupThree, verbStem)){
67
        printType(g3);
68
        if(verb == "きます" || verb == "来ます") {
69
            specify("to come");
70
            printVerbStemTe();
71
            
72-
        console.log("xxx");
72+
73
        else if (verb == "します") {
74
            specify("to do");
75
            printVerbStemTe();
76
        }
77
        printPage("xxx");
78-
        console.log("The character to be conjugated is " + preMasu.old + ". ");
78+
79
    
80
    //Since group three verbs can possibly intended to be group one verbs, we start a new if block.
81
    if (isInArray(groupOne, preMasu.old)) {
82
        printType(g1);
83
        printPage("The character to be conjugated is " + preMasu.old + ". ");
84
        
85
        if (preMasu.old == "み" || preMasu.old == "に" || preMasu.old == "び") {
86
            preMasu.change("んで");
87
        }
88
        else if (preMasu.old == "い" || preMasu.old == "ち" || preMasu.old == "り") {
89
            preMasu.change("って");
90
        }
91
        else if (preMasu.old == "き") {
92
            preMasu.change("いて");
93
        }
94
        else if (preMasu.old == "ぎ") {
95-
        console.log("xxx");
95+
96
        }
97
        else if (preMasu.old == "し"){
98
            preMasu.change("して");
99
        }
100
        printPage("xxx");
101
        }
102-
        console.log("xxx");
102+
103
    //We'll assume everything else that's not group one is a group two verb. 
104
    else {
105
        printType(g2);
106
        printVerbStemTe();
107
        printPage("xxx");
108
    }
109
    
110
    //Check if the verb is possibly an exception to the usual group rules. We can add more else ifs for more exceptions and use printType and specify. Use either the group one method (preMasu.change) or the group two function printVerbStemTe accordingly.
111
       if (isInArray(exceptions, verbStem)){
112-
        console.log("xxx");
112+
113
            printType(g1, ex);
114-
    console.log("~~~");
114+
115-
    console.log("");
115+
116
        }
117
        printPage("xxx");
118-
teConjugate("いきます");
118+
119-
teConjugate("はなします");
119+
    printPage("~~~");
120-
teConjugate("します");
120+
    printPage("");
121-
teConjugate("きます");
121+
122-
teConjugate("たべます")
122+
    teConjugate();
123
})