Good art is a taste, good design is an opinion.


Come as guest, stay as family.
Board Index

Come as guest, stay as family.


You are not connected. Please login or register

Foto

[Javascript] Admin/Mod Comment



Go to page : 1, 2  Next

View previous topic View next topic Go down Message [Page 1 of 2]

1
Offline

  Random Troll

avatar
Punbb Rookie
Punbb Rookie

Tutorial: Adding Admin/Mod Comments

This tutorial makes an Accept/Reject/Information buttons that only admins and moderators can see.

Credits: Ange Tuteur

--> Tutorials, tips and tricks <--
Adding Admin/Mod Comments by RandomTroller 



- Javascript

Code:
[panda=js]jQuery(window).load(function() {
if (typeof _userdata === "undefined") return;
if ((_userdata['user_level'] == '1') || (_userdata["user_level"] == '2')) {
 jQuery('body').append('<div id="fa_modtable" class="select" style="visibility:hidden;width:auto;text-align:left;"><div class="rndmtablex" id="rndmtable1">Solved/Accept</div><div class="rndmtablex" id="rndmtable2">Warning</div><div class="rndmtablex" id="rndmtable3">Information</div>');
 jQuery('.sceditor-group:last-child').after('<div class="sceditor-group" id="fa_modtools"><a class="sceditor-button" title="Mod Tables" onclick="selectWysiwyg(this, \'fa_modtable\');"><div style="background:url(http://i56.servimg.com/u/f56/18/45/41/65/modera10.png) no-repeat center;"></div></a></div>');
 jQuery('#rndmtable1').click(function() { jQuery('#text_editor_textarea').sceditor('instance').insertText('[table class="alert-x solvedbox"][tr][td class="alert-y"]','[/td][/tr][/table]');});
jQuery('#rndmtable2').click(function() { jQuery('#text_editor_textarea').sceditor('instance').insertText('[table class="alert-x warningbox"][tr][td class="alert-y"]','[/td][/tr][/table]');});
 jQuery('#rndmtable3').click(function() { jQuery('#text_editor_textarea').sceditor('instance').insertText('[table class="alert-x informbox"][tr][td class="alert-y"]','[/td][/tr][/table]'); });
 jQuery('.rndmtablex').click(function() { jQuery('#fa_modtable').css('visibility','hidden'); });
 }
});

- CSS

Code:
[panda=css].alert-x {
padding: 14px 17px;
color: #fefefe;
-webkit-box-shadow: 0 1px 5px rgba(0,0,0,0.4);
-moz-box-shadow: 0 1px 5px rgba(0,0,0,0.4);
-khtml-box-shadow: 0 1px 5px rgba(0,0,0,0.4);
box-shadow: 0 1px 5px rgba(0,0,0,0.4);
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
-webkit-border-radius: 5px 5px 5px 5px;
-moz-border-radius: 5px 5px 5px 5px;
-khtml-border-radius: 5px 5px 5px 5px;
border-radius: 5px 5px 5px 5px;
border-style: solid;
border-width: 0;
position: relative;
width: 100%;
font: 14px/20px Museo300Regular,Helvetica,Arial,sans-serif;
}
.alert-y {
padding: 0 20px 0 40px;
}
.informbox {
background: #2fa9f6 url(http://w3lessons.info/demo/metro-style-alert-box/images/info.png) no-repeat 14px 14px;
}

.solvedbox {
background: #7EB62E url(http://w3lessons.info/demo/metro-style-alert-box/images/success.png) no-repeat 14px 14px;
}
.warningbox {
background: #BE1B00 url(http://w3lessons.info/demo/metro-style-alert-box/images/error.png) no-repeat 14px 14px;
}

Visible to admins/moderators? How?:

Code:
[panda=js]jQuery(window).load(function() {
if (typeof _userdata === "undefined") return;
if ((_userdata['user_level'] == '1') || (_userdata["user_level"] == '2')) {
 /* insert admin/mod code here */
 }
});

This code makes the script work only on users who have admin/mod status on the forums, you can also put other codes.

- Screenshot




© PunBB Design
made by Randomtroller
If you have any questions related to this topic create a topic with the following title:
Adding Admin/Mod Comments

Powered by PunBB
Currently 0 users have thanked Random Troll for this post:

2
Offline

  Shadow

avatar
Administrator
Administrator
Nicely done, the tutorial has been accepted.

User is rewarded with the points.

Powered by PunBB
Currently 0 users have thanked Shadow for this post:

3
Offline

  Guest

avatar
Guest
Good one thanks.

Powered by PunBB
Currently 0 users have thanked Guest for this post:

4
Offline

  Ultron

avatar
Punbb Rookie
Punbb Rookie
I think there is something wrong with the code.

When I click on solved it shows up fine. I can't click on warning, but when I click on information it shows a warning and information in one.

Powered by PunBB
Currently 0 users have thanked Ultron for this post:

