1 | if (licenseAvailable == "!OK")
|
---|
2 | {
|
---|
3 | $('#alert-services').modal('show');
|
---|
4 | if (first_visit == '1') {
|
---|
5 | $('#alert-services').modal('show');
|
---|
6 | }
|
---|
7 | $('#alert-services').on('hidden.bs.modal', function () {
|
---|
8 | if (update_user_info == "1")
|
---|
9 | {
|
---|
10 | $('#update_user_info').modal({backdrop: 'static',keyboard: false,});
|
---|
11 | }
|
---|
12 | });
|
---|
13 | }
|
---|
14 |
|
---|
15 | if (p_period == -1 && is_overdate == 1)
|
---|
16 | {
|
---|
17 |
|
---|
18 | $('#alert-trial-services').modal('show');
|
---|
19 | $('#alert-trial-services').on('hidden.bs.modal', function () {
|
---|
20 | if (update_user_info == "1")
|
---|
21 | {
|
---|
22 | $('#update_user_info').modal({backdrop: 'static',keyboard: false,});
|
---|
23 | }
|
---|
24 | });
|
---|
25 | }
|
---|
26 |
|
---|
27 | else
|
---|
28 | {
|
---|
29 | if (licenseAvailable == "OK"){
|
---|
30 | if (update_user_info == "1")
|
---|
31 | {
|
---|
32 | $('#update_user_info').modal({backdrop: 'static'});
|
---|
33 | }
|
---|
34 | }
|
---|
35 | }
|
---|
36 |
|
---|
37 | $("#update_user_info.btn").click(function () {
|
---|
38 | $(".error").html("");
|
---|
39 | $.ajax({
|
---|
40 | url: 'user/update_info/',
|
---|
41 | type: 'POST',
|
---|
42 | data: $("#update_user_info.form").serialize(),
|
---|
43 | success: function (data, textStatus, jqXHR)
|
---|
44 | {
|
---|
45 | result = jQuery.parseJSON(data);
|
---|
46 | if (result.success == "1")
|
---|
47 | {
|
---|
48 | $('#update_user_info').modal('hide');
|
---|
49 |
|
---|
50 | }
|
---|
51 | else
|
---|
52 | {
|
---|
53 | for (var key in result.errors)
|
---|
54 | {
|
---|
55 | $("#" + result.errors[key]['field'] + ".error").html(result.errors[key]['content']);
|
---|
56 |
|
---|
57 | }
|
---|
58 | }
|
---|
59 | }
|
---|
60 | });
|
---|
61 | });
|
---|
62 |
|
---|
63 | function showModal() {
|
---|
64 | console.log('Show modal!');
|
---|
65 | $('#alert-services-package').modal('show');
|
---|
66 | //$('#alert-services-package-bk').modal('show');
|
---|
67 | }
|
---|
68 |
|
---|
69 | $('#services-reg').click(function () {
|
---|
70 | $('#alert-services').modal('hide');
|
---|
71 | window.location = url + "frontend/user/profile#services-register";
|
---|
72 | });
|
---|
73 |
|
---|
74 | $('#save-package').click(function () {
|
---|
75 | DoSaveLecture();
|
---|
76 | });
|
---|
77 |
|
---|
78 | $('#services-sign').click(function () {
|
---|
79 | $('#alert-services-reg').modal('hide');
|
---|
80 | $('#alert-services-reg-2').modal('show');
|
---|
81 | })
|
---|
82 |
|
---|
83 | var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
|
---|
84 | var g_Flash = null;
|
---|
85 | var g_cbData = "";
|
---|
86 |
|
---|
87 | function InitViolet() {
|
---|
88 | g_Flash = document.getElementById('LectorEditorOnline');
|
---|
89 | //g_Flash = $('#LectorEditorOnline');
|
---|
90 | //g_Flash = isInternetExplorer ? LectorEditorOnline : document.LectorEditorOnline;
|
---|
91 | }
|
---|
92 | ;
|
---|
93 |
|
---|
94 | function GetClipboardItem() {
|
---|
95 | var cbData = window.clipboardData ? window.clipboardData.getData('Text') : g_cbData;
|
---|
96 | g_Flash.SetVariable("clipboardData", cbData);
|
---|
97 | g_Flash.SetVariable("command", "Get Text");
|
---|
98 | }
|
---|
99 | ;
|
---|
100 |
|
---|
101 | function SetClipboardItem(args) {
|
---|
102 | if (window.clipboardData)
|
---|
103 | window.clipboardData.setData('Text', args);
|
---|
104 | else
|
---|
105 | g_cbData = args;
|
---|
106 | g_Flash.SetVariable("command", "Set OK");
|
---|
107 | }
|
---|
108 | ;
|
---|
109 |
|
---|
110 | function SetWindowTitle(fileName) {
|
---|
111 | if (fileName == "")
|
---|
112 | document.title = "Violet Online";
|
---|
113 | else {
|
---|
114 | var docName = fileName.substring(0, fileName.length - 4);
|
---|
115 | document.title = "Violet Online - " + docName;
|
---|
116 | }
|
---|
117 | }
|
---|
118 | ;
|
---|
119 |
|
---|
120 | function SetWindowState() {
|
---|
121 | var full = (g_Flash.width == "100%");
|
---|
122 | g_Flash.width = full ? "800" : "100%";
|
---|
123 | g_Flash.height = full ? "580" : "100%";
|
---|
124 | }
|
---|
125 | ;
|
---|
126 |
|
---|
127 | function DoSaveLecture() {
|
---|
128 | g_Flash.SetVariable("command", "Press Save");
|
---|
129 | }
|
---|
130 |
|
---|
131 | function DoOpenLecture(filename) {
|
---|
132 | g_Flash.SetVariable("openedFileName", filename);
|
---|
133 | g_Flash.SetVariable("command", "Open File");
|
---|
134 | }
|
---|
135 |
|
---|
136 | function DoCloseLecture () {
|
---|
137 | g_Flash.SetVariable("command", "Quit App");
|
---|
138 | }
|
---|
139 |
|
---|
140 | function getLectureState () {
|
---|
141 | var state = g_Flash.GetVariable("dataChanged");
|
---|
142 | return state == 'true' ? true: (state == 'false' ? false:false);
|
---|
143 | }
|
---|
144 |
|
---|
145 | // Handle all the FSCommand messages in a Flash movie.
|
---|
146 | function LectorEditorOnline_DoFSCommand(command, args) {
|
---|
147 | switch (command) {
|
---|
148 | case "Set Title":
|
---|
149 | SetWindowTitle(args);
|
---|
150 | break;
|
---|
151 | case "Get Clipboard":
|
---|
152 | GetClipboardItem();
|
---|
153 | break;
|
---|
154 | case "Set Clipboard":
|
---|
155 | SetClipboardItem(args);
|
---|
156 | break;
|
---|
157 | case "Set State":
|
---|
158 | //SetWindowState();
|
---|
159 | break;
|
---|
160 | case "Quit":
|
---|
161 | window.open('', '_self').close();
|
---|
162 | break;
|
---|
163 | case "trace":
|
---|
164 | alert(args);
|
---|
165 | break;
|
---|
166 | case "Check License":
|
---|
167 | showModal();
|
---|
168 | break;
|
---|
169 | }
|
---|
170 | }
|
---|
171 | ;
|
---|
172 |
|
---|
173 | // Hook for Internet Explorer.
|
---|
174 | if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
|
---|
175 | document.write('<script language=\"VBScript\"\>\n');
|
---|
176 | document.write('On Error Resume Next\n');
|
---|
177 | document.write('Sub LectorEditorOnline_FSCommand(ByVal command, ByVal args)\n');
|
---|
178 | document.write(' Call LectorEditorOnline_DoFSCommand(command, args)\n');
|
---|
179 | document.write('End Sub\n');
|
---|
180 | document.write('</script\>\n');
|
---|
181 | }
|
---|
182 | ;
|
---|
183 |
|
---|
184 |
|
---|
185 | $(document).ready(function () {
|
---|
186 | InitViolet();
|
---|
187 | //$('#open-lecture').click(function(e){DoOpenLecture('http://sbgapi.violet.vn/space/file/id/7');});
|
---|
188 | var inFormOrLink = false;
|
---|
189 |
|
---|
190 | $(window).on('beforeunload', function() {
|
---|
191 | var e = $.Event('webapp:page:closing');
|
---|
192 | $(window).trigger(e); // let other modules determine whether to prevent closing
|
---|
193 | if(e.isDefaultPrevented()) {
|
---|
194 | return e.message;
|
---|
195 | }
|
---|
196 | });
|
---|
197 |
|
---|
198 | $(window).on('webapp:page:closing', function(e) {
|
---|
199 | if(getLectureState()) {
|
---|
200 | e.preventDefault();
|
---|
201 | e.message = 'Bạn Äang soạn bà i giảng và chưa lưu dữ liá»u. Bạn có muá»n chuyá»n khá»i ứng dụng khÃŽng?';
|
---|
202 | }
|
---|
203 | });
|
---|
204 |
|
---|
205 | });
|
---|
206 | $(document).ready(function(){
|
---|
207 | if ($("#form-field-province").val() !== 'undefined'){
|
---|
208 | provinceId = $("#form-field-province").val();
|
---|
209 | $.ajax({
|
---|
210 | url: 'user/getDistrict/' + provinceId,
|
---|
211 | type: 'POST',
|
---|
212 | success: function (data, textStatus, jqXHR)
|
---|
213 | {
|
---|
214 | result = jQuery.parseJSON(data);
|
---|
215 | content = "<option></option>";
|
---|
216 | if (result != null){
|
---|
217 | for (var i in result){
|
---|
218 | content = content + '<option value="' + result[i].district_id + '">' + result[i].district_name + '</option>'
|
---|
219 | }
|
---|
220 |
|
---|
221 | }
|
---|
222 | $("#form-field-district").html(content);
|
---|
223 | }
|
---|
224 | });
|
---|
225 | }
|
---|
226 |
|
---|
227 | $("#form-field-province").change(function(){
|
---|
228 | provinceId = this.value;
|
---|
229 | $.ajax({
|
---|
230 | url: 'user/getDistrict/' + provinceId,
|
---|
231 | type: 'POST',
|
---|
232 | success: function (data, textStatus, jqXHR)
|
---|
233 | {
|
---|
234 | console.log(data);
|
---|
235 | result = jQuery.parseJSON(data);
|
---|
236 | content = "<option></option>";
|
---|
237 | if (result != null){
|
---|
238 | for (var i in result){
|
---|
239 | content = content + '<option value="' + result[i].district_id + '">' + result[i].district_name + '</option>'
|
---|
240 | }
|
---|
241 |
|
---|
242 | }
|
---|
243 | $("#form-field-district").html(content);
|
---|
244 | }
|
---|
245 | });
|
---|
246 | });
|
---|
247 | });
|
---|