Save note on F5/quit
This commit is contained in:
@@ -8,10 +8,11 @@ var Tools = {
|
||||
return asForm;
|
||||
},
|
||||
|
||||
ajax: function(sAction, fOnSuccess, oData, fOnFail, $Loader, sType, sDataType)
|
||||
ajax: function(sAction, fOnSuccess, oData, fOnFail, $Loader, sType, sDataType, bBeacon)
|
||||
{
|
||||
sType = sType || 'GET';
|
||||
sDataType = sDataType || 'json';
|
||||
bBeacon = bBeacon || false;
|
||||
oData = oData || {};
|
||||
var asData = {};
|
||||
|
||||
@@ -19,6 +20,7 @@ var Tools = {
|
||||
asData = this.serialize(oData);
|
||||
}
|
||||
else asData = oData;
|
||||
asData['a'] = sAction;
|
||||
|
||||
if($Loader)
|
||||
{
|
||||
@@ -30,32 +32,40 @@ var Tools = {
|
||||
.html($('<img>', {'class':'onlyimg', src: Config.paths.dir.theme_image+"ajax.svg"}));
|
||||
}
|
||||
|
||||
asData['a'] = sAction;
|
||||
return $.ajax({
|
||||
url: oCATC.consts.context.process_page,
|
||||
type: sType,
|
||||
data: asData,
|
||||
dataType: sDataType
|
||||
})
|
||||
.done(function(oData) {
|
||||
if(oData.result==oCATC.consts.error) {
|
||||
if(!fOnFail) Tools.feedback('error', oData.desc);
|
||||
else fOnFail(oData.desc);
|
||||
}
|
||||
else fOnSuccess(oData.data, oData.desc);
|
||||
|
||||
if($Loader) {
|
||||
$Loader
|
||||
.removeClass()
|
||||
.addClass($Loader.data('load_class'))
|
||||
.html($Loader.data('load_html'));
|
||||
}
|
||||
})
|
||||
.fail(function(jqXHR, textStatus, errorThrown) {
|
||||
if(!fOnFail) Tools.feedback('error', textStatus+' '+errorThrown);
|
||||
else fOnFail(textStatus);
|
||||
}
|
||||
);
|
||||
if(bBeacon) {
|
||||
var oFD = new FormData();
|
||||
$.each(asData, function(sKey, sValue){
|
||||
if($.type(sValue) != 'string') sValue = JSON.stringify(sValue);
|
||||
oFD.append(sKey, sValue);
|
||||
});
|
||||
return navigator.sendBeacon(oCATC.consts.context.process_page, oFD);
|
||||
}
|
||||
else {
|
||||
return $.ajax({
|
||||
url: oCATC.consts.context.process_page,
|
||||
type: sType,
|
||||
data: asData,
|
||||
dataType: sDataType
|
||||
})
|
||||
.done(function(oData) {
|
||||
if(oData.result==oCATC.consts.error) {
|
||||
if(!fOnFail) Tools.feedback('error', oData.desc);
|
||||
else fOnFail(oData.desc);
|
||||
}
|
||||
else fOnSuccess(oData.data, oData.desc);
|
||||
|
||||
if($Loader) {
|
||||
$Loader
|
||||
.removeClass()
|
||||
.addClass($Loader.data('load_class'))
|
||||
.html($Loader.data('load_html'));
|
||||
}
|
||||
})
|
||||
.fail(function(jqXHR, textStatus, errorThrown) {
|
||||
if(!fOnFail) Tools.feedback('error', textStatus+' '+errorThrown);
|
||||
else fOnFail(textStatus);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
getIcon: function(sIcon, bFull){
|
||||
@@ -118,42 +128,6 @@ function addInput(form, name, type, value)
|
||||
document.forms[form].appendChild(registerInput);
|
||||
}
|
||||
|
||||
function getInfo(action, fOnSuccess, vars, fOnError, sType/*, bProcessIcon*/)
|
||||
{
|
||||
if(!vars) vars = {};
|
||||
sType = sType || 'GET';
|
||||
//bProcessIcon = bProcessIcon || false;
|
||||
//if(bProcessIcon) self.addBufferIcon();
|
||||
|
||||
vars['a'] = action;
|
||||
$.ajax(
|
||||
{
|
||||
url: oCATC.consts.context.process_page,
|
||||
type:sType,
|
||||
data: vars,
|
||||
dataType: 'json'
|
||||
})
|
||||
.done(function(oData)
|
||||
{
|
||||
if(oData.result==oCATC.consts.error)
|
||||
{
|
||||
if(!fOnError) console.log(oData.desc);
|
||||
else fOnError(oData.desc);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if(bProcessIcon) self.resetIcon();
|
||||
fOnSuccess(oData.desc, oData.data);
|
||||
}
|
||||
})
|
||||
.fail(function(jqXHR, textStatus, errorThrown)
|
||||
{
|
||||
//if(bProcessIcon) self.resetIcon();
|
||||
if(!fOnError) console.log(textStatus+' '+errorThrown);
|
||||
else fOnError(textStatus);
|
||||
});
|
||||
}
|
||||
|
||||
function addPunctuation(sMsg)
|
||||
{
|
||||
var asPunctuations = ['?', '!', '.', ',', ':', ';', '-', '/'];
|
||||
|
||||
Reference in New Issue
Block a user