-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
114 lines (103 loc) · 4.13 KB
/
index.html
1
2
3
4
5
6
7
8
9
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
</head>
<body>
<div class="container" id="addDiv">
<br>
<h4 align="center">Please fill the form</h4>
<form method="post" v-on:submit.prevent="handleSubmit($event);">
<div class="form-group">
<label for="college">Name</label>
<input type="text" class="form-control" id="name" name="name" v-model="name" required="" v-transliterate="options">
</div>
<div class="form-group">
<label for="department">Department</label>
<input type="text" class="form-control" id="department" name="department" v-model="department" required="" v-transliterate="options">
</div>
<div class="form-group">
<label for="college">Address</label>
<textarea rows="5" class="form-control" id="college" name="address" v-model="address" required="" v-transliterate="options"></textarea>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
<script>
// Load the Google Transliterate API
google.load("elements", "1", {
packages: "transliteration"
});
Vue.directive('transliterate', function (el, binding) {
var control = new google.elements.transliteration.TransliterationControl(binding.value);
// a getter for each property google transliterate reads and a setter for each it modifies
var inputOrTextareaProxy = {
get getAttribute() { return el.getAttribute.bind(el); },
get addEventListener() { return el.addEventListener.bind(el); },
get resize() { return el.resize.bind(el); },
get blur() { return el.blur.bind(el); },
get focus() { return el.focus.bind(el); },
get tagName() { return el.tagName; },
//get type() { return el.type; },
//get id() { return el.id; },
//get style() { return el.style; },
get selectionStart() { return el.selectionStart; },
get selectionEnd() { return el.selectionEnd; },
get value() { return el.value; },
set value(v) { el.value = v; el.dispatchEvent(new CustomEvent('input')); },
//get nodeType() { return el.nodeType; },
//get ownerDocument() { return el.ownerDocument; },
//get scrollTop() { return el.scrollTop; },
//set scrollTop(v) { el.scrollTop = v; }
};
control.makeTransliteratable([inputOrTextareaProxy]);
});
</script>
<script>
addDiv = new Vue({
el: "#addDiv",
data: {
name: '',
address:'',
department:'',
options: {
sourceLanguage: google.elements.transliteration.LanguageCode.ENGLISH,
destinationLanguage: [google.elements.transliteration.LanguageCode.MALAYALAM],
shortcutKey: 'ctrl+g',
transliterationEnabled: true
}
},
methods: {
handleSubmit: function(e) {
var vm = this;
data = {};
data['name'] = this.name;
data['department'] = this.department;
data['address'] = this.address;
$.ajax({
url: 'your url here',
data: data,
type: "POST",
dataType: 'json',
success: function(e) {
if (e.status)
{
vm.response = e;
alert("success")
}
else {
vm.response = e;
console.log(vm.response);
alert("Registration Failed")
}
}
});
return false;
},
},
});
</script>
</body>
</html>