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.
The forum of the forums
2 posters

    Continuation of the spooky ghost counter topic

    yayayes
    yayayes
    Forumember


    Female Posts : 49
    Reputation : 1
    Language : Thai
    Location : Bangkok, London & Hong Kong

    Solved Continuation of the spooky ghost counter topic

    Post by yayayes November 27th 2014, 3:19 pm

    I have been following the spooky ghost topic and find it very interesting. Ange Tuteur mentioned at some point that he has an idea with a profile field. If I'm correct it never get mentioned, but I'm still interested to know anyway. 


    URL: https://help.forumotion.com/t136605-spooky-ghost-counter-and-rank#921735 


    Thank you! 
    Yaya
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Continuation of the spooky ghost counter topic

    Post by Ange Tuteur November 27th 2014, 7:17 pm

    Hello yayayes,

    Try this :
    Go to Administration Panel > Users and groups > Profiles > Create new profile field

    Make sure it has the following content :
    Continuation of the spooky ghost counter topic Captur93

    Check after creating to make sure the default is 0, save, and then replace the content for everyone.

    Next, create a new script :
    Modules > JavaScript codes management > Create a new script

    Title : get field data
    Placement : In all the pages
    Paste the code below and submit :
    Code:
    /\/u\d+/.test(window.location.pathname) && $(function() {
      $('[id^="field_id"]').on('click',function() {
        alert('Copy the following to a textpad.\n\n id : '+ $(this).attr('id') + '\n name : '+ $(this).find('[name^="profile"]').attr('name'));
      });
    });

    This is a tool to help you get the profile data of that field. Go to your user profile and click your new profile field, it should alert you with some data that you should copy to a textpad.
    Continuation of the spooky ghost counter topic Captur94

    Once you have that data copied somewhere you can remove that script.


    Now, create a new script for the ghosts :

    Title : Your choice
    Placement : Your choice
    Code:
    $(function() {
      var chance = 10, id = 'field_id', name = 'profile_field', content = new Array();
      
      if (_userdata.user_id === -1) return; // excludes guests
      if (/\/profile/.test(window.location.pathname)) $(function(){$('dl:has(#'+name+')').remove()});
      
      // Happy Halloween from Forumotion !
      var ghost = document.createElement('IMG'), actif = false;
      ghost.src = 'http://i39.servimg.com/u/f39/18/21/60/73/ghost10.png';
      ghost.setAttribute('style','position:fixed;top:0%;left:0%;z-index:99999;display:none;');
      document.body.appendChild(ghost);
      
      ghost.onclick = function() {
        var storage = window.localStorage;
        ghost.style.display = 'none';
        if (storage.ghostClicks) {
          storage.ghostClicks = Number(storage.ghostClicks) + 1;
          content.push(new Array(name, storage.ghostClicks));
          $.post('/ajax_profile.forum?jsoncallback=?', {
            id : id.substring(8, id.length),
            user : _userdata.user_id,
            active : '1',
            content : $.toJSON(content),
            tid : document.getElementById('logout').href.replace(/.*tid=(.*?)&.*/,'$1')
          },function(data){}, 'json');
        }
        else if (storage) {
          $('body').append('<div id="contU" style="display:none"></div>');
          $('#contU').load('/u'+_userdata.user_id+' #' + id + ' .field_uneditable', function() {storage.ghostClicks = Number($(this).text()) + 1});
        }
      };
      window.setInterval('_spook_ghost()', 1000);
      _spook_ghost = function() {
        if (random(chance) === 0 && actif === false) {
          actif = true;
          ghost.style.left = random(76) + '%';
          ghost.style.top = random(76) + '%';
          ghost.style.width = '48px';
          ghost.style.opacity = '1';
          ghost.style.display = '';
          _animation_ghost = window.setInterval(function() {
            if (Number(ghost.style.opacity) <= 0) {
              ghost.style.display = 'none';
              window.clearInterval(_animation_ghost);
              return actif = false;
            }
            ghost.style.width = Number(ghost.style.width.replace(/px/,'')) + 10 + 'px';
            ghost.style.opacity = Number(ghost.style.opacity) - 0.01;
          },1);
        }
      };
      function random(val) { return Math.floor(Math.random() * val) };
    });

    Modifications :

    Chance : This is the chance for the ghost to appear. Lower = higher chance, higher = lower chance.

    id : remember that id you copied before ? Well, replace field_id with that id. for example my id was field_id2, so that's what I'll write.

    name : You guessed it the last data you copied. Replace profile_field with that name. Mine was profile_field_13_2, so that's what I'll write.

    When finished, save, and you should be good. thumright

    Oh, for some extra protection, so the members can't edit the field use this CSS :
    Display > Colors > CSS
    Code:
    #field_id2 .field_editable, #field_id2 .ajax-profil_edit, #field_id2 .ajax-profil_valid { display:none !important }
    Just replace field_id2 with your id, make sure to keep the hash #
    yayayes
    yayayes
    Forumember


    Female Posts : 49
    Reputation : 1
    Language : Thai
    Location : Bangkok, London & Hong Kong

    Solved Re: Continuation of the spooky ghost counter topic

    Post by yayayes November 29th 2014, 1:52 am

    It's all clear! Thank you again Ange Tuteur Smile
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Continuation of the spooky ghost counter topic

    Post by Ange Tuteur November 29th 2014, 3:04 am

    You're welcome ^^

    Topic archived

    If you have any problems do not hesitate to open a new topic. Smile

      Current date/time is September 23rd 2024, 4:19 pm