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.

about random cursor code

View previous topic View next topic Go down

Solved about random cursor code

Post by Michael_vx on Tue Jan 06, 2015 12:59 pm

hi there
i forget to ask about something here
http://help.forumotion.com/t136449-decorate-your-forum-for-halloween
Terrifyingly random cursor :
if i like to add more cursors or use something like cursor.cru
or cursor.ani
is this gonna work ?
i did not try it yet but i like to know before i try
thanks


Last edited by Michael_vx on Fri Jan 23, 2015 1:31 pm; edited 1 time in total

Michael_vx
Forumember

Male Posts : 655
Reputation : 29
Language : Arabic and some English
Location : Egypt

Back to top Go down

Solved Re: about random cursor code

Post by Ange Tuteur on Wed Jan 07, 2015 1:24 am

Hi @Michael_vx,

You can replace the cursors :
Code:
cursor1 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu10.png',
  cursor2 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu11.png',
  cursor3 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu12.png',
  cursor4 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu13.png',
  cursor5 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu14.png',

With any image or valid cursor file that you like. Smile

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: about random cursor code

Post by Michael_vx on Wed Jan 07, 2015 1:28 pm

Very Happy
i think i missed to say more info
if more then 5
is it gonna work ?

Michael_vx
Forumember

Male Posts : 655
Reputation : 29
Language : Arabic and some English
Location : Egypt

Back to top Go down

Solved Re: about random cursor code

Post by Ange Tuteur on Thu Jan 08, 2015 5:30 am

Add more variables and more conditions for multiple cursors.

Example :
Code:
(function() {
 var cursor1 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu10.png',
  cursor2 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu11.png',
  cursor3 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu12.png',
  cursor4 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu13.png',
  cursor5 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu14.png',
  cursor6 = 'image link',
  cursor7 = 'image link',
  cursor8 = 'image link',
  cursor9 = 'image link',
  cursor10 = 'image link',
  r = Math.floor(Math.random()*10);

  if (r == 0) setCursor(cursor1);
  if (r == 1) setCursor(cursor2);
  if (r == 2) setCursor(cursor3);
  if (r == 3) setCursor(cursor4);
  if (r == 4) setCursor(cursor5);
  if (r == 5) setCursor(cursor6);
  if (r == 6) setCursor(cursor7);
  if (r == 7) setCursor(cursor8);
  if (r == 9) setCursor(cursor9);
  if (r == 9) setCursor(cursor10);

 function setCursor(cursor) {
  var s = document.createElement('STYLE');
  s.type = 'text/css';
  s.innerHTML = 'body, *:hover {cursor:url('+cursor+'),auto !important}';
  document.head.appendChild(s);
 }
})();

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: about random cursor code

Post by Michael_vx on Fri Jan 23, 2015 1:04 pm

sorry for delay im *****up with my internet problems Sad
and my last question just so i can make sure that i understand everything
is that line must have same number as the cursor i mean this line
Code:
r = Math.floor(Math.random()*10);
so if i used 15 then ill need to change the 10 to 15 am I right
Code:
if (r == 1) setCursor(cursor2);
this is about the changing ?
i apologize again for my delay
my network is being online like less then a week each month Sad

Michael_vx
Forumember

Male Posts : 655
Reputation : 29
Language : Arabic and some English
Location : Egypt

Back to top Go down

Solved Re: about random cursor code

Post by Ange Tuteur on Fri Jan 23, 2015 1:13 pm

I made a mistake in the last code, but you have it correct.

If you have 15 cursors, you should change the number in r to :
Code:
r = Math.floor(Math.random()*16);
( It should always be 1 number higher than what you have )

These are conditions, if r(the random number) is equal to N we set a cursor. For example :
Code:
if (r == 0) setCursor(cursor1)

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: about random cursor code

Post by Michael_vx on Fri Jan 23, 2015 1:21 pm

is the conditions are must be used ?
if yes
then i don`t have any other question Smile and topic is solved
if no
then tell me more info and still topic solved
thanks a lot

Michael_vx
Forumember

Male Posts : 655
Reputation : 29
Language : Arabic and some English
Location : Egypt

Back to top Go down

Solved Re: about random cursor code

Post by Ange Tuteur on Fri Jan 23, 2015 1:29 pm

Of course the conditions are necessary. They're used to assign a number to the cursor, so to say.

for example, if we want cursor 2 to be used, we'll need to set a condition so it can be used if r is 1.
Code:
if (r == 1) setCursor(cursor2)

You should do this for every new cursor you add. For example, up to 15 cursors, well end with :
Code:
if (r == 16) setCursor(cursor15)

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: about random cursor code

Post by Michael_vx on Fri Jan 23, 2015 1:33 pm

all clear to me Smile
thanks a lot
100%
solved

Michael_vx
Forumember

Male Posts : 655
Reputation : 29
Language : Arabic and some English
Location : Egypt

Back to top Go down

Solved Re: about random cursor code

Post by Ange Tuteur on Fri Jan 23, 2015 2:30 pm

You're welcome

Topic archived

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
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