5
Offline

  Abdalah tupe

avatar
Punbb Rookie
Punbb Rookie
@Ultron wrote:I think there is something wrong with the code.

When I click on solved it shows up fine. I can't click on warning, but when I click on information it shows a warning and information in one.

Same problem Sad

I hop it will fix it

!#!

Powered by PunBB
Currently 0 users have thanked Abdalah tupe for this post:

6
Offline

  Eca|ErcHimA|

avatar
Punbb Rookie
Punbb Rookie
@Abdalah tupe wrote:[link="/t388-javascript-admin-mod-comment#2355"]
@Ultron wrote:I think there is something wrong with the code.

When I click on solved it shows up fine. I can't click on warning, but when I click on information it shows a warning and information in one.

Same problem Sad

I hop it will fix it

!#!
change your JS with code below to fix it
Code:

jQuery(window).load(function() {
if (typeof _userdata === "undefined") return;
if ((_userdata['user_level'] == '1') || (_userdata["user_level"] == '2')) {
 jQuery('body').append('<div id="fa_modtable" class="select" style="visibility:hidden;width:auto;text-align:left;"><div class="rndmtablex" id="rndmtable1">Solved/Accept</div><div class="rndmtablex" id="rndmtable2">Warning</div><div class="rndmtablex" id="rndmtable3">Information</div>');
 jQuery('.sceditor-group:last-child').after('<div class="sceditor-group" id="fa_modtools"><a class="sceditor-button" title="Mod Tables" onclick="selectWysiwyg(this, \'fa_modtable\');"><div style="background:url(http://i56.servimg.com/u/f56/18/45/41/65/modera10.png) no-repeat center;"></div></a></div>');
 jQuery('#rndmtable1').click(function() { jQuery('#text_editor_textarea').sceditor('instance').insertText('[table class="alert-x solvedbox"][tr][td class="alert-y"]','[/td][/tr][/table]');});
jQuery('#rndmtable2').click(function() { jQuery('#text_editor_textarea').sceditor('instance').insertText('[table class="alert-x warningbox"][tr][td class="alert-y"]','[/td][/tr][/table]');});
 jQuery('#rndmtable3').click(function() { jQuery('#text_editor_textarea').sceditor('instance').insertText('[table class="alert-x informbox"][tr][td class="alert-y"]','[/td][/tr][/table]'); });
 jQuery('.rndmtablex').click(function() { jQuery('#fa_modtable').css('visibility','hidden'); });
 }
});

Powered by PunBB
Currently 0 users have thanked Eca|ErcHimA| for this post:

7
Offline

  Guest

avatar
Guest
I've updated the first post with [ic]jQuery('#rndmtable2')[/ic]

Powered by PunBB
Currently 0 users have thanked Guest for this post:

8
Offline

  KiNGphx

avatar
Punbb Guru
Punbb Guru
ok this is pretty call nice Smile thanks for this

Powered by PunBB
Currently 0 users have thanked KiNGphx for this post:

9
Offline

  Abdalah tupe

avatar
Punbb Rookie
Punbb Rookie
@Eca|ErcHimA| wrote:[link="/t388-javascript-admin-mod-comment#2367"]
@Abdalah tupe wrote:[link="/t388-javascript-admin-mod-comment#2355"]
@Ultron wrote:I think there is something wrong with the code.

When I click on solved it shows up fine. I can't click on warning, but when I click on information it shows a warning and information in one.

Same problem Sad

I hop it will fix it

!#!
change your JS with code below to fix it
Code:

jQuery(window).load(function() {
if (typeof _userdata === "undefined") return;
if ((_userdata['user_level'] == '1') || (_userdata["user_level"] == '2')) {
 jQuery('body').append('<div id="fa_modtable" class="select" style="visibility:hidden;width:auto;text-align:left;"><div class="rndmtablex" id="rndmtable1">Solved/Accept</div><div class="rndmtablex" id="rndmtable2">Warning</div><div class="rndmtablex" id="rndmtable3">Information</div>');
 jQuery('.sceditor-group:last-child').after('<div class="sceditor-group" id="fa_modtools"><a class="sceditor-button" title="Mod Tables" onclick="selectWysiwyg(this, \'fa_modtable\');"><div style="background:url(http://i56.servimg.com/u/f56/18/45/41/65/modera10.png) no-repeat center;"></div></a></div>');
 jQuery('#rndmtable1').click(function() { jQuery('#text_editor_textarea').sceditor('instance').insertText('[table class="alert-x solvedbox"][tr][td class="alert-y"]','[/td][/tr][/table]');});
jQuery('#rndmtable2').click(function() { jQuery('#text_editor_textarea').sceditor('instance').insertText('[table class="alert-x warningbox"][tr][td class="alert-y"]','[/td][/tr][/table]');});
 jQuery('#rndmtable3').click(function() { jQuery('#text_editor_textarea').sceditor('instance').insertText('[table class="alert-x informbox"][tr][td class="alert-y"]','[/td][/tr][/table]'); });
 jQuery('.rndmtablex').click(function() { jQuery('#fa_modtable').css('visibility','hidden'); });
 }
});

