You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How is the best practice with sammy js ?
I have this codes, what is it best practice ? But i think it is not a best practice.
My codes :
`
var app, app_name, base_url, url = [], cdn, websocket;
var body, navbar, container_content, left_side, main_side, main_content, other_side, right_side, footer;
var uid, user_id, name;
How is the best practice with sammy js ?
I have this codes, what is it best practice ? But i think it is not a best practice.
My codes :
`
var app, app_name, base_url, url = [], cdn, websocket;
var body, navbar, container_content, left_side, main_side, main_content, other_side, right_side, footer;
var uid, user_id, name;
// Config
var config = {
host : 'http://localhost:8080/xampp/MyApp/',
app_name : window.location.pathname.split('/').length > 1 ? window.location.pathname.split('/')[2] : window.location.pathname.split('/')[1],
target : 'body'
}
// Autoload
var autoload = {
base_url: config.host,
error_404: ''
};
// Url's
var url = {
login: '#/',
profile: 'profile/index/',
kronologi: 'profile/kronologi/',
status_profile: 'profile/status/',
global: 'page/global_page',
status_global: 'page/status_global/',
recomended: 'page/all_recomended'
}
// System
Object.keys(url).forEach(function (key) {
url[key] = config.host + url[key];
});
base_url = autoload.base_url;
app_name = config.app_name;
name = $('#nama-profile').children().text();
// Controller
var routes = $.sammy(function(){
app = this;
this.element_selector = config.target;
this.run_interval_every = 60000;
this.get('#/', function (context) {
}).run('#/');
// Views
// Profile
function profile(el,controller,name) {
render(el,controller,'kronologi');
change_title(str_replace(app_name,'/','')+' - '+str_replace(name,'',' '));
$(document).find('.title-user').html('
Profil '+str_replace(name,'',' ')+'
');}
function kronologi(el,controller,user_id) {
render(el,controller,'status_profile');
}
// Global
function global(el,controller) {
change_title(str_replace(app_name,'/','')+' - '+'Global');
$(document).find('.title-user').html('
Global page
');render(el,controller,'');
}
// Helpers
function render(params1,params2,params3) {
$.ajax({
url: params2,
type: 'post',
beforeSend:function (argument) {
}
function site_url(args){
return config.host + args;
}
function loadStatus(el,urlTarget) {
$(el).loadStatus({
loading : "",
no_news : "",
error_text : "Terjadi kesalahan memuat konten",
url : urlTarget,
start : 1
});
}
function change_title(argument) {
$(document).find('title').text(argument);
}
function str_replace(args,haystack,needle) {
return args.replace(haystack,needle);
}`
Hope you can give me the best practice in documentation, because i know about jquery but just litle for sammy :-)
The text was updated successfully, but these errors were encountered: