source: pro-violet-viettel/sourcecode/assets/js/frontend/lecture.js @ 718

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