source: pro-violet-viettel/www/deploy/20150304/assets/js/frontend/lecture.js @ 780

Last change on this file since 780 was 780, checked in by dungnv, 10 years ago
File size: 5.3 KB
Line 
1if (licenseAvailable == "!OK")
2{
3    $('#alert-services').modal('show');
4    if (first_visit == '1') {
5        $('#alert-services').modal('show');
6    }
7}
8
9if (p_period == -1 && is_overdate == 1)
10{
11        $('#alert-trial-services').modal('show');
12        $('#alert-trial-services').on('hidden.bs.modal', function () {
13                if (update_user_info == "1")
14                {
15                        $('#update_user_info').modal({backdrop: 'static',keyboard: false,});
16                }
17        });
18}
19else
20{
21        if (update_user_info == "1")
22        {
23                $('#update_user_info').modal({backdrop: 'static'});
24        }
25}
26
27$("#update_user_info.btn").click(function () {
28    $(".error").html("");
29    $.ajax({
30        url: 'user/update_info/',
31        type: 'POST',
32        data: $("#update_user_info.form").serialize(),
33        success: function (data, textStatus, jqXHR)
34        {
35            result = jQuery.parseJSON(data);
36            if (result.success == "1")
37            {
38                $('#update_user_info').modal('hide');
39
40            }
41            else
42            {
43                for (var key in result.errors)
44                {
45                    $("#" + result.errors[key]['field'] + ".error").html(result.errors[key]['content']);
46
47                }
48            }
49        }
50    });
51});
52
53function showModal() {
54    console.log('Show modal!');
55    $('#alert-services-package').modal('show');
56        //$('#alert-services-package-bk').modal('show');
57}
58
59$('#services-reg').click(function () {
60    $('#alert-services').modal('hide');
61    window.location = url + "frontend/user/profile#services-register";
62});
63
64$('#save-package').click(function () {
65    DoSaveLecture();
66});
67
68$('#services-sign').click(function () {
69    $('#alert-services-reg').modal('hide');
70    $('#alert-services-reg-2').modal('show');
71})
72
73var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
74var g_Flash = null;
75var g_cbData = "";
76
77function InitViolet() {
78    g_Flash = document.getElementById('LectorEditorOnline');
79    //g_Flash = $('#LectorEditorOnline');
80    //g_Flash = isInternetExplorer ? LectorEditorOnline : document.LectorEditorOnline;
81}
82;
83
84function GetClipboardItem() {
85    var cbData = window.clipboardData ? window.clipboardData.getData('Text') : g_cbData;
86    g_Flash.SetVariable("clipboardData", cbData);
87    g_Flash.SetVariable("command", "Get Text");
88}
89;
90
91function SetClipboardItem(args) {
92    if (window.clipboardData)
93        window.clipboardData.setData('Text', args);
94    else
95        g_cbData = args;
96    g_Flash.SetVariable("command", "Set OK");
97}
98;
99
100function SetWindowTitle(fileName) {
101    if (fileName == "")
102        document.title = "Violet Online";
103    else {
104        var docName = fileName.substring(0, fileName.length - 4);
105        document.title = "Violet Online - " + docName;
106    }
107}
108;
109
110function SetWindowState() {
111    var full = (g_Flash.width == "100%");
112    g_Flash.width = full ? "800" : "100%";
113    g_Flash.height = full ? "580" : "100%";
114}
115;
116
117function DoSaveLecture() {
118    g_Flash.SetVariable("command", "Press Save");
119}
120
121function DoOpenLecture(filename) {
122    g_Flash.SetVariable("openedFileName", filename);
123    g_Flash.SetVariable("command", "Open File");
124}
125
126function DoCloseLecture () {
127        g_Flash.SetVariable("command", "Quit App");             
128}
129
130function getLectureState () {
131        var state = g_Flash.GetVariable("dataChanged");
132        return state == 'true' ? true: (state == 'false' ? false:false);
133}
134
135// Handle all the FSCommand messages in a Flash movie.
136function LectorEditorOnline_DoFSCommand(command, args) {
137    switch (command) {
138        case "Set Title":
139            SetWindowTitle(args);
140            break;
141        case "Get Clipboard":
142            GetClipboardItem();
143            break;
144        case "Set Clipboard":
145            SetClipboardItem(args);
146            break;
147        case "Set State":
148            //SetWindowState();
149            break;
150        case "Quit":
151            window.open('', '_self').close();
152            break;
153        case "trace":
154            alert(args);
155            break;
156        case "Check License":
157            showModal();
158            break;
159    }
160}
161;
162
163// Hook for Internet Explorer.
164if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
165    document.write('<script language=\"VBScript\"\>\n');
166    document.write('On Error Resume Next\n');
167    document.write('Sub LectorEditorOnline_FSCommand(ByVal command, ByVal args)\n');
168    document.write('  Call LectorEditorOnline_DoFSCommand(command, args)\n');
169    document.write('End Sub\n');
170    document.write('</script\>\n');
171}
172;
173
174
175$(document).ready(function () {
176    InitViolet();
177    //$('#open-lecture').click(function(e){DoOpenLecture('http://sbgapi.violet.vn/space/file/id/7');});
178        var inFormOrLink = false;
179
180        $(window).on('beforeunload', function() {
181                var e = $.Event('webapp:page:closing');
182                $(window).trigger(e); // let other modules determine whether to prevent closing
183                if(e.isDefaultPrevented()) {
184                        return e.message;
185                }
186        });
187
188        $(window).on('webapp:page:closing', function(e) {
189                if(getLectureState()) {
190                        e.preventDefault();
191                        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?';
192                }
193        });
194
195})
Note: See TracBrowser for help on using the repository browser.