The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

[Project] elapsedTime (Total Time Spent On Forums)

+6
GummyBear
smurfavr
ForeverPotterLock
Van-Helsing
CovalentBond
JScript
10 posters

Go down

[Project] elapsedTime (Total Time Spent On Forums) Empty [Project] elapsedTime (Total Time Spent On Forums)

Post by JScript February 20th 2015, 5:30 pm

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":
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:
[Project] elapsedTime (Total Time Spent On Forums) 3nVSYO2

Irrelevant and useless information?
->Maybe yes or no: You decide...

JS
JScript
JScript
Forumember

Male Posts : 741
Reputation : 175
Language : PT-BR, EN
Location : Brazil

http://jscript.forumeiros.com/

Back to top Go down

[Project] elapsedTime (Total Time Spent On Forums) Empty Re: [Project] elapsedTime (Total Time Spent On Forums)

Post by JScript February 24th 2015, 10:08 am

sunny11 wrote:Forumotion offers professional service and security héhé  to your forums, often better than the payed offers. The administration and maintenance of such a system requires a daily monitoring. Our technical banana  infrastructure and our loul  daily efforts allow us to fully ensure the integrity and security of all data on all our services.
Then you make a new account here and your first post is that?

Okay, but what his statements have to do with my topic?

Despite the question marks, you do not need to answer me!

JS
JScript
JScript
Forumember

Male Posts : 741
Reputation : 175
Language : PT-BR, EN
Location : Brazil

http://jscript.forumeiros.com/

Back to top Go down

[Project] elapsedTime (Total Time Spent On Forums) Empty Re: [Project] elapsedTime (Total Time Spent On Forums)

Post by CovalentBond March 11th 2015, 4:16 pm

Wow mate, thanks for sharing!
avatar
CovalentBond
New Member

Posts : 10
Reputation : 2
Language : English

http://nostalgia.forumhe.com/

Back to top Go down

[Project] elapsedTime (Total Time Spent On Forums) Empty Re: [Project] elapsedTime (Total Time Spent On Forums)

Post by Van-Helsing May 8th 2015, 12:57 am

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.
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

[Project] elapsedTime (Total Time Spent On Forums) Empty Re: [Project] elapsedTime (Total Time Spent On Forums)

Post by ForeverPotterLock May 18th 2015, 2:42 am

This doesn't show up for me :/
ForeverPotterLock
ForeverPotterLock
Forumember

Posts : 93
Reputation : 2
Language : English

http://www.thepetpalace.ga

Back to top Go down

[Project] elapsedTime (Total Time Spent On Forums) Empty Re: [Project] elapsedTime (Total Time Spent On Forums)

Post by smurfavr July 4th 2015, 12:06 pm

@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?

[Project] elapsedTime (Total Time Spent On Forums) 8211751P

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
smurfavr
smurfavr
Active Poster

Male Posts : 1883
Reputation : 22
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

[Project] elapsedTime (Total Time Spent On Forums) Empty Re: [Project] elapsedTime (Total Time Spent On Forums)

Post by smurfavr July 5th 2015, 10:38 pm

up
smurfavr
smurfavr
Active Poster

Male Posts : 1883
Reputation : 22
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

[Project] elapsedTime (Total Time Spent On Forums) Empty Re: [Project] elapsedTime (Total Time Spent On Forums)

Post by JScript July 5th 2015, 11:40 pm

smurfavr wrote:up
Hello!
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
JScript
JScript
Forumember

Male Posts : 741
Reputation : 175
Language : PT-BR, EN
Location : Brazil

http://jscript.forumeiros.com/

Back to top Go down

[Project] elapsedTime (Total Time Spent On Forums) Empty Re: [Project] elapsedTime (Total Time Spent On Forums)

Post by smurfavr July 6th 2015, 12:18 pm

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ааа
smurfavr
smurfavr
Active Poster

