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

Last change on this file since 744 was 744, 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        //$('#alert-services-package-bk').modal('show');
61}
62
63$('#services-reg').click(function () {
64    $('#alert-services').modal('hide');
65    window.location = url + "frontend/user/profile#services-register";
66});
67
68$('#save-package').click(function () {
69    DoSaveLecture();
70});
71
72$('#services-sign').click(function () {
73    $('#alert-services-reg').modal('hide');
74    $('#alert-services-reg-2').modal('show');
75})
76
77var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
78var g_Flash = null;
79var g_cbData = "";
80
81function InitViolet() {
82    g_Flash = document.getElementById('LectorEditorOnline');
83    //g_Flash = $('#LectorEditorOnline');
84    //g_Flash = isInternetExplorer ? LectorEditorOnline : document.LectorEditorOnline;
85}
86;
87
88function GetClipboardItem() {
89    var cbData = window.clipboardData ? window.clipboardData.getData('Text') : g_cbData;
90    g_Flash.SetVariable("clipboardData", cbData);
91    g_Flash.SetVariable("command", "Get Text");
92}
93;
94
95function SetClipboardItem(args) {
96    if (window.clipboardData)
97        window.clipboardData.setData('Text', args);
98    else
99        g_cbData = args;
100    g_Flash.SetVariable("command", "Set OK");
101}
102;
103
104function SetWindowTitle(fileName) {
105    if (fileName == "")
106        document.title = "Violet Online";
107    else {
108        var docName = fileName.substring(0, fileName.length - 4);
109        document.title = "Violet Online - " + docName;
110    }
111}
112;
113
114function SetWindowState() {
115    var full = (g_Flash.width == "100%");
116    g_Flash.width = full ? "800" : "100%";
117    g_Flash.height = full ? "580" : "100%";
118}
119;
120
121function DoSaveLecture() {
122    g_Flash.SetVariable("command", "Press Save");
123}
124
125function DoOpenLecture(filename) {
126    g_Flash.SetVariable("openedFileName", filename);
127    g_Flash.SetVariable("command", "Open File");
128}
129
130function DoCloseLecture () {
131        g_Flash.SetVariable("command", "Quit App");             
132}
133
134function getLectureState () {
135        var state = g_Flash.GetVariable("dataChanged");
136        return state == 'true' ? true: (state == 'false' ? false:false);
137}
138
139// Handle all the FSCommand messages in a Flash movie.
140function LectorEditorOnline_DoFSCommand(command, args) {
141    switch (command) {
142        case "Set Title":
143            SetWindowTitle(args);
144            break;
145        case "Get Clipboard":
146            GetClipboardItem();
147            break;
148        case "Set Clipboard":
149            SetClipboardItem(args);
150            break;
151        case "Set State":
152            //SetWindowState();
153            break;
154        case "Quit":
155            window.open('', '_self').close();
156            break;
157        case "trace":
158            alert(args);
159            break;
160        case "Check License":
161            showModal();
162            break;
163    }
164}
165;
166
167// Hook for Internet Explorer.
168if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
169    document.write('<script language=\"VBScript\"\>\n');
170    document.write('On Error Resume Next\n');
171    document.write('Sub LectorEditorOnline_FSCommand(ByVal command, ByVal args)\n');
172    document.write('  Call LectorEditorOnline_DoFSCommand(command, args)\n');
173    document.write('End Sub\n');
174    document.write('</script\>\n');
175}
176;
177
178
179$(document).ready(function () {
180    InitViolet();
181    //$('#open-lecture').click(function(e){DoOpenLecture('http://sbgapi.violet.vn/space/file/id/7');});
182        var inFormOrLink = false;
183
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        });
191
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        });
198
199})
Note: See TracBrowser for help on using the repository browser.