FM Design
Would you like to react to this message? Create an account in a few clicks or log in to continue.

IMPORTANT

FM Design is in read-only mode, please click here for more information.

Latest topics
» Forumactif Edge - Releases
by Ange Tuteur Tue 03 Sep 2019, 11:49

» GIFActif - Giphy Button for the Editor
by Ange Tuteur Wed 08 May 2019, 17:21

» Forum Closure
by Ange Tuteur Mon 01 Jan 2018, 01:28

» Chit Chat Thread
by Valoish Sun 31 Dec 2017, 19:15

» Font/Text background color.
by Valoish Sun 31 Dec 2017, 19:11

» Forumactif Messenger - Instant Message Application for Forumotion
by Wolfuryo Sun 31 Dec 2017, 18:24

» [GAME] Count to One Million!
by brandon_g Fri 29 Dec 2017, 18:58

» Post Cards
by manikbiradar Wed 20 Dec 2017, 07:50

» [GAME] Countdown from 200,000
by Valoish Wed 13 Dec 2017, 23:22

» GeekPolice Tech Support Forums - GeekPolice.net
by Dr Jay Mon 11 Dec 2017, 19:12

» Asking about some plugin for Forumotion
by Dr Jay Mon 11 Dec 2017, 19:10

» [GAME] What are you thinking right now?
by Van-Helsing Sat 09 Dec 2017, 14:51

» Widget : Similar topics
by ranbac Wed 06 Dec 2017, 18:11

» Change the Background of the Forum and put an image and how to make prefixs?
by Clement Wed 06 Dec 2017, 15:19

» Hello from Western Australia
by SarkZKalie Wed 06 Dec 2017, 05:34

Recent Tutorials
Top posting users this month

Who is online?
In total there are 7 users online :: 0 Registered, 0 Hidden and 7 Guests

None

[ View the whole list ]


Most users ever online was 515 on Tue 14 Sep 2021, 15:24

[SOLVED] about code snippet

View previous topic View next topic Go down

omarpop23
omarpop23

Gender : Male
Age : 29
Posts : 140
Points : 3270
Reputation : 25
Location : Egypt
Language : Arabic , English
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge
https://www.facebook.com/omarpop23

Postomarpop23 Mon 18 Apr 2016, 08:35

could i make this button of code snippet for moderator Only Wink

i tried to take the code and put it in module of Forum widgets management
and make his Rights for moderator only but it was failed

could you help me
because i will use this code to make special tables
Ange Tuteur
Ange Tuteur
Administrator
Gender : Male
Posts : 4741
Points : 12057
Reputation : 2375
Location : Pennsylvania
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
https://sethclydesdale.github.io/ https://twitter.com/sethc1995

PostAnge Tuteur Mon 18 Apr 2016, 08:40

You're using the following tutorial, correct ?
https://fmdesign.forumotion.com/t411-how-to-install-the-code-snippet-button

If so, replace
Code:
if ($.sceditor)
in the script with
Code:
if ($.sceditor && _userdata.user_level)
. This will make the button only display for moderators and admins.

if _userdata.user_level is equal to 2 or 1 it'll show the button.
if _userdata.user_level is equal to 0 it wont show the button

In javascript 0 returns false and any number above 0 returns true.
omarpop23
omarpop23

Gender : Male
Age : 29
Posts : 140
Points : 3270
Reputation : 25
Location : Egypt
Language : Arabic , English
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge
https://www.facebook.com/omarpop23

Postomarpop23 Mon 18 Apr 2016, 08:48

should i make it like this ?

Code:
$(function() {
  if ($.sceditor && _userdata.user_level = 1)
    $.sceditor.command.set('inline-code', {
      exec : function() {
        this.insert('[table class="inline-code"][tr][td][code]','[/code][/td][/tr][/table]');
      },
 
      txtExec : function() {
        this.insert('[table class="inline-code"][tr][td][code]','[/code][/td][/tr][/table]');
      },
 
      tooltip : 'Code snippet'
    });
 
    toolbar = toolbar.replace(/code/, 'code,inline-code');
  }
});
document.write('<style type="text/css">.inline-code,.inline-code *{display:inline-block!important}.inline-code .codebox{background-color:rgba(0,0,0,.04)!important;border:1px solid rgba(0,0,0,.05)!important;margin:0;line-height:12px;border-radius:3px}#mpage-body .inline-code .codebox p,.inline-code .codebox dt{display:none!important}.inline-code .codebox code{padding:0!important;margin:0;border:none;background:0 0}.sceditor-button-inline-code div{background-image:url(http://i21.servimg.com/u/f21/18/21/41/30/snippe10.png)!important}</style>');
Ange Tuteur
Ange Tuteur
Administrator
Gender : Male
Posts : 4741
Points : 12057
Reputation : 2375
Location : Pennsylvania
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
https://sethclydesdale.github.io/ https://twitter.com/sethc1995

PostAnge Tuteur Mon 18 Apr 2016, 08:54

No, if you're comparing two values you should use this comparison symbol :
Code:
==

Like this :
Code:
_userdata.user_level == 1
Otherwise if you use 1 equal sign it means you're assigning the value "1" to _userdata.user_level.

If you want it to work for both admins and mods you should write the condition like this :
Code:
if ($.sceditor && _userdata.user_level)
No need for comparison here since guests and members are user_level 0 which evaluates to false.
omarpop23
omarpop23

Gender : Male
Age : 29
Posts : 140
Points : 3270
Reputation : 25
Location : Egypt
Language : Arabic , English
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge
https://www.facebook.com/omarpop23

Postomarpop23 Mon 18 Apr 2016, 09:12

I'm sorry but my language is arabic and i week in English
do you mean that if i need it to Admins only i have to write that
Code:
if ($.sceditor && _userdata.user_level == 1)
Ange Tuteur
Ange Tuteur
Administrator
Gender : Male
Posts : 4741
Points : 12057
Reputation : 2375
Location : Pennsylvania
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
https://sethclydesdale.github.io/ https://twitter.com/sethc1995

PostAnge Tuteur Mon 18 Apr 2016, 09:14

You got it, that's correct ! Yes
omarpop23
omarpop23

Gender : Male
Age : 29
Posts : 140
Points : 3270
Reputation : 25
Location : Egypt
Language : Arabic , English
Browser : Browser : Google Chrome Forum Version : Forum Version : Forumactif Edge
https://www.facebook.com/omarpop23

Postomarpop23 Mon 18 Apr 2016, 09:23

thank you so much Ange
Solved Dance
Ange Tuteur
Ange Tuteur
Administrator
Gender : Male
Posts : 4741
Points : 12057
Reputation : 2375
Location : Pennsylvania
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
https://sethclydesdale.github.io/ https://twitter.com/sethc1995

PostAnge Tuteur Mon 18 Apr 2016, 09:26

No problem ^^
Sponsored content

PostSponsored content

View previous topic View next topic Back to top

Create an account or log in to leave a reply

You need to be a member in order to leave a reply.

Create an account

Join our community by creating a new account. It's easy!


Create a new account

Log in

Already have an account? No problem, log in here.


Log in

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