[Project] elapsedTime (Total Time Spent On Forums)
+6
GummyBear
smurfavr
ForeverPotterLock
Van-Helsing
CovalentBond
JScript
10 posters
Page 1 of 1
[Project] elapsedTime (Total Time Spent On Forums)
Hello friends!
I started this - so to speak - project on the 18th of this month and he is intended to show how much time each member spends logged into the site.
Well, the code is very simple and I'll explain below how it works:
1- It created two fields in the profile of members, the first has the purpose of show the connected time, the other as a pseudo-database;
2- The time count starts when the member do a log in;
3- So every 30 seconds (default time that can be changed) the time counter is incremented and saved in the profile field;
4- The counter is only reset when the member log out of the forum! If only close the page or the browser, the counter remains active and will be incremented on the next login!
Below is the code to be added with placement "In all the pages":
Result:
Irrelevant and useless information?
->Maybe yes or no: You decide...
JS
I started this - so to speak - project on the 18th of this month and he is intended to show how much time each member spends logged into the site.
Well, the code is very simple and I'll explain below how it works:
1- It created two fields in the profile of members, the first has the purpose of show the connected time, the other as a pseudo-database;
2- The time count starts when the member do a log in;
3- So every 30 seconds (default time that can be changed) the time counter is incremented and saved in the profile field;
4- The counter is only reset when the member log out of the forum! If only close the page or the browser, the counter remains active and will be incremented on the next login!
Below is the code to be added with placement "In all the pages":
- Code:
/*******************************************************************************************************
* Application: elapsedTime (Total Time Spent On Forums)
* Description: Will show how much time each member spends logged into the site.
* Version: RC1 - Beta tester only!
* Made and Optimizations by JScript - 2015/02/18
* Copyright (c) 2015 JScript <jscriptbrasil at live dot com>
* This work is free. You can redistribute it and/or modify it
* under the terms of the WTFPL, Version 2
********************************************************************************************************
-
Variables that can be changed by the user:
1- tTimeOut
2- checkTime
3- fieldName
Note: For those variables "tTimeout" and "checkTime" ->
- to avoid the "Request Limit" the lowest value should be 10 seconds and 30 seconds respectively!
*/
var elapsedTime = {
autor: 'JScript',
version: '1.02202015-jq1.9.1',
codename: 'Narmer (Sheikh Muftah)',
/**
* Related to database.
**/
fieldName: 'Time Online',
field_id: 0,
fd_description: 'Will show how much time each member spends logged into the site.',
db_field: 0,
db_content: '',
db_description: 'Database to store the data of the module elapsedTime!',
db_url: '/admin/index.forum?part=users_groups&sub=users&mode=avatar_profil2&extended_admin=1&tid=',
response: '',
evalTextarea: 'jQuery(\'label:contains("elapsedTime_DB"), span:contains("elapsedTime_DB"), dt:contains("elapsedTime_DB")\', response).closest("dl, tr").find("textarea")',
db_default: {
appInfo: {
module: 'elapsedTime_DB',
description: 'Database to store the data of the module elapsedTime!',
author: 'JScript',
version: 'RC1 b',
release: '2015/02/18'
},
userInfo: {
isOnline: 1,
dateOld: Number(new Date()),
dateNow: Number(new Date()),
dateSpent: ''
}
},
/**
* Related to intervals.
**/
lInterval: 10,
tTimeOut: 10000,
checkTime: 30000,
setLoop: 0,
// other variables...
evalTID: 'jQuery(\'a[href*="tid="]\').attr("href").split("tid=")[1].split("&")[0]',
TID: 0,
/**
* JavaScript/jQuery functions
*/
initialize: function() {
$(function() {
return (!_userdata.session_logged_in) ? false : elapsedTime.setup();
});
},
setup: function() {
elapsedTime.TID = eval(elapsedTime.evalTID);
/**
* First checks if the database exists!
**/
jQuery.get('/profile?mode=editprofile', function(response) {
elapsedTime.response = eval(elapsedTime.evalTextarea);
// If the database does not exist, then an administrator will create it now!
if ((!elapsedTime.response.length) && (_userdata.user_level == 1)) {
elapsedTime.async(false);
jQuery.post(elapsedTime.db_url + elapsedTime.TID, { /* <- Parameters! */
/* Post action */
action: 'add_field',
id: 0,
type: 0,
action: 'configuration_final',
list_type_field: 2,
field_name: 'elapsedTime_DB',
field_desc: elapsedTime.db_description + ' - Made by JScript, 2015/02/18',
field_oblig: 0,
field_display_profil: 1,
list_field_type_view: 0,
list_auth_field_himself: 1,
list_field_view: 0,
list_separator: 0,
field_type_2_lng_max: 15000,
submit: 1,
field_type_11_max_before: 14,
field_type_11_max_after: 6
}).done(function() {
jQuery.get('/profile?mode=editprofile', function(response) {
elapsedTime.response = eval(elapsedTime.evalTextarea);
});
});
jQuery.post(elapsedTime.db_url + elapsedTime.TID, { /* <- Parameters! */
/* Post action */
action: 'add_field',
id: 0,
type: 0,
action: 'configuration_final',
list_type_field: 13,
field_name: elapsedTime.fieldName,
field_desc: elapsedTime.fd_description + ' - Made by JScript, 2015/02/18',
field_oblig: 0,
field_display_message: 1,
field_display_profil: 1,
list_field_type_view: 0,
list_auth_field_himself: 1,
list_field_view: -1,
list_separator: 1,
field_type_2_lng_max: 15000,
submit: 1,
field_type_11_max_before: 14,
field_type_11_max_after: 6
}).done(function(e) {
console.log(e)
});
elapsedTime.async(true);
}
if (!elapsedTime.response.length) {
return false;
}
elapsedTime.db_field = elapsedTime.response.attr('id');
if (elapsedTime.response.val().length) {
elapsedTime.db_content = JSON.parse(elapsedTime.response.val().replace(/'/g, '"'));
}
if ((!elapsedTime.response.val().length) || (!elapsedTime.db_content.userInfo.isOnline)) {
elapsedTime.db_content = elapsedTime.db_default;
elapsedTime.async(false);
elapsedTime.dataSave(elapsedTime.db_field, JSON.stringify(elapsedTime.db_content).replace(/"/g, "'"));
elapsedTime.async(true);
elapsedTime.updateTime();
}
if (document.getElementById('fa_welcome') !== null) {
jQuery('a[href$="logout=1"]').attr('href', jQuery('#logout').attr('href'));
}
jQuery('a[href*="logout=1"]').click(function(event) {
elapsedTime.TID = eval(elapsedTime.evalTID);
elapsedTime.db_content.userInfo.isOnline = 0;
elapsedTime.async(false);
elapsedTime.dataSave(elapsedTime.db_field, JSON.stringify(elapsedTime.db_content).replace(/"/g, "'"));
elapsedTime.async(true);
});
/**
* Writes the current time in the profile field...
**/
setTimeout(function() {
setInterval(function() {
elapsedTime.updateTime();
}, elapsedTime.checkTime);
}, elapsedTime.tTimeOut);
}).fail(function(e) {
console.log(e);
});
},
async: function(mode) {
jQuery.ajaxSetup({
async: mode
});
},
dataSave: function(field, content) {
jQuery.post("/ajax_profile.forum?jsoncallback=?", {
id: field.split("_")[3],
user: _userdata.user_id,
active: "1",
content: '[["' + field + '", "' + content + '"]]',
tid: elapsedTime.TID
}, function(data) {
// OK!
}, "json").fail(function(e) {
console.log(e);
});
},
updateTime: function() {
elapsedTime.TID = eval(elapsedTime.evalTID);
jQuery.get('/profile?mode=editprofile', function(response) {
elapsedTime.response = jQuery('label:contains("' + elapsedTime.fieldName + '"), span:contains("' + elapsedTime.fieldName + '"), dt:contains("' + elapsedTime.fieldName + '")', response).closest('dl, tr').find('input');
elapsedTime.field_id = elapsedTime.response.attr('id');
if (elapsedTime.response.length) {
elapsedTime.response = eval(elapsedTime.evalTextarea);
elapsedTime.db_content = JSON.parse(elapsedTime.response.val().replace(/'/g, '"'));
elapsedTime.dataSave(elapsedTime.field_id, elapsedTime.getTime(elapsedTime.db_content.userInfo.dateOld));
}
}).fail(function(e) {
console.log(e);
});
},
getTime: function(date_old, date_now) {
date_old = date_old || new Date(); //.toLocaleString('en-US', { hour12: false });
date_now = date_now || new Date(); //.toLocaleString('en-US', { hour12: false });
//date_old = date_old.split("/").swap(0, 1).join("/");
//date_now = date_now.split("/").swap(0, 1).join("/");
date_old = new Date(date_old);
date_now = new Date(date_now);
var seconds = Math.floor((date_now - (date_old)) / 1000),
minutes = Math.floor(seconds / 60),
hours = Math.floor(minutes / 60),
days = Math.floor(hours / 24);
hours = hours - (days * 24);
minutes = minutes - (days * 24 * 60) - (hours * 60);
seconds = seconds - (days * 24 * 60 * 60) - (hours * 60 * 60) - (minutes * 60);
//console.log(days + "d " + hours + "h " + minutes + "m " + seconds + "s ");
return ((days) ? days + "d " : "") + ((hours) ? hours + "h " : "") + ((minutes) ? minutes + "m " : "") + ((seconds) ? seconds + "s " : "");
}
};
elapsedTime.initialize();
Result:
Irrelevant and useless information?
->Maybe yes or no: You decide...
JS
Re: [Project] elapsedTime (Total Time Spent On Forums)
Then you make a new account here and your first post is that?sunny11 wrote:Forumotion offers professional service and security to your forums, often better than the payed offers. The administration and maintenance of such a system requires a daily monitoring. Our technical infrastructure and our daily efforts allow us to fully ensure the integrity and security of all data on all our services.
Okay, but what his statements have to do with my topic?
Despite the question marks, you do not need to answer me!
JS
Re: [Project] elapsedTime (Total Time Spent On Forums)
Hello @JScript,
I don't know why but when I have active (In all the pages) the javascript is not displaying the images in the posts.
I don't know why but when I have active (In all the pages) the javascript is not displaying the images in the posts.
Re: [Project] elapsedTime (Total Time Spent On Forums)
@JScript
1. Why show me this profile and how to remove it?
2. Why can not I change this inscription Time Online: 3m 44s in my language?
psp
The two codes conflict. As this code and put out some pictures. Time spent at the forum hides.
https://help.forumotion.com/t139335-project-last-visitors-on-member-profile#945728
1. Why show me this profile and how to remove it?
2. Why can not I change this inscription Time Online: 3m 44s in my language?
psp
The two codes conflict. As this code and put out some pictures. Time spent at the forum hides.
https://help.forumotion.com/t139335-project-last-visitors-on-member-profile#945728
Re: [Project] elapsedTime (Total Time Spent On Forums)
Hello!smurfavr wrote:up
I'm not sure, but I guess do not need give "up" in this section...
To translate "Time Online" in the profile, you will also translate into the code!
But that I'm skirting with a new code.
To hide the other field, it can be achieved via CSS!
So I can solve what you want, you will have to give access to visitors in the profile or give me a temporary account.
JS
Re: [Project] elapsedTime (Total Time Spent On Forums)
Time spent in the forum shows only the administrator. Other users are not displayed.
Code put it 3 days ago and shows me that I spent Time Online: 3m 44s. Why not show how much time I spent in the forum and stands only at the same time?
http://vracatestforum.bulgarianforum.net/forum
koko76
123ааа
Code put it 3 days ago and shows me that I spent Time Online: 3m 44s. Why not show how much time I spent in the forum and stands only at the same time?
http://vracatestforum.bulgarianforum.net/forum
koko76
123ааа
Re: [Project] elapsedTime (Total Time Spent On Forums)
There is a bug in the code. Displayed several times weather information.
The other bug I noticed in the admin panel.
Profiles / Profile fields
When refresh Profile appear several times in the options Highlight fields.
psp
This occurs in the admin panel changed the name of the options my native language.
psp2
Can make to automatically display all account users how long they have been in onlain forum?
The other bug I noticed in the admin panel.
Profiles / Profile fields
When refresh Profile appear several times in the options Highlight fields.
psp
This occurs in the admin panel changed the name of the options my native language.
psp2
Can make to automatically display all account users how long they have been in onlain forum?
Re: [Project] elapsedTime (Total Time Spent On Forums)
Good job , JScript !
But that for me is not working so much and it is blocked to 1 second .
But that for me is not working so much and it is blocked to 1 second .
Re: [Project] elapsedTime (Total Time Spent On Forums)
i have added this in punbb but aint working any help sir ?
am having edited template thanks
am having edited template thanks
Re: [Project] elapsedTime (Total Time Spent On Forums)
Code has a lot bugs.
If you remove tick the option Who can modify the profile field value during the ordinary users, not shown.
If banned from elapsedTime_DB file is displayed in the user profile of the time-line in his profile is not displayed.
If you remove tick the option Who can modify the profile field value during the ordinary users, not shown.
If banned from elapsedTime_DB file is displayed in the user profile of the time-line in his profile is not displayed.
Re: [Project] elapsedTime (Total Time Spent On Forums)
This will no longer be supported by JScript: https://help.forumotion.com/t151137-in-memory-of-jscript-joao-carlos.
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Similar topics
» Code for time spent in the forum does not work well
» Total online time
» Ads reappeared on my forums but credit time hasn't expired
» Credits spent twice for the same service
» add the total number of views.
» Total online time
» Ads reappeared on my forums but credit time hasn't expired
» Credits spent twice for the same service
» add the total number of views.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum