The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Continuation of the spooky ghost counter topic

View previous topic View next topic Go down

Solved Continuation of the spooky ghost counter topic

Post by yayayes on November 27th 2014, 1:19 pm

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


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


Thank you!
Yaya

yayayes
Forumember

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

Back to top Go down

Solved Re: Continuation of the spooky ghost counter topic

Post by Ange Tuteur on November 27th 2014, 5: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 :


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.

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 #

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Continuation of the spooky ghost counter topic

Post by yayayes on November 28th 2014, 11:52 pm

It's all clear! Thank you againAnge Tuteur Smile

yayayes
Forumember

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

Back to top Go down

Solved Re: Continuation of the spooky ghost counter topic

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

You're welcome ^^

Topic archived

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

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

View previous topic View next topic Back to top


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