Male Posts : 1883
Reputation : 22
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

[Project] elapsedTime (Total Time Spent On Forums) Empty Re: [Project] elapsedTime (Total Time Spent On Forums)

Post by GummyBear July 8th 2015, 6:44 am

aint working for me.
avatar
GummyBear
Forumember

Posts : 71
Reputation : 2
Language : English

http://haxactivity.forum.com.bz

Back to top Go down

[Project] elapsedTime (Total Time Spent On Forums) Empty Re: [Project] elapsedTime (Total Time Spent On Forums)

Post by JScript July 8th 2015, 1:32 pm

@smurfavr & @GummyBear
I'm working on a new version, I kindly ask you to wait ok?

JS
JScript
JScript
Forumember

Male Posts : 741
Reputation : 175
Language : PT-BR, EN
Location : Brazil

http://jscript.forumeiros.com/

Back to top Go down

[Project] elapsedTime (Total Time Spent On Forums) Empty Re: [Project] elapsedTime (Total Time Spent On Forums)

Post by GummyBear July 9th 2015, 6:40 am

no problem Wink
avatar
GummyBear
Forumember

Posts : 71
Reputation : 2
Language : English

http://haxactivity.forum.com.bz

Back to top Go down

[Project] elapsedTime (Total Time Spent On Forums) Empty Re: [Project] elapsedTime (Total Time Spent On Forums)

Post by smurfavr September 3rd 2015, 1:51 am

There is a bug in the code. Displayed several times weather information.
[Project] elapsedTime (Total Time Spent On Forums) 8335855g

The other bug I noticed in the admin panel.
Profiles / Profile fields

When refresh Profile appear several times in the options Highlight fields.
[Project] elapsedTime (Total Time Spent On Forums) 8335858I

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?
smurfavr
smurfavr
Active Poster

Male Posts : 1883
Reputation : 22
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

[Project] elapsedTime (Total Time Spent On Forums) Empty Re: [Project] elapsedTime (Total Time Spent On Forums)

Post by Angelo Andrei September 17th 2015, 5:23 pm

Good job , JScript !
But that for me is not working so much and it is blocked to 1 second . bwi
Angelo Andrei
Angelo Andrei
New Member

Male Posts : 12
Reputation : 1
Language : Romanian , English & German | HTML
Location : Iecea Mare - România

http://www.help.forumotion.com

Back to top Go down

[Project] elapsedTime (Total Time Spent On Forums) Empty Re: [Project] elapsedTime (Total Time Spent On Forums)

Post by OLC CREATORS September 17th 2015, 6:07 pm

Thanks for sharing @JScript
OLC CREATORS
OLC CREATORS
Forumember

Male Posts : 80
Reputation : 16
Language : English

http://promote.forumotion.com

Back to top Go down

[Project] elapsedTime (Total Time Spent On Forums) Empty Re: [Project] elapsedTime (Total Time Spent On Forums)

Post by mist3r0us_b0y January 12th 2016, 10:25 am

i have added this in punbb but aint working any help sir ?

am having edited template thanks
mist3r0us_b0y
mist3r0us_b0y
Forumember

Male Posts : 747
Reputation : 19
Language : english

http://sh.st/nJRXG

Back to top Go down

[Project] elapsedTime (Total Time Spent On Forums) Empty Re: [Project] elapsedTime (Total Time Spent On Forums)

Post by smurfavr April 30th 2016, 4:34 pm

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.
smurfavr
smurfavr
Active Poster

Male Posts : 1883
Reputation : 22
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

[Project] elapsedTime (Total Time Spent On Forums) Empty Re: [Project] elapsedTime (Total Time Spent On Forums)

Post by SLGray February 23rd 2017, 8:05 am

This will no longer be supported by JScript: https://help.forumotion.com/t151137-in-memory-of-jscript-joao-carlos.


[Project] elapsedTime (Total Time Spent On Forums) Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51453
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum