Notice
For more information about app.js
, please visit app.js section in the FJS Core guide.
After downloading the FrameworkJS core, you will notice that there is an app.js
file in the js folder.. This file contains a set of default general settings.
we need to modify some of these settings to match our project requirements. In the following code snippet, you can see the changes we have made to the configurations.
For more information about app.js
, please visit app.js section in the FJS Core guide.
It should be the exact name that we made in the CloadIO Account section. So here we named our project 'blog'.
app.name = 'blog';
Each project has a domain name in CloadIO with the below syntax in the app.js file. And if there is no secure operation in your server, add false
for SSL
property.
app.http = {
domain: 'blog.cloadio.com',
ssl: false
};
app.version = {
// control min version
// if minimum version be greater than the current version update page will be shown
// so app must have update page
control: true,
// current version
current: 202209181121,
// min version path
mvp: '/update/client/minVersion',
};
// default localization value
// all modules will use this configuration
app.localization = {
language: {
direction: 'ltr',
code: localStorage.languageCode || 'enUs'
},
calendar: 'gregorian',
timeZone: '00:00'
};
// fallback page name
app.auth.fpn = 'home';
// --------------- define app objects --------------------
app.functions = {};
app.local = {};
app.local.onSyncCompleted = [];
app.local.posts = {};
app.local.images = {};
// ------------ end of define app object
After defining the objects, we handle the jQuery click. (to avoid repetition and accumulation of clicks)
// -------------------- overrides ------------------------
// override jquey on click method
$.fn.addClick = $.fn.click;
$.fn.click = function (callback) {
if (callback) {
this.off('click');
this.addClick(callback);
}
else
this.addClick();
};
// ---------------- end of overrides ---
Now we are going to change the back event in Android devices by the below operation.
app.control.onBack = function () {
var jBack = $('.page.' + app.page.name + ' .back');
if (jBack.length)
jBack.trigger('push');
else if (app.local.exit)
Android.exit();
else {
setTimeout(function () {
app.local.exit = false;
}, 10000);
mdtoast('Press back button again to exit.', {duration: 1000});
app.local.exit = true;
}
};
Please note that this is the initial configuration for the project, next we will refer to app.js and add some code here to complete the project. For more information visit the FJS Core, app.js section.
Into CloadIO there are some important events, these events should be handled for every project.
These events include security codes and user accesses to receive or send data to CloadIO, or access levels to delete data and other security items that are necessary for the project.
For more information about CloadIO events, please see the CloadIO documentation.
We should add the following codes into events in CloadIO dashboard account of the project.
First should log in CloadIO Account and goes to Cloud side
, and then select the Events
menu.
In this page you can see and changes the some events box, like Del, Set,... if is needed.
Please note that absolutly don't change other events.
After adding changes you press Save all changes
, and the go to Settings
section and press the Restart
button to apply all changes.
We add the below code into Del event.
if (path.length > -1)
result(null, {permit: true});
else
result(null, {permit: false});
We add the below code into Set event.
if (path.length > -1)
result(null, {permit: true, valid: true});
else
result(null, {permit: false});