Widget code help please. Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

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.
3 posters

    Widget code help please.

    avatar
    Kumari
    Forumember


    Female Posts : 63
    Reputation : 1
    Language : English
    Location : Australia

    Solved Widget code help please.

    Post by Kumari October 16th 2014, 5:36 am

    Hey there,

    I was wondering if there is any way to allow only a certain member group to view a single Widget?
    For example, I wish to create a chat box (Using cbox.com) for each of my member groups where only that specific group can enter it. Whether this is by password or simply that the other member groups cannot view it entirely. Is there a way to do this? Can someone help please. I'm not too great with coding, I know only the basics.

    I have researched it and I can only find a code to disallow a member group to view all of my widgets but that's not what I'm looking for.

    This is my webpage: Kumari


    Last edited by Kumari on October 18th 2014, 3:58 pm; edited 1 time in total
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: Widget code help please.

    Post by _Twisted_Mods_ October 16th 2014, 6:00 am

    Admin panel>Modules>Portal&widgets

    choose either forum widgets or portal widgets witch ever your trying to add permission to

    click structure

    remove the widgets from the structure that you only want certain groups to see

    now scroll down to

    Addition of existing widgets < for default widgets

    or

    Addition/deletion of personal widgets < for custom made widgets

    choose your rights to who you want to be allowed to see it and click add widget

    organize the widgets back to the way you want them then click save below the widget structure
    avatar
    Kumari
    Forumember


    Female Posts : 63
    Reputation : 1
    Language : English
    Location : Australia

    Solved Re: Widget code help please.

    Post by Kumari October 16th 2014, 6:11 am

    thetwistedkilla wrote:Admin panel>Modules>Portal&widgets

    choose either forum widgets or portal widgets witch ever your trying to add permission to

    click structure

    remove the widgets from the structure that you only want certain groups to see

    now scroll down to

    Addition of existing widgets < for default widgets

    or

    Addition/deletion of personal widgets < for custom made widgets

    choose your rights to who you want to be allowed to see it and click add widget

    organize the widgets back to the way you want them then click save below the widget structure
    Thankyou for such a quick response, but this is not wht I am looking for. This only gives the option to allow/disallow 

    Administrators Moderators Members Guests"




    I want to allow specific member groups which I have created AKA "Nayati, Kostas" (groups taken from my site) to only view certain Widgets and was wondering if there is a code for this? Perhaps a code that allows a Widget to be password protected?
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: Widget code help please.

    Post by _Twisted_Mods_ October 16th 2014, 6:21 am

    i will look around see what i can figure out but think your gonna need some javascript for this.. so you will prob have to wait for ange to gets on
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Widget code help please.

    Post by Ange Tuteur October 16th 2014, 10:14 pm

    Hello Kumari,

    It's partially possible, however, protection by JavaScript(passwords) can be easily bypassed. I do have an Idea which could be useful, you would just need to supply me with what the widget contents will be. Wink
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: Widget code help please.

    Post by _Twisted_Mods_ October 16th 2014, 11:59 pm

    ange if he has toolbar active couldn't u grab the user group the person is in 

    and do like

    if grouptitle="admin" then
    element.display=normal
    else
    element.display=none
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Widget code help please.

    Post by Ange Tuteur October 17th 2014, 12:24 am

    A portion of _userdata is still accessible even if the toolbar is disabled. ^^

    I was thinking something like.. :
    Code:
    <script type="text/javascript">
    _widget = new Object();
    _widget.allowed = ['Ange Tuteur', 'Test Dummy'];
    _widget.title = 'Widget Title';
    _widget.content = 'Widget Content';
    </script>
    <div id="theWidget" class="module" style="display:none">
      <div class="inner">
        <span class="corners-top"><span></span></span>
        <div id="theTitle" class="h3"></div>
     <span id="widgetContent"></span>
        <span class="corners-bottom"><span></span></span>
      </div>
    </div>
    <script type="text/javascript">(function() {
      var allowed = false, memb = _widget.allowed;
      for (i=0; i<memb.length; i++) if (memb[i] === _userdata.username) var allowed = true;
      if (allowed === true) {
        document.getElementById('theWidget').style.display = '';
     document.getElementById('theTitle').innerHTML = _widget.title;
     document.getElementById('widgetContent').innerHTML = _widget.content;
      } else return;
    })();</script>

    It's for phpbb3(html), but I'll write it for phpbb2 for them when I know what they want. Smile
    avatar
    Kumari
    Forumember


    Female Posts : 63
    Reputation : 1
    Language : English
    Location : Australia

    Solved Re: Widget code help please.

    Post by Kumari October 17th 2014, 2:59 am

    Ange Tuteur wrote:Hello Kumari,

    It's partially possible, however, protection by JavaScript(passwords) can be easily bypassed. I do have an Idea which could be useful, you would just need to supply me with what the widget contents will be. Wink

    Ohhh an idea is better than none! hha We can play aroun with it as much as need be Smile

    Here is the code that will be in the widget.

    It is a chatbox.
    As I said before, there will be a few with some different chat boxes in, so perhaps once we work out what works, can you please mark the place where the cbox code would go?

    Code:
    <script type="text/javascript">
    function popcbox() {
      cboxwin = window.open("","Cbox","width=200,height=380,toolbar=no,scrollbars=no,status=no,resizable=yes");
      cboxwin.document.write('<html><head><title>Cbox</title></head><frameset rows="*,75" frameborder="0" framespacing="0">');
    cboxwin.document.write('<frame marginwidth="2" marginheight="2" src="http://www3.cbox.ws/box/?boxid=3412857&amp;boxtag=9ew4kz&amp;sec=main" noresize="true" scrolling="auto" name="cboxmain3-3412857" style="border: 0px solid;"/>');
    cboxwin.document.write('<frame marginwidth="2" marginheight="2" src="http://www3.cbox.ws/box/?boxid=3412857&amp;boxtag=9ew4kz&amp;sec=form" noresize="true" scrolling="no" name="cboxform3-3412857" style="border: 0px solid;border-top:0px"/>');
      cboxwin.document.write('</frameset>');
      cboxwin.document.write('<noframes>Cbox needs frames!</noframes></html>');
      try {
        x = screen.width;
        y = screen.height;
        cboxwin.moveTo(Math.max((x/2)-100, 0), Math.max((y/3)-190));
      } catch (e) {};
    }
    </script>


    <a href="JavaScript:popcbox();">Pop up my Cbox</a>
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Widget code help please.

    Post by Ange Tuteur October 17th 2014, 3:59 am

    Try adding this to a widget :
    Titles : Your choice
    Use a table type : No
    Code:
    <script type="text/javascript">
    _widget_allowed = ['Member 1', 'Member2', 'Member 3'];
    </script>
    <div id="cbContent"></div>
    <script type="text/javascript">(function() {
      var allowed = false, memb = _widget_allowed;
      for (i=0; i<memb.length; i++) if (memb[i] === _userdata.username) var allowed = true;
      if (allowed === true) {
        popcbox = function() {
          cboxwin = window.open("","Cbox","width=200,height=380,toolbar=no,scrollbars=no,status=no,resizable=yes");
          cboxwin.document.write('<html><head><title>Cbox</title></head><frameset rows="*,75" frameborder="0" framespacing="0">');
          cboxwin.document.write('<frame marginwidth="2" marginheight="2" src="http://www3.cbox.ws/box/?boxid=3412857&amp;boxtag=9ew4kz&amp;sec=main" noresize="true" scrolling="auto" name="cboxmain3-3412857" style="border: 0px solid;"/>');
          cboxwin.document.write('<frame marginwidth="2" marginheight="2" src="http://www3.cbox.ws/box/?boxid=3412857&amp;boxtag=9ew4kz&amp;sec=form" noresize="true" scrolling="no" name="cboxform3-3412857" style="border: 0px solid;border-top:0px"/>');
          cboxwin.document.write('</frameset>');
          cboxwin.document.write('<noframes>Cbox needs frames!</noframes></html>');
          try {
            x = screen.width;
            y = screen.height;
            cboxwin.moveTo(Math.max((x/2)-100, 0), Math.max((y/3)-190));
          } catch (e) {};
        }
        document.getElementById('cbContent').innerHTML = '<a href="JavaScript:popcbox();">Pop up my Cbox</a>';
      } else return;
    })();</script>

    At the top you will see :
    Code:
    _widget_allowed = ['Member 1', 'Member2', 'Member 3']

    This is a list of the users allowed to view the widget. Add their username to the list and they can view the widget. Note : The name must be spelt exactly the same as it appears on the forum. The name must be between the single quotes and multiple names must be separated by a comma.
    avatar
    Kumari
    Forumember


    Female Posts : 63
    Reputation : 1
    Language : English
    Location : Australia

    Solved Re: Widget code help please.

    Post by Kumari October 17th 2014, 7:13 am

    OMG! THIS IS PERFECT!!! Thank you sooooo much Ange! I'm in love with it! Very Happy

    EDIT: I made another on with a different chat box in it for different members but the two keep clashing. One either won't work or one will just disappear all together when they're both place as working widgets.

    I have even tried to put one on the left and one on the right sides of my forum, but it still doesnt work together, is there any way to change this please?

    Maybe I made a mistake in the code when making a new one?

    Here are the two codes:

    Kostas: 
    Code:
    <script type="text/javascript">
    _widget_allowed = ['Bladewolf', 'Nammia', 'Ashlyn', 'Aleria', 'Pandora', 'Zigan', 'Benjamin Nekishu', 'Charon', 'Kostas Modertor'];
    </script>
    <div id="cbContent">
    </div><script type="text/javascript">(function() {
      var allowed = false, memb = _widget_allowed;
      for (i=0; i<memb.length; i++) if (memb[i] === _userdata.username) var allowed = true;
      if (allowed === true) {
        popcbox = function() {
          cboxwin = window.open("","Kostas Chat","width=200,height=380,toolbar=no,scrollbars=no,status=no,resizable=yes");
          cboxwin.document.write('<html><head><title>Kostas Chat</title></head><frameset rows="*,75" frameborder="0" framespacing="0">');
          cboxwin.document.write('<frame marginwidth="2" marginheight="2" src="http://www3.cbox.ws/box/?boxid=3412857&amp;boxtag=9ew4kz&amp;sec=main" noresize="true" scrolling="auto" name="cboxmain3-3412857" style="border: 0px solid;"/>');
          cboxwin.document.write('<frame marginwidth="2" marginheight="2" src="http://www3.cbox.ws/box/?boxid=3412857&amp;boxtag=9ew4kz&amp;sec=form" noresize="true" scrolling="no" name="cboxform3-3412857" style="border: 0px solid;border-top:0px"/>');
          cboxwin.document.write('</frameset>');
          cboxwin.document.write('<noframes>Cbox needs frames!</noframes></html>');
          try {
            x = screen.width;
            y = screen.height;
            cboxwin.moveTo(Math.max((x/2)-100, 0), Math.max((y/3)-190));
          } catch (e) {};
        }
        document.getElementById('cbContent').innerHTML = '<a href="JavaScript:popcbox();">Kostas Chat</a>';
      } else return;
    })();</script>


    Nayati: 



    Code:
    <script type="text/javascript">
    _widget_allowed = ['Benjamin Nekishu', 'Kara', 'Charon', 'Freya Dark', 'Griffin', 'SunRise'];
    </script>
    <div id="cbContent">
    </div><script type="text/javascript">(function() {
      var allowed = false, memb = _widget_allowed;
      for (i=0; i<memb.length; i++) if (memb[i] === _userdata.username) var allowed = true;
      if (allowed === true) {
    popcbox = function popcbox() {
      cboxwin = window.open("","Nayati Chat","width=200,height=380,toolbar=no,scrollbars=no,status=no,resizable=yes");
      cboxwin.document.write('<html><head><title>Nayati Chat</title></head><frameset rows="*,75" frameborder="0" framespacing="0">');
    cboxwin.document.write('<frame marginwidth="2" marginheight="2" src="http://www3.cbox.ws/box/?boxid=3415280&amp;boxtag=55l4xf&amp;sec=main" noresize="true" scrolling="auto" name="cboxmain3-3415280" style="border:#000000 1px solid;"/>');
    cboxwin.document.write('<frame marginwidth="2" marginheight="2" src="http://www3.cbox.ws/box/?boxid=3415280&amp;boxtag=55l4xf&amp;sec=form" noresize="true" scrolling="no" name="cboxform3-3415280" style="border:#000000 1px solid;border-top:0px"/>');
      cboxwin.document.write('</frameset>');
      cboxwin.document.write('<noframes>Cbox needs frames!</noframes></html>');
      try {
        x = screen.width;
        y = screen.height;
        cboxwin.moveTo(Math.max((x/2)-100, 0), Math.max((y/3)-190));
      } catch (e) {};
    }
    document.getElementById('cbContent').innerHTML = '<a href="JavaScript:popcbox();">Nayati Chat</a>';
      } else return;
    })();</script>



    I had it working at one stage, but when I tried to move them I lost it completely. I've been trying different ways to make it work or the past hour and half but I've come up with nothing Sad
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Widget code help please.

    Post by Ange Tuteur October 17th 2014, 3:07 pm

    This is probably because the variables and ids are the same, try replacing your Nayati one by :
    Code:
    <script type="text/javascript">
    _widget_allowed2 = ['Benjamin Nekishu', 'Kara', 'Charon', 'Freya Dark', 'Griffin', 'SunRise'];
    </script>
    <div id="cbContent2">
    </div><script type="text/javascript">(function() {
      var allowed = false, memb = _widget_allowed2;
      for (i=0; i<memb.length; i++) if (memb[i] === _userdata.username) var allowed = true;
      if (allowed === true) {
    popcbox = function popcbox() {
      cboxwin = window.open("","Nayati Chat","width=200,height=380,toolbar=no,scrollbars=no,status=no,resizable=yes");
      cboxwin.document.write('<html><head><title>Nayati Chat</title></head><frameset rows="*,75" frameborder="0" framespacing="0">');
    cboxwin.document.write('<frame marginwidth="2" marginheight="2" src="http://www3.cbox.ws/box/?boxid=3415280&amp;boxtag=55l4xf&amp;sec=main" noresize="true" scrolling="auto" name="cboxmain3-3415280" style="border:#000000 1px solid;"/>');
    cboxwin.document.write('<frame marginwidth="2" marginheight="2" src="http://www3.cbox.ws/box/?boxid=3415280&amp;boxtag=55l4xf&amp;sec=form" noresize="true" scrolling="no" name="cboxform3-3415280" style="border:#000000 1px solid;border-top:0px"/>');
      cboxwin.document.write('</frameset>');
      cboxwin.document.write('<noframes>Cbox needs frames!</noframes></html>');
      try {
        x = screen.width;
        y = screen.height;
        cboxwin.moveTo(Math.max((x/2)-100, 0), Math.max((y/3)-190));
      } catch (e) {};
    }
    document.getElementById('cbContent2').innerHTML = '<a href="JavaScript:popcbox();">Nayati Chat</a>';
      } else return;
    })();</script>

    I changed _widget_allowed to _widget_allowed2

    and cbContent to cbContent2

    You can use a text document to easily replace these. Widget code help please. 1852325475

    Sorry I should of let you know this. Shocked

    Let me know if that works for you. Smile
    avatar
    Kumari
    Forumember


    Female Posts : 63
    Reputation : 1
    Language : English
    Location : Australia

    Solved Re: Widget code help please.

    Post by Kumari October 18th 2014, 1:02 am

    That's okay! No need to worry, I thought it had something to do with something like that but I just didn't know what exactly to change; but alas It still did not work Sad

    When I'm clicking on either of the chats, it's still showing only one. It doesn't seem to matter which one I click. Which ever is below the other seems to be the primary eg:

    I have them set on the web page as follows:

    Nayati Chat (On top)
    Kostas Chat (On bottom)

    But when I open either of them they automatically go to Kostas Chat; and vise versa when the Nayati Chat is on the bottom.
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Widget code help please.

    Post by Ange Tuteur October 18th 2014, 1:06 am

    Oooh, I think I forgot to change the function name popcbox() to popcbox2().

    Try now :
    ( Replace the same widget ^^ )
    Code:
    <script type="text/javascript">
    _widget_allowed2 = ['Benjamin Nekishu', 'Kara', 'Charon', 'Freya Dark', 'Griffin', 'SunRise'];
    </script>
    <div id="cbContent2">
    </div><script type="text/javascript">(function() {
      var allowed = false, memb = _widget_allowed2;
      for (i=0; i<memb.length; i++) if (memb[i] === _userdata.username) var allowed = true;
      if (allowed === true) {
    popcbox = function popcbox2() {
      cboxwin = window.open("","Nayati Chat","width=200,height=380,toolbar=no,scrollbars=no,status=no,resizable=yes");
      cboxwin.document.write('<html><head><title>Nayati Chat</title></head><frameset rows="*,75" frameborder="0" framespacing="0">');
    cboxwin.document.write('<frame marginwidth="2" marginheight="2" src="http://www3.cbox.ws/box/?boxid=3415280&amp;boxtag=55l4xf&amp;sec=main" noresize="true" scrolling="auto" name="cboxmain3-3415280" style="border:#000000 1px solid;"/>');
    cboxwin.document.write('<frame marginwidth="2" marginheight="2" src="http://www3.cbox.ws/box/?boxid=3415280&amp;boxtag=55l4xf&amp;sec=form" noresize="true" scrolling="no" name="cboxform3-3415280" style="border:#000000 1px solid;border-top:0px"/>');
      cboxwin.document.write('</frameset>');
      cboxwin.document.write('<noframes>Cbox needs frames!</noframes></html>');
      try {
        x = screen.width;
        y = screen.height;
        cboxwin.moveTo(Math.max((x/2)-100, 0), Math.max((y/3)-190));
      } catch (e) {};
    }
    document.getElementById('cbContent2').innerHTML = '<a href="JavaScript:popcbox2();">Nayati Chat</a>';
      } else return;
    })();</script>
    avatar
    Kumari
    Forumember


    Female Posts : 63
    Reputation : 1
    Language : English
    Location : Australia

    Solved Re: Widget code help please.

    Post by Kumari October 18th 2014, 3:57 pm

    Yay! All fixed! Thank you so much! They work perfectly!!!! Very Happy <3<3
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Widget code help please.

    Post by Ange Tuteur October 18th 2014, 5:28 pm

    You're welcome ! Widget code help please. 1852325475

    Topic archived

    If you have any problems you can let us know by creating a new topic. Have a great weekend ! Smile