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

Last change on this file was 836, checked in by dungnv, 10 years ago
File size: 5.7 KB
RevLine 
[780]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{
[831]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    });
[780]18}
19else
20{
[831]21    if (update_user_info == "1")
22    {
23        $('#update_user_info').modal({backdrop: 'static'});
24    }
[780]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');
[831]56    //$('#alert-services-package-bk').modal('show');
[780]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
[835]126function DoOpenLectureOnLoad(filename) {
127        g_Flash.SetVariable("openedFileName", filename);
128        g_Flash.SetVariable("command", "Init&Open File");
129}
130
[831]131function DoCloseLecture() {
132    g_Flash.SetVariable("command", "Quit App");
[780]133}
134
[831]135function getLectureState() {
136    var state = g_Flash.GetVariable("dataChanged");
137    return state == 'true' ? true : (state == 'false' ? false : false);
[780]138}
139
140// Handle all the FSCommand messages in a Flash movie.
141function LectorEditorOnline_DoFSCommand(command, args) {
142    switch (command) {
143        case "Set Title":
144            SetWindowTitle(args);
145            break;
146        case "Get Clipboard":
147            GetClipboardItem();
148            break;
149        case "Set Clipboard":
150            SetClipboardItem(args);
151            break;
152        case "Set State":
153            //SetWindowState();
154            break;
155        case "Quit":
156            window.open('', '_self').close();
157            break;
158        case "trace":
159            alert(args);
160            break;
161        case "Check License":
162            showModal();
163            break;
164    }
165}
166;
167
168// Hook for Internet Explorer.
169if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
170    document.write('<script language=\"VBScript\"\>\n');
171    document.write('On Error Resume Next\n');
172    document.write('Sub LectorEditorOnline_FSCommand(ByVal command, ByVal args)\n');
173    document.write('  Call LectorEditorOnline_DoFSCommand(command, args)\n');
174    document.write('End Sub\n');
175    document.write('</script\>\n');
176}
177;
178
179
180$(document).ready(function () {
[831]181    InitViolet();
182    var inFormOrLink = false;
[780]183
[831]184    $(window).on('beforeunload', function () {
185        var e = $.Event('webapp:page:closing');
186        $(window).trigger(e); // let other modules determine whether to prevent closing
187        if (e.isDefaultPrevented()) {
188            return e.message;
189        }
190    });
[780]191
[831]192    $(window).on('webapp:page:closing', function (e) {
193        if (getLectureState()) {
194            e.preventDefault();
195            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?';
196        }
197    });
[832]198   
[835]199    if (fileid != "")
200    {
201        console.log(api_url+'space/file/id/' + fileid);
202        DoOpenLectureOnLoad(api_url+'space/file/id/' + fileid);
203    }
204    else {
205        g_Flash.SetVariable("command", "Init OK");
206    }
[828]207})
208
Note: See TracBrowser for help on using the repository browser.