Thanks its work now with out problem 10/10 . lol

Powered by PunBB
Currently 0 users have thanked Abdalah tupe for this post:

10
Offline

  Ange Tuteur

avatar
Punbb Rookie
Punbb Rookie
Huh, that's funny. I remember writing this script a few months back for someone on the support. Y'know changing the selectors doesn't mean that you wrote the script.

http://help.forumotion.com/t129493-table-widgets-in-quick-reply#867560

Powered by PunBB
Currently 0 users have thanked Ange Tuteur for this post:

11
Offline

  Guest

avatar
Guest
We can put your credits or remove tutorial, it's up to you.

Anyways user is warned for not putting credits.

Powered by PunBB
Currently 0 users have thanked Guest for this post:

12
Offline

  Ange Tuteur

avatar
Punbb Rookie
Punbb Rookie
You can keep it up however, I think the information for the script should be updated, since he obviously didn't know how it works.

The reason it is visible to Administrators and Moderators only is because it uses data from the ForumActif toolbar.

i.e. _userdata

If the toolbar is not activated the script will not work; from this piece :
if (typeof _userdata === "undefined") return;

if userdata is not defined then your buttons will not show up.

The level of users are as follows :
0 = Membre
1 = Administrateur
2 = Modérateur

An example for all three from one of my old scripts for the toolbar :
Code:
jQuery(window).load(function() {
    if (typeof _userdata === "undefined") return;
    /* Administrateur */
    if (_userdata['user_level'] == '1') {
       jQuery('#fa_menulist .fa_separator:eq(1)').after('<li><a href="/LIEN">Supressions des messages</a></li>');
    }
    /* Administrateur, Modérateur */
    if ((_userdata['user_level'] == '1') || (_userdata["user_level"] == '2')) {
       jQuery('#fa_menulist .fa_separator:eq(1)').after('<li><a href="/LIEN">Tchat de l\'équipe</a></li>');
    }
    /* Administrateur, Modérateur, Membre */
    if ((_userdata['user_level'] == '1') || (_userdata["user_level"] == '2') || (_userdata["user_level"] == '0')) {
       jQuery('#fa_menulist .fa_separator:eq(1)').after('<li><a href="/LIEN">Contacter</a></li>');
    }
});

Powered by PunBB
Currently 0 users have thanked Ange Tuteur for this post:

13
Offline

  Abdalah tupe

avatar
Punbb Rookie
Punbb Rookie
Perfect, thank ange for edit Smile

Powered by PunBB
Currently 0 users have thanked Abdalah tupe for this post:

14
Offline

  J0k3R^

avatar
Pemanently Banned
Pemanently Banned
very good tutorial and worked perfect on my forum.


what do u mean /* insert admin/mod code here */
what im supposed to write there to be visible only for admin/mods ?

Powered by PunBB
Currently 0 users have thanked J0k3R^ for this post:

15
Offline

  Virus

avatar
★Moderator★
★Moderator★
@J0k3R^ wrote:[link="/t388-javascript-admin-mod-comment#2651"]very good tutorial and worked perfect on my forum.


what do u mean /* insert admin/mod code here */
what im supposed to write there to be visible only for admin/mods ?

Same question here
you must add the code of the user. ex 1,50,2000 etc. The number of the user "uX".

Powered by PunBB
Currently 0 users have thanked Virus for this post:

16
Offline

  sivastar

avatar
Punbb Rookie
Punbb Rookie
Nice tutorial.

Now im using LGBB, How to add [warning] [/warning] like this codes.

Powered by PunBB
Currently 0 users have thanked sivastar for this post:

17
Offline

  Michael_vx

avatar
Punbb Junior
Punbb Junior
as my test the code working good at my forum
phpbb2
thanks so much for this idea

Powered by PunBB
Currently 0 users have thanked Michael_vx for this post:

18
Offline

  MoiLulu

avatar
Punbb Rookie
Punbb Rookie
Thanks for this, will use Smile

Powered by PunBB
Currently 0 users have thanked MoiLulu for this post:

19
Offline

  Forumotion

avatar
Punbb Rookie
Punbb Rookie
I need to know if you have permission to post this tutorial.

Powered by PunBB
Currently 0 users have thanked Forumotion for this post:

20
Offline

  ddoesmc

avatar
Pemanently Banned
Pemanently Banned
Amazing script, might even add it.

Powered by PunBB
Currently 0 users have thanked ddoesmc for this post:

View previous topic View next topic Back to top Message [Page 1 of 2]


Go to page : 1, 2  Next

Topic URL's

URL
BBcode
HTML

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