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.

Dice Rolls results customisation

Go down

Dice Rolls results customisation Empty Dice Rolls results customisation

Post by Kami-sama Wed Jun 07, 2017 11:28 pm

Technical Details


Forum version : #phpBB2
Position : Founder
Concerned browser(s) : Google Chrome
Who the problem concerns : Yourself
Forum link : ( link is hidden, you must reply to see )

Description of problem

Hello! I have couple questions about dice rolls.

1) Following script provided here - https://help.forumotion.com/t141900-quick-reply-display-dice-rolls?highlight=dice - where is the best place to put it in? The scripts page or templates?

2) Is there a way to customise the dice rolls result? Now it says something like:

The member 'Kami-sama' has done the following action : Dice roll
#1 'First' :
#1 Result : 7

I would like to at least translate it (the forum is not in english)

Regards,
Kami-sama
Kami-sama
Forumember

Female Posts : 407
Reputation : 12
Language : EN, RU, DE, LT
Location : Lithuania

View user profile http://hogas.huhohi.com/

Back to top Go down

Dice Rolls results customisation Empty Re: Dice Rolls results customisation

Post by Guest Thu Jun 08, 2017 4:50 pm

The code should be added in the javascript page. About the second problem, the texts can be modified, but I'll need a link to a forum page that display's those texts(I don't use dice rolls on my forum so I don't know how it works).
avatar
Guest
Guest


Back to top Go down

Dice Rolls results customisation Empty Re: Dice Rolls results customisation

Post by Kami-sama Thu Jun 08, 2017 7:57 pm

Hello Wolfuryo,

The issue is basically, you select one account in the forum and automatic result is posted as a message bellow the roll itself with that selected account. There are no specific tags in the message (that would mark it as dice roll result, like special IDs or classes). I have an idea how to just translate it (done that before), but would be interesting to modify the layout itself ://
Kami-sama
Kami-sama
Forumember

Female Posts : 407
Reputation : 12
Language : EN, RU, DE, LT
Location : Lithuania

View user profile http://hogas.huhohi.com/

Back to top Go down

Dice Rolls results customisation Empty Re: Dice Rolls results customisation

Post by Guest Thu Jun 08, 2017 8:41 pm

The only way to modify it would be by using javascript in this case. I don't there are any templates for dice rolls so that's the only way.
avatar
Guest
Guest


Back to top Go down

Dice Rolls results customisation Empty Re: Dice Rolls results customisation

Post by Kami-sama Fri Jun 09, 2017 4:23 pm

But I don't think that it will affect it well. As I mention, there are no specific Tags in the dice roll result post.... I wish there were more templates available.
Kami-sama
Kami-sama
Forumember

Female Posts : 407
Reputation : 12
Language : EN, RU, DE, LT
Location : Lithuania

View user profile http://hogas.huhohi.com/

Back to top Go down

Dice Rolls results customisation Empty Re: Dice Rolls results customisation

Post by Guest Fri Jun 09, 2017 7:50 pm

You'll have to do something like this:
Code:
$(function(){
$(":contains('Text to modify')").text("New text");
})
You have to modify
Code:
Text to modify
with the old text(the default one) and
Code:
New text
with the updated text.
avatar
Guest
Guest


Back to top Go down

Dice Rolls results customisation Empty Re: Dice Rolls results customisation

Post by Kami-sama Fri Jun 09, 2017 8:03 pm

How to check if for example SPAN element contains another SPAN element AND other text?
Example:
Code:
<span><span>Text</span>Other Text</span>


$("span:contains('<span>Text</span>Other Text')").text("New text");


As I tested, it has some issues with <> and " I think.
Kami-sama
Kami-sama
Forumember

Female Posts : 407
Reputation : 12
Language : EN, RU, DE, LT
Location : Lithuania

View user profile http://hogas.huhohi.com/

Back to top Go down

Dice Rolls results customisation Empty Re: Dice Rolls results customisation

Post by Guest Fri Jun 09, 2017 8:08 pm

This should work:
Code:
$("span>span:contains('Text')")
:contains only works with text nodes, not html elements. If you need to select for example a span that contains another span, you have to use span>span


Last edited by Wolfuryo on Fri Jun 09, 2017 8:10 pm; edited 1 time in total
avatar
Guest
Guest


Back to top Go down

Dice Rolls results customisation Empty Re: Dice Rolls results customisation

Post by Kami-sama Fri Jun 09, 2017 8:09 pm

Oh, then it will apply style or whatever to the first span?
Nice Very Happy was looking for that for an hour now ;DD
Kami-sama
Kami-sama
Forumember

Female Posts : 407
Reputation : 12
Language : EN, RU, DE, LT
Location : Lithuania

View user profile http://hogas.huhohi.com/

Back to top Go down

Dice Rolls results customisation Empty Re: Dice Rolls results customisation

Post by Guest Fri Jun 09, 2017 8:12 pm

If you want to apply some styles to that, you should add a class via jquery and than style the elem via css:
Code:
$("span>span:contains('Text')").addClass("class_name")
Or if you want to add an id, you have to use
Code:
.attr("id", "id_name")
avatar
Guest
Guest


Back to top Go down

Dice Rolls results customisation Empty Re: Dice Rolls results customisation

Post by Kami-sama Fri Jun 09, 2017 8:34 pm

I am just concerned, that this will really slow down the page load time....
Kami-sama
Kami-sama
Forumember

Female Posts : 407
Reputation : 12
Language : EN, RU, DE, LT
Location : Lithuania

View user profile http://hogas.huhohi.com/

Back to top Go down

Dice Rolls results customisation Empty Re: Dice Rolls results customisation

Post by Guest Fri Jun 09, 2017 8:38 pm

It should not slow it down too much, no more than half of a millisecond. Make sure to place the script just in a page where it is needed, so that it does not loads on pages where it is no need for it. Smile
avatar
Guest
Guest


Back to top Go down

Back to top

- Similar topics

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