if (licenseAvailable == "!OK")
{
$('#alert-services').modal('show');
if (first_visit == '1') {
$('#alert-services').modal('show');
}
}
if (p_period == -1 && is_overdate == 1)
{
$('#alert-trial-services').modal('show');
$('#alert-trial-services').on('hidden.bs.modal', function () {
if (update_user_info == "1")
{
$('#update_user_info').modal({backdrop: 'static',keyboard: false,});
}
});
}
else
{
if (update_user_info == "1")
{
$('#update_user_info').modal({backdrop: 'static'});
}
}
$("#update_user_info.btn").click(function () {
$(".error").html("");
$.ajax({
url: 'user/update_info/',
type: 'POST',
data: $("#update_user_info.form").serialize(),
success: function (data, textStatus, jqXHR)
{
result = jQuery.parseJSON(data);
if (result.success == "1")
{
$('#update_user_info').modal('hide');
}
else
{
for (var key in result.errors)
{
$("#" + result.errors[key]['field'] + ".error").html(result.errors[key]['content']);
}
}
}
});
});
function showModal() {
console.log('Show modal!');
$('#alert-services-package').modal('show');
//$('#alert-services-package-bk').modal('show');
}
$('#services-reg').click(function () {
$('#alert-services').modal('hide');
window.location = url + "frontend/user/profile#services-register";
});
$('#save-package').click(function () {
DoSaveLecture();
});
$('#services-sign').click(function () {
$('#alert-services-reg').modal('hide');
$('#alert-services-reg-2').modal('show');
})
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var g_Flash = null;
var g_cbData = "";
function InitViolet() {
g_Flash = document.getElementById('LectorEditorOnline');
//g_Flash = $('#LectorEditorOnline');
//g_Flash = isInternetExplorer ? LectorEditorOnline : document.LectorEditorOnline;
}
;
function GetClipboardItem() {
var cbData = window.clipboardData ? window.clipboardData.getData('Text') : g_cbData;
g_Flash.SetVariable("clipboardData", cbData);
g_Flash.SetVariable("command", "Get Text");
}
;
function SetClipboardItem(args) {
if (window.clipboardData)
window.clipboardData.setData('Text', args);
else
g_cbData = args;
g_Flash.SetVariable("command", "Set OK");
}
;
function SetWindowTitle(fileName) {
if (fileName == "")
document.title = "Violet Online";
else {
var docName = fileName.substring(0, fileName.length - 4);
document.title = "Violet Online - " + docName;
}
}
;
function SetWindowState() {
var full = (g_Flash.width == "100%");
g_Flash.width = full ? "800" : "100%";
g_Flash.height = full ? "580" : "100%";
}
;
function DoSaveLecture() {
g_Flash.SetVariable("command", "Press Save");
}
function DoOpenLecture(filename) {
g_Flash.SetVariable("openedFileName", filename);
g_Flash.SetVariable("command", "Open File");
}
function DoCloseLecture () {
g_Flash.SetVariable("command", "Quit App");
}
function getLectureState () {
var state = g_Flash.GetVariable("dataChanged");
return state == 'true' ? true: (state == 'false' ? false:false);
}
// Handle all the FSCommand messages in a Flash movie.
function LectorEditorOnline_DoFSCommand(command, args) {
switch (command) {
case "Set Title":
SetWindowTitle(args);
break;
case "Get Clipboard":
GetClipboardItem();
break;
case "Set Clipboard":
SetClipboardItem(args);
break;
case "Set State":
//SetWindowState();
break;
case "Quit":
window.open('', '_self').close();
break;
case "trace":
alert(args);
break;
case "Check License":
showModal();
break;
}
}
;
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
document.write('\n');
}
;
$(document).ready(function () {
InitViolet();
//$('#open-lecture').click(function(e){DoOpenLecture('http://sbgapi.violet.vn/space/file/id/7');});
var inFormOrLink = false;
$(window).on('beforeunload', function() {
var e = $.Event('webapp:page:closing');
$(window).trigger(e); // let other modules determine whether to prevent closing
if(e.isDefaultPrevented()) {
return e.message;
}
});
$(window).on('webapp:page:closing', function(e) {
if(getLectureState()) {
e.preventDefault();
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?';
}
});
});
if ($("#form-field-province").val() !== 'undefined'){
provinceId = $("#form-field-province").val();
$.ajax({
url: 'user/getDistrict/' + provinceId,
type: 'POST',
success: function (data, textStatus, jqXHR)
{
result = jQuery.parseJSON(data);
content = "";
if (result != null){
for (var i in result){
content = content + ''
}
$("#form-field-district").html(content);
}
}
});
}
$("#form-field-province").change(function(){
provinceId = this.value;
$.ajax({
url: 'user/getDistrict/' + provinceId,
type: 'POST',
success: function (data, textStatus, jqXHR)
{
result = jQuery.parseJSON(data);
content = "";
if (result != null){
for (var i in result){
content = content + ''
}
$("#form-field-district").html(content);
}
}
});
});