[Project] CP_AddOn - Configure scripts - Page 2 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.
+7
Ange Tuteur
SLGray
Van-Helsing
TheCrow
Wagner'
Ramdaman
JScript
11 posters

    [Project] CP_AddOn - Configure scripts

    JScript
    JScript
    Forumember


    Male Posts : 741
    Reputation : 175
    Language : PT-BR, EN
    Location : Brazil

    [Project] CP_AddOn - Configure scripts - Page 2 Empty [Project] CP_AddOn - Configure scripts

    Post by JScript November 29th 2014, 11:11 pm

    First topic message reminder :

    Attention:
    This topic of debate about this project is intended for developers only, not orders of any kind will be accepted, not insist!
    Soon it will be posted a tutorial about the system with the required documentation for developers and the manual for end users who are the admins!

    Note: I do not know much about scripts, so the experts here forgive my errors with JavaScript and jQuery language.

    Hello folks!

    Introduction:

    The title says half of what I wish to speak, but I'll complement:
    In IPBoard platform, for example, when we add a .js code and we need to configure script parameters, we do not change a single line of code, there is only one interface with options, like the image below:
    Spoiler:
    In this way it's easier for the administrator to configure the variables and parameters of a script without even understand the code to edit it!!!

    The purpose of this topic is exactly to bring this facility to Forumotion platform, yes, why not ??? !!!

    But for this to be possible, the code that is added to the control panel should have a kind of header for the system to recognize and add your settings in the new tab added!
    In principle the idea seems confusing / complicated, but it is actually quite simple and functional...

    Look at this example:
    [Project] CP_AddOn - Configure scripts - Page 2 EPqYyWD
    This image shows the "injection" of the script required to have the configuration tab of the scripts.

    Below the configuration of some code:
    [Project] CP_AddOn - Configure scripts - Page 2 Caef0Fu

    But what is needed to get my code compatible with this system?
    Below you will have this answer:

    Header:

    It is the part that identifies the compatibility of your code with the system, formed by XML items, which is understood only with a regex of the system itself, as it is within a comment as the interpreter JavaScript does not recognize XML!
    Example header:
    Code:

    /**
     * @CP_AddOn Addons for the Forumotion control panel
     * @copyright Copyright (C) 2014 JScript
     * @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
     * @engine 1.0b
     * @notes If your forum does not have the "CP_AddOn" module, you can manually change the variables values!

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <mod>
       <header>
          <id>WhereIam</id>
          <title>Where I am?, Topic Active Users (Who is read this topic?)!</title>
          <version>1.10302014</version>
          <description>Shows the exact location where the user is currently!</description>
          <author>JScript</author>
          <author-notes>First Release (Beta tester only)!</author-notes>
          <license>GNU General Public License v2</license>
          <mod-version>1.0.0.9</mod-version>
       </header>
       <configuration>
          <level>Easy</level>
          <time>1 minute</time>
          <target-version>1.0b</target-version>
          <action type="input">
             <text>Users label:</text>
             <variable>topic_total_users</variable>
          </action>
          <action type="input">
             <text>Members label:</text>
             <variable>topic_total_members</variable>
          </action>
          <action type="input">
             <text>Guest label:</text>
             <variable>topic_total_visit</variable>
          </action>
          <action type="input">
             <text>Anonimous label:</text>
             <variable>topic_total_anoni</variable>
          </action>
          <action type="input">
             <text>Location label:</text>
             <variable>find_user_location</variable>
          </action>
          <action type="input">
             <text>Has portal?:</text>
             <variable>has_portal</variable>
          </action>
       </configuration>
    </mod>
    */
    Note: You must respect the XML syntax.

    Current code released for testing:
    Code:

    jQuery(function() {
        jQuery('a[href*="/admin/index.forum?part=admin"]').click(function(event) {
            event.preventDefault();
            document.body.innerHTML = '<iframe name="cpaddons" id="cpaddons" onLoad="CP_AddOns()" src="' + this.href + '" style="position:fixed; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;">IFrame is not supported</iframe>';
          // Clear all temporizations!
            var lastNum = setTimeout(";");
            for (var i = 0; i < lastNum; i++) {
                clearTimeout(i);
            }
          lastNum = setInterval(";");
            for (var i = 0; i < lastNum; i++) {
                clearInterval(i);
            }
        });
    });

    function CP_AddOns() {
        var oIframe = (document.getElementById("cpaddons").contentWindow || document.getElementById("cpaddons").contentDocument);
        oIframe.sContent = {
            sHtml0: '<!-- Module: Configure Scripts - By JScript Brasil at live dot com -->' +
                '<div class="clearfix" id="content">' +
                '   <div style="display: none;" id="menu_close">' +
                '      <p>' +
                '         <a href=\'javascript:ShowHideMenu("menu","menu_close","main","expended_main");\'><img title="Display the menu" alt="Display the menu" src="http://2img.net/i/fa/admin/icones/show_menu.png">' +
                '         </a>' +
                '        </p>' +
                '   </div>' +
                '   <div id="menu">' +
                '      <p id="hide-menu" style="display: block;">' +
                '         <a href=\'javascript:ShowHideMenu("menu","menu_close","main","expended_main");\'><img title="Hide the menu" alt="Hide the menu" src="http://2img.net/i/fa/admin/icones/hide_menu.png">' +
                '         </a>' +
                '      </p>' +
                '      <script type="text/javascript">' +
                '         //&lt;![CDATA[' +
                '         document.getElementById("hide-menu").style.display = "block"; //]]&gt;' +
                '      </script>' +
                '      <div class="header"><img src="http://2img.net/i/fa/admin/icones/puce_bleu.png">&nbsp;Configure Scripts</div>' +
                '      <div class="coins-top">' +
                '         <div class="left-top">&nbsp;&nbsp;<img align="absmiddle" src="http://2img.net/i/fa/admin/icones/small_ico/html.png">&nbsp;JAVASCRIPT</div><img align="right" class="corner-right" src="http://2img.net/i/fa/admin/icones/top-right-gris.png">' +
                '      </div>' +
                '      <br clear="all">' +
                '      <div class="coins-border">' +
                '         <div id="activesubmenu"><a href="javascript:void(0);" onclick="showContent();"><span>Module JavaScript &amp; jQuery</span></a></div>' +
                '      </div>' +
                '      <div class="coins-bottom">' +
                '         <div class="left-bottom"></div><img align="right" src="http://2img.net/i/fa/admin/icones/bottom-right-blanc.png">' +
                '      </div>' +
                '      <br clear="all">' +
                '      <br>' +
                '      <div class="coins-top">' +
                '         <div class="left-top">&nbsp;&nbsp;<img align="absmiddle" src="http://2img.net/i/fa/admin/icones/small_ico/support.png">&nbsp;Suporte</div><img align="right" class="corner-right" src="http://2img.net/i/fa/admin/icones/top-right-gris.png">' +
                '      </div>' +
                '      <br clear="all">' +
                '      <div class="coins-border">' +
                '         <div class="submenu"><a href="javascript:void(0);"><span>Configure Scripts</span></a></div>' +
                '         <div class="submenu"><a href="http://help.forumotion.com/" target="_blank"><span>Forumotion</span></a></div>' +
                '      </div>' +
                '      <div class="coins-bottom">' +
                '         <div class="left-bottom"></div><img align="right" src="http://2img.net/i/fa/admin/icones/bottom-right-blanc.png">' +
                '      </div>' +
                '      <br clear="all">' +
                '   </div>' +
                '   <div id="main">' +
                '      <div id="main-content">' +
                '      </div><!-- closing tag for #main-content -->' +
                '   </div><!-- closing tag for #main -->' +
                '   <div id="tools"></div><!-- closing tag for #tools -->' +
                '</div>',
            sHtml1: '<!-- Module: Configure Scripts - By JScript Brasil at live dot com -->' +
                '<h2><a href="javascript:void(0);" onclick="showContent();">JAVASCRIPT</a></h2>' +
                '<ul class="h2-breadcrumb clearfix">' +
                '    <li class="first">Module JavaScript &amp; jQuery</li>' +
                '</ul>' +
                '<blockquote class="block_left" style="display: none;">' +
                '    <p class="explain">Through this section, you can easily manage the JavaScript files you want to add on your forum pages.' +
                '        <br>' +
                '        <br>Warning: This section is intended for expert users. Be careful, your javascript code must be functional when published. In effect, we compress the code in order to improve your forum pages loading time.</p>' +
                '</blockquote>' +
                '<fieldset>' +
                '   <legend>Javascript Codes</legend>' +
                '   <table width="85%" align="center" cellspacing="1" cellpadding="4" border="0" class="tablesorter" id="listJs">' +
                '      <thead>' +
                '         <tr>' +
                '            <th id="column_title" class="headerSort">Name<span class="imgSort">&nbsp;</span></th>' +
                '            <th id="column_address" class="headerSort">Version<span class="imgSort">&nbsp;</span></th>' +
                '            <th id="column_date" class="headerSort headerSortUp">Author<span class="imgSort">&nbsp;</span></th>' +
                '            <th>Edit</th>' +
                '         </tr>' +
                '      </thead>' +
                '      <tbody>' +
                '         <!-- Code list! -->' +
                '         <tr id="load_list">' +
                '            <td><ul class="h2-breadcrumb clearfix" style="margin: 0px;"><br><li class="first">Filling Out the list, wait... <span id="code_num"></span></li></ul></td>' +
                '         </tr>' +
                '      </tbody>' +
                '   </table>' +
                '   <br>' +
                '</fieldset>',
            sHtml2: '<!-- Module: Configure Scripts - By JScript Brasil at live dot com -->' +
                '<h2><a href="javascript:void(0);" onclick="showContent();">JAVASCRIPT</a></h2>' +
                '<ul class="h2-breadcrumb clearfix">' +
                '    <li class="first"><a href="javascript:void(0);" onclick="showContent();">Module JavaScript &amp; jQuery</a>' +
                '    </li>' +
                '    <li>Code configuration</li>' +
                '</ul>' +
                '<blockquote class="block_left" style="margin: 5px;">' +
                '    <p class="explain" id="description"></p>' +
                '</blockquote>' +
                '<br>' +
                '<fieldset id="placement"></fieldset>' +
                '<fieldset id="config">' +
                '   <legend>Configurations</legend>' +
                '</fieldset>'
        };

        script = oIframe.document.createElement("script");
        script.type = "text/javascript";
        script.innerHTML =
            'TID = jQuery(\'a[href^="/admin/index.forum?tid="]\').attr("href").split("=")[1];' +
            'jQuery(function() {' +
            '   jQuery("#tabs ul").append(\'<li class="jsconfig"><a href="javascript:void(0);" onclick="showContent();"><span>Configure Scripts</span></a></li>\');' +
            '});' +
          'function showContent() {' +
            '   jQuery("#activetab").removeAttr("id");' +
            '   jQuery("li.jsconfig").attr("id", "activetab");' +
            '   jQuery("#wrapper").html(sContent.sHtml0);' +
            '   jQuery("#main-content").html(sContent.sHtml1);' +
            '   var whait_msg = jQuery("#load_list"),' +
            '      code_num = jQuery("#code_num");' +
            '   jQuery.ajax({' +
            '      url: "/admin/index.forum?part=modules&sub=html&mode=js&extended_admin=1&tid=" + TID,' +
            '      type: "get",' +
            '      async: true,' +
            '      dataType: "html",' +
            '      success: function (response, status, xhr) {' +
            '         if (xhr.status == 200) {' +
            '            var response = jQuery(response),' +
            '               oTarget = response.find("#listJs tbody:first tr"),' +
            '               ilen = oTarget.length,' +
            '               index = 0,' +
          '               count = ilen,' +
            '               last_update = response.find("#listJs tbody:first tr:first td:eq(2) > span").text(),' +
            '               saved_update = sessionStorage.getItem("listJs_update");' +
            '            if (saved_update == last_update) {' +
            '               jQuery("#listJs tbody").html(sessionStorage.getItem("listJs_html"));' +
            '               return false;' +
            '            }' +
            '            code_num.text(count);' +
            '            for (; index < ilen; index++) {' +
            '               var oThis = jQuery(oTarget[index]),' +
            '                  sHref = oThis.find(\'a[href^="/admin"]\').attr("href");' +
          '               (function(index, sHref) {' +
            '                  setTimeout(function() {' +
            '                     jQuery.ajax({' +
            '                        url: sHref,' +
            '                        type: "get",' +
            '                        async: true,' +
            '                        dataType: "html",' +
            '                        success: function (response, status, xhr) {' +
            '                           if (xhr.status == 200) {' +
            '                              var js_content = jQuery(response).find("#js_content").val(),' +
            '                                 aXML = /(?:<mod>([\\s\\S]*?)<[/]mod>)/.exec(js_content);' +
            '                              if (aXML !== null) {' +
            '                                 aXML = jQuery.parseXML(aXML[0]),' +
            '                                    tr =' +
            '                                    \'<tr>\' +' +
            '                                       \'<td class="row1">\' + jQuery(aXML).find("id").text() + \'</td>\' +' +
            '                                       \'<td class="row1">\' + jQuery(aXML).find("version").text() + \'</td>\' +' +
            '                                       \'<td class="row1 url_ltr">\' + jQuery(aXML).find("author").text() + \'</td>\' +' +
            '                                       \'<td align="center" class="row1">\' +' +
            '                                          \'<a href="javascript:void(0);" onClick="CP_AddOns_Edit(&quot;\' + encodeURIComponent(response) + \'&quot;);"><img title="" alt="" src="http://2img.net/i/fa/admin/icones/editer.png"></a>\' +' +
            '                                       \'</td>\' +' +
            '                                    \'</tr>\';' +
            '                                 jQuery("#listJs tbody").append(tr);' +
            '                              }' +
            '                           }' +
            '                        }' +
            '                     });' +
            '                     code_num.text(count--);' +
            '                  }, index * 200);' +
          '               }(index, sHref));' +
            '            }' +
          '            setTimeout(function() {' +
            '               if (jQuery("#listJs tbody tr").length == 1) {' +
            '                  whait_msg.find("li").text("There is no scripts compatible with the system or with the current version!");' +
          '                  sessionStorage.setItem("listJs_update", 0);' +
            '               } else {' +
          '                  whait_msg.hide();' +
            '                  sessionStorage.setItem("listJs_update", last_update);' +
            '                  sessionStorage.setItem("listJs_html", jQuery("#listJs tbody").html());' +
          '               }' +
          '            }, index * 300);' +
            '         }' +
            '      }' +
            '   });' +
          '}' +
            'function CP_AddOns_Edit(response) {' +
            '   jQuery("#main-content").html(sContent.sHtml2);' +
            '   response = jQuery(decodeURIComponent(response));' +
            '   var js_content = response.find("#js_content").val(),' +
            '      aXML = /(?:<mod>([\\s\\S]*?)<[/]mod>)/.exec(js_content);' +
            '   jQuery("#placement").html(response.find("#formenvoi fieldset").html());' +
            '   try {' +
            '      aXML = jQuery(jQuery.parseXML(aXML[0]));' +
          '      jQuery("#description").html(aXML.find("id").text() + "<br>Description: " + aXML.find("description").text());' +
            '      var oTarget = aXML.find("action");' +
            '      oTarget.each(function () {' +
            '         var oThis = jQuery(this),' +
            '            xVariable = oThis.find("variable").text();' +
            '         if (xVariable) {' +
            '            var patt = new RegExp("(?:" + xVariable + "\\\\s*=\\\\s*([\\\\s\\\\S]*?);)", "g");' +
            '            var xValue = patt.exec(js_content);' +
            '            if (xValue !== null) {' +
            //'               console.log("Variable: " + xVariable + "\\nValue: " + xValue[1]);' +
            '               var dl =' +
            '                  \'<dl><dt><label>\' + oThis.find("text").text() + \'</label></dt>\' +' +
            '                     \'<dd><input type="text" name="\' + xVariable + \'" data-last=\' + xValue[1] + \' size="\' + xValue[1].length + \'" maxlength="\' + (xValue[1].length * 2) + \'" value=\' + xValue[1] + \'> </dd>\' +' +
            '                  \'</dl>\';' +
            '               jQuery("#config").append(dl);' +
            '            }' +
            '         }' +
            '      });' +
            '      jQuery("#config").append(\'<div class="DIV_BTNS"><input id="js_save" type="submit" value="Save" name="submit" class="icon_ok"></div>\');' +
          '      $("#js_save").click(function() {' +
          '         var oTarget = jQuery("#config dl dd input"),' +
          '            ilen = oTarget.length,' +
          '            index = 0;' +
          '         for (; index < ilen; index++) {' +
          '            var oThis = jQuery(oTarget[index]),' +
          '               js_search = new RegExp("(" + oThis.attr("name") + "\\\\s*=\\\\s*)([\\\\u0022\\\\u0027]|)(?:[\\\\s\\\\S]*?)([\\\\u0022\\\\u0027]|);", "g");' +
          '               js_replace = oThis.val();' +
          '            js_content = js_content.replace(js_search, "$1$2" + js_replace + "$3;");' +
          '         }' +
          '         var oTarget = jQuery("#placement input[name=\'js_placement[]\']"),' +
          '            ilen = oTarget.length,' +
          '            index = 0,' +
          '            ID = response.find("#formenvoi input[name=\'page\']").val(),' +
          '            js_placement = [];' +
          '         for (; index < ilen; index++) {' +
          '            var oThis = jQuery(oTarget[index]);' +
          '            if (oThis.is(":checked")) {' +
          '               js_placement.push(oThis.val());' +
          '            }' +
          '         }' +
          '         jQuery.post("/admin/index.forum?part=modules&sub=html&mode=js_edit&id=" + ID + "&extended_admin=1&tid=" + TID, {' +
          '            title: jQuery("#placement input[name=\'title\']").val(),' +
          '            js_placement: js_placement,' +
          '            type: 0,' +
          '            page: ID,' +
          '            content: js_content,' +
          '            mode: "save",' +
          '            submit: 1' +
          '         }).done(function() {' +
          '            jQuery("#main-content").html(\'<div class="successbox"><center><h3>Information</h3></center><p>Your JavaScript code has been changed.<br><br><a href="javascript:void(0);" onclick="showContent();">Click here to go back to CP_AddOn.</a></p></div>\')' +
          '         }).fail(function() {' +
          '            jQuery("#main-content").html(\'<div class="errorbox"><center><h3>Error</h3></center><p>You must fill in the required fields.</p></div>\')' +
          '         });' +
          '      });' +
            '      if ($("#js_placement_all").is(":checked")) {' +
            '         $("#js_placement_index").attr({' +
            '            checked: false,' +
            '            disabled: true' +
            '         });' +
            '         $("#js_placement_portal").attr({' +
            '            checked: false,' +
            '            disabled: true' +
            '         });' +
            '         $("#js_placement_viewforum").attr({' +
            '            checked: false,' +
            '            disabled: true' +
            '         });' +
            '         $("#js_placement_viewtopic").attr({' +
            '            checked: false,' +
            '            disabled: true' +
            '         });' +
            '         $("#js_placement_gallery").attr({' +
            '            checked: false,' +
            '            disabled: true' +
            '         });' +
            '      }' +
            '      $("#js_placement_all").click(function() {' +
            '         if ($(this).is(":checked")) {' +
            '            $("#js_placement_index").attr({' +
            '               checked: false,' +
            '               disabled: true' +
            '            });' +
            '            $("#js_placement_portal").attr({' +
            '               checked: false,' +
            '               disabled: true' +
            '            });' +
            '            $("#js_placement_viewforum").attr({' +
            '               checked: false,' +
            '               disabled: true' +
            '            });' +
            '            $("#js_placement_viewtopic").attr({' +
            '               checked: false,' +
            '               disabled: true' +
            '            });' +
            '            $("#js_placement_gallery").attr({' +
            '               checked: false,' +
            '               disabled: true' +
            '            });' +
            '         } else {' +
            '            $("#js_placement_index").attr("disabled", false);' +
            '            $("#js_placement_portal").attr("disabled", false);' +
            '            $("#js_placement_viewforum").attr("disabled", false);' +
            '            $("#js_placement_viewtopic").attr("disabled", false);' +
            '            $("#js_placement_gallery").attr("disabled", false);' +
            '         }' +
            '      });' +
            '   } catch (e) {' +
            '      console.log(e);' +
            '   }' +
            '}';
        oIframe.document.getElementsByTagName("head")[0].appendChild(script);
    };
    Simply create a new JavaScript with placement on all pages, so the control panel link will be intercepted and thus the code goes into action on the panel!


    Module: Installer scripts!

    This module aims to automate the process of manually add scripts in JavaScript section !!!
    You can install a .zip file downloaded on the local computer and my code extracts the zip content and install according to the instructions in it!
    In this way the script is automatically created in the JavaScript section, with the name and placement already set the installer file.

    The installer XML that is inside the zip will support search and replace, search and add after or before in templates, thus eliminates the manual editing of them!

    Well that's it and those who wish and be able to contribute more ideas and code to further implement the project, feel free to help.


    If you wish to see a code compatible with this system, add the code below with placement on all pages:
    Code:

    /**
     * @CP_AddOn Addons for the Forumotion control panel
     * @copyright Copyright (C) 2014 JScript
     * @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
     * @engine 1.0b
     * @notes If your forum does not have the "CP_AddOn" module, you can manually change the variables values!

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <mod>
       <header>
          <id>WhereIam</id>
          <title>Where I am?, Topic Active Users (Who is read this topic?)!</title>
          <version>1.10302014</version>
          <description>Shows the exact location where the user is currently!</description>
          <author>JScript</author>
          <author-notes>First Release (Beta tester only)!</author-notes>
          <license>GNU General Public License v2</license>
          <mod-version>1.0.0.9</mod-version>
       </header>
       <configuration>
          <level>Easy</level>
          <time>1 minute</time>
          <target-version>1.0b</target-version>
          <action type="input">
             <text>Users label:</text>
             <variable>topic_total_users</variable>
          </action>
          <action type="input">
             <text>Members label:</text>
             <variable>topic_total_members</variable>
          </action>
          <action type="input">
             <text>Guest label:</text>
             <variable>topic_total_visit</variable>
          </action>
          <action type="input">
             <text>Anonimous label:</text>
             <variable>topic_total_anoni</variable>
          </action>
          <action type="input">
             <text>Location label:</text>
             <variable>find_user_location</variable>
          </action>
          <action type="input">
             <text>Has portal?:</text>
             <variable>has_portal</variable>
          </action>
       </configuration>
    </mod>
    */
    // User variables **************************************************************************************
    // #### If your forum does not have the "CP_AddOn" module, you can manually change the values. ####
    topic_total_users = 'user(s) are reading this topic';
    topic_total_members = 'members';
    topic_total_visit = 'guests and';
    topic_total_anoni = 'anonymous users';
    find_user_location = "Getting the user's location, wait...";
    has_portal = 1; // #### If your forum does not have a "Portal", change the value to 0! ####
    // ******************************************************************************************************

    // System variables!
    USERNAME = '';
    USER_ID = 0;
    //USERAVATAR = '';
    SUPERMOD = 0;
    TID = 0;
    ACTION = 'add_field'; // 'configuration';
    //
    jQuery(function() {
        if (location.pathname.indexOf('/u') !== -1) {
            jQuery('dt:contains("WhereIam")').closest('dl').remove();
        } else if (location.pathname.indexOf('editprofile' !== -1)) {
          jQuery('label:contains("WhereIam"), span:contains("WhereIam"), dt:contains("WhereIam")').closest('dl, tr').remove();
        }
        if (_userdata.session_logged_in) {
            USERNAME = _userdata.username;
            USER_ID = _userdata.user_id;
            // USERAVATAR = jQuery(_userdata.avatar).attr('src');
            SUPERMOD = _userdata.user_level; // Is Admin/Mod ?
            TID = jQuery('a[href*="tid="]').attr('href').split('tid=')[1].split('&')[0]; //Get the var {TID}
        }
        // console.clear();
        console.log("/**************************************************************************");
        console.log("* Module: 'Where I am?' and 'Topic Active Users (Who is read this topic?)'!");
        console.log("* Description: Shows the exact location where the user is currently.");
        console.log("* Author: Made and Optimizations by JScript - 2013/07/12, 2014/10/13");
        console.log("* Version: First Release (Beta tester only)!");
        console.log("/**************************************************************************");
        console.log('USERNAME: ' + USERNAME);
        console.log("USER_ID: " + USER_ID);
        console.log("TID: " + TID);

        var oWereIam = {
            pathname: location.pathname,
            total_users: 0,
            oSubForum: '',
            oTarget: 0,
          sIndex: '/forum',
            oHtml: {
             phpbb2: '<!-- ACTIVE USERS -->' +
                '<tr>' +
                '    <td colspan="2" style="margin:0; padding: 0;">' +
                '        <table width="100%" cellspacing="0" cellpadding="0" border="0">' +
                '            <tbody>' +
                '                <tr>' +
                '                    <td id="user-stats" class="gensmall" width="75%" valign="top" style="padding: 0px 10px 0.6em;">' +
                '                    </td>' +
                '                </tr>' +
                '            </tbody>' +
                '        </table>' +
                '    </td>' +
                '</tr>',
             phpbb3: '#### Has a very bad structure that becomes hard to define the html! ####',
                punbb: '<!-- ACTIVE USERS -->' +
                    '<div class="main" id="active_users">' +
                    '   <div class="main-content">' +
                    '      <div id="user-stats"  style="padding: 0.6em 1em;">' +
                    '      </div>' +
                    '   </div>' +
                    '</div>',
             invision: '<!-- ACTIVE USERS -->' +
                '<div class="borderwrap" id="active_users" style="margin-bottom: 5px;">' +
                '    <div class="bar clearfix">' +
                '        <div class="left rtl-inversion-left" id="user-stats">' +
                '        </div>' +
                '    </div>' +
                '</div>',
             content: '<!-- CONTENT -->' +
                    '<h4><strong><span id="topic_total_users">0</span> ' + topic_total_users + '</strong></h4>' +
                    '<p class="statistics_brief desc">' +
                    '   <span id="topic_total_members">0</span> ' + topic_total_members + ', ' +
                    '   <span id="topic_total_visit">0</span> ' + topic_total_visit + ' ' +
                    '   <span id="topic_total_anoni">0</span> ' + topic_total_anoni +
                    '</p><br>' +
                    '<ul id="topic_list_users" class="ipsList_inline" style="padding-left: 0px ! important;"></ul>'
            }
        };

        if (_userdata.session_logged_in) {
            WhereIam() // Where I am?
        }

        if (oWereIam.pathname.indexOf('/t') !== -1) {
          /* Forum versions! */
          var phpBB2 = jQuery('#content-container table.forumline:last tbody > tr:eq(1)');
          var phpBB3 = jQuery('#main-content > div.h3:last');
          var punbb = jQuery('#pun-info');
          var invision = jQuery('#main-content .borderwrap:last');

          if (phpBB2.length) {
             jQuery(oWereIam.oHtml.phpbb2).insertBefore(phpBB2);
          } else if(phpBB3.length) {
             jQuery(oWereIam.oHtml.punbb).insertBefore(phpBB3);
          } else if(punbb.length) {
             jQuery(oWereIam.oHtml.punbb).insertBefore(punbb);
          } else if(invision.length) {
             jQuery(oWereIam.oHtml.invision).insertBefore(invision);
          };
          jQuery('#user-stats').html(oWereIam.oHtml.content);

          if (!has_portal) oWereIam.sIndex = '/';

            oWereIam.oSubForum = jQuery('.pun-crumbs.noprint a.nav[href^="/f"], #navstrip a.nav[href^="/f"], .pathname-box:first a.nav[href^="/f"], span.nav a.nav[href^="/f"]').attr('href');
            try {
                jQuery.get(oWereIam.oSubForum, function(data) {
                oWereIam.oTarget = jQuery('#stats > a, #info_open td[colspan="2"]:not(.catBottom) .gensmall a, #main-content > a[href^="/u"], .activeusers-box .row1 a', data);

                }).always(function() {
                    if (oWereIam.oTarget.length !== 0) {
                        var guest = Math.floor(Math.random() * (5 - 0));
                        jQuery('#topic_total_visit').text(guest);
                        searchActiveUsers(oWereIam.oTarget, 0, oWereIam.oTarget.length, 0, guest);
                    }
                });
            } catch (e) {
             // console.log(e);
            }
        }

        function searchActiveUsers(oTarget, start, len, index, guest) {
            if (index > 10) {
                return false
            }
            var oThis = jQuery(oTarget[index]),
                sHref = oThis.attr('href'),
                $JScript;

            if ((sHref !== undefined) || (sHref.length !== 0)) {
                var user_name = '<a href="' + sHref + '">' + oThis.html() + '</a>';

                jQuery.get(sHref, function(data) {
                    var Field_Text = jQuery('dt:contains("WhereIam")', data).closest('dl').find('div.field_uneditable').text();

                    try {
                        $JScript = JSON.parse(Field_Text.replace(/'/g, '"'));
                    } catch (e) {
                        // console.log(e);
                    }
                    console.log(Field_Text);
                }).always(function() {
                    try {
                        if ($JScript.path.url == oWereIam.pathname) {
                            if (oWereIam.total_users == 0) {
                                $('#topic_list_users').html('');
                                $('#topic_list_users').append(user_name);
                            } else {
                                $('#topic_list_users').append(', ' + user_name);
                            }
                            oWereIam.total_users++;
                            $('#topic_total_users').text(oWereIam.total_users + guest);
                            $('#topic_total_members').text(oWereIam.total_users);
                        }
                    } catch (e) {
                        // console.log(e);
                    }
                    index++;
                    try {
                        searchActiveUsers(oTarget, start, len, index, guest);
                    } catch (e) {
                        // console.log(e);
                    }
                });
            }
        }
    });

    function WhereIam() {
        jQuery.ajaxSetup({
            async: false
        });
        jQuery.get('/profile?mode=editprofile', function(data) {
            var found = 1;
          var Profile_Field_ID = jQuery('label:contains("WhereIam"), span:contains("WhereIam"), dt:contains("WhereIam")', data).closest('dl, tr').find('textarea').attr('id');

            console.log("Profile_Field_ID: " + Profile_Field_ID);

            if ((Profile_Field_ID == undefined) && (SUPERMOD == 1)) {
                jQuery.post("/admin/index.forum?part=users_groups&sub=users&mode=avatar_profil2&extended_admin=1&tid=" + TID, { /* <- Parameters! */
                    /* Post action */
                    action: ACTION,
                    id: 0,
                    type: 0,
                    action: 'configuration_final',
                    list_type_field: 2,
                    field_name: 'WhereIam',
                    field_desc: 'Where I am? - Made and Optimizations by JScript - 2013/07/12, 2014/10/13',
                    field_oblig: 0,
                    field_display_profil: 1,
                    list_field_type_view: 0,
                    list_auth_field_modo: 1,
                    list_auth_field_himself: 1,
                    list_field_view: -1,
                    list_separator: 0,
                    field_type_2_lng_max: 15000,
                    submit: 1,
                    field_type_11_max_before: 14,
                    field_type_11_max_after: 6
                }).done(function() {
                    console.log('Add profile field done!');
                    jQuery.get('/profile?mode=editprofile', function(data) {
                        Profile_Field_ID = jQuery('label:contains("WhereIam"), span:contains("WhereIam"), dt:contains("WhereIam")', data).closest('dl, tr').find('textarea').attr('id');
                    }).fail(function() {
                        console.log('Failed to get field Profile_Field_ID!');
                        found = 0;
                    });
                }).fail(function() {
                    console.log('Add profile field Fail!');
                    found = 0;
                });
            }
            if (found) {
                var sTitle = jQuery('.pun-crumbs:first p strong:last').text();
                if ((sTitle == 'undefined') || (sTitle == '')) sTitle = location.pathname;

                var now = new Date;
                var $JScript = {
                    appInfo: {
                        module: 'Where I am?',
                        description: 'Shows the exact location where the user is currently.',
                        author: 'JScript',
                        version: '1.00',
                        release: '2014/10/13'
                    },
                    userInfo: {
                        oscpu: navigator.oscpu,
                        appName: navigator.appName,
                        language: navigator.language,
                        userAgent: navigator.userAgent
                    },
                    path: {
                        title: sTitle,
                        url: location.pathname,
                        param: location.search,
                        state: '0',
                        time: now.getHours() + ":" + now.getMinutes(),
                        date: now.getDate() + "/" + now.getMonth() + "/" + now.getFullYear()
                    }
                };

                jQuery.post("/ajax_profile.forum?jsoncallback=?", {
                    id: Profile_Field_ID.substring(16, Profile_Field_ID.length),
                    user: USER_ID,
                    active: "1",
                    content: '[["' + Profile_Field_ID + '", "' + JSON.stringify($JScript).replace(/"/g, "'") + '"]]',
                    tid: TID
                }, function(data) {
                    console.log("OK: ajax_profile, userID = " + USER_ID);
                }, "json").fail(function() {
                    console.log("error: ajax_profile, userID = " + USER_ID);
                });
            }
        }).done(function() {
            // Done!!!
        }).fail(function() {
            console.log('Failed to get field Profile_Field_ID');
        });
        jQuery.ajaxSetup({
            async: true
        });
    }
    This code shows you who is reading a topic!

    JS


    Last edited by JScript on December 4th 2014, 4:28 pm; edited 2 times in total (Reason for editing : Improvements in the code!)
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51515
    Reputation : 3519
    Language : English
    Location : United States

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by SLGray December 4th 2014, 3:14 am

    When I added the code, the tab did not appear until I had check to see if the profile field had been created (one minute).



    [Project] CP_AddOn - Configure scripts - Page 2 Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    JScript
    JScript
    Forumember


    Male Posts : 741
    Reputation : 175
    Language : PT-BR, EN
    Location : Brazil

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by JScript December 4th 2014, 4:23 am

    But this is related to the code of tests used to "shows you who is reading a topic"!!!
    Turns out that this code only creates the field in the profile only once, after that it only records the location of member in this profile field.

    I could see the address of your forum?

    JS
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51515
    Reputation : 3519
    Language : English
    Location : United States

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by SLGray December 4th 2014, 4:50 am

    Sorry, I posted about the wrong one.  I mean it takes time for the Configure Script tab to appear.



    [Project] CP_AddOn - Configure scripts - Page 2 Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by Van-Helsing December 4th 2014, 10:19 am

    Hello,
    The script "who is reading the topic" maybe have a bug. Last night I tested it with my staff and it shows only to each one as member who reading the topic only its name and the other members who read the topic their names are not displayed as members. Instead of this the script shown them as guests.
    JScript
    JScript
    Forumember


    Male Posts : 741
    Reputation : 175
    Language : PT-BR, EN
    Location : Brazil

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by JScript December 4th 2014, 4:32 pm

    SLGray wrote:Sorry, I posted about the wrong one.  I mean it takes time for the Configure Script tab to appear.
    I changed a few things in the code, try to see if improved the time for you ok?

    @Black-Shadow
    I ask you again to leave this topic just to we treat the main subject "that is the new tab in the ACP" ok?
    Create a new topic and report problems related to other codes.

    So long,

    JS
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by Van-Helsing December 4th 2014, 9:47 pm

    JScript wrote:
    SLGray wrote:Sorry, I posted about the wrong one.  I mean it takes time for the Configure Script tab to appear.
    I changed a few things in the code, try to see if improved the time for you ok?


    @Black-Shadow
    I ask you again to leave this topic just to we treat the main subject "that is the new tab in the ACP" ok?
    Create a new topic and report problems related to other codes.

    So long,

    JS
    Ok Js,
    I am leaving this topic as you asked.

    Regards,
    Black-Shadow.
    JScript
    JScript
    Forumember


    Male Posts : 741
    Reputation : 175
    Language : PT-BR, EN
    Location : Brazil

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by JScript December 4th 2014, 10:31 pm

    Black-Shadow wrote:Ok Js,
    I am leaving this topic as you asked.
    I did not ask you to leave the topic, but posts that are not related to the main theme!

    I'm waiting for you to create new topics with your questions about this and other code ok?

    JS
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51515
    Reputation : 3519
    Language : English
    Location : United States

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by SLGray December 5th 2014, 8:46 pm

    The tab appears faster now.



    [Project] CP_AddOn - Configure scripts - Page 2 Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    JScript
    JScript
    Forumember


    Male Posts : 741
    Reputation : 175
    Language : PT-BR, EN
    Location : Brazil

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by JScript December 5th 2014, 8:58 pm

    SLGray wrote:The tab appears faster now.
    Hello, I was waiting for your response, thanks for the info!

    JS
    Rhino.Freak
    Rhino.Freak
    Helper
    Helper


    Male Posts : 1248
    Reputation : 104
    Language : English
    Location : Mumbai, India

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by Rhino.Freak December 18th 2014, 6:12 am

    Hello, I just noticed, this is the bug. I want this removed, how?

    [Project] CP_AddOn - Configure scripts - Page 2 Untitl25

    I really don't want to get rid of the Pop-up profile (made by @"Ange Tueter") as well :/
    JScript
    JScript
    Forumember


    Male Posts : 741
    Reputation : 175
    Language : PT-BR, EN
    Location : Brazil

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by JScript December 18th 2014, 11:38 am

    @Rhino.Freak
    If you are referring to the field called WereIAm and thinks is a "bug" the CP_AddOn project, it is because you did not pay attention to what is written!

    See the image below that I pulled out of my post:
    [Project] CP_AddOn - Configure scripts - Page 2 0btZT8h
    Read carefully what is marked and you will see that it refers to a sample code for you could prove and understand the functioning of the project!

    To remove this new field, you simply remove the example code and manually delete the field in your ACP.

    I hope you understand,

    JS
    Rhino.Freak
    Rhino.Freak
    Helper
    Helper


    Male Posts : 1248
    Reputation : 104
    Language : English
    Location : Mumbai, India

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by Rhino.Freak December 18th 2014, 1:22 pm

    I see so its not a functional code? Deleting it wpnt cause problems?
    JScript
    JScript
    Forumember


    Male Posts : 741
    Reputation : 175
    Language : PT-BR, EN
    Location : Brazil

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by JScript December 18th 2014, 2:28 pm

    Rhino.Freak wrote:I see so its not a functional code?
    Of course it is! See what he is capable of doing:
    [Project] CP_AddOn - Configure scripts - Page 2 XM182HG
    But is designed to profile with default template!

    Rhino.Freak wrote:Deleting it wpnt cause problems?
    Of course not!

    JS

    {Lone~Wolf}
    {Lone~Wolf}
    New Member


    Male Posts : 9
    Reputation : 3
    Language : English/Arabic/Spanish/Polish
    Location : Alaska

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by {Lone~Wolf} April 1st 2015, 6:45 am

    Hello JScript,
    As you can see, I am a new user here..I signed up as a special thanks to you for this new project you are working on, I am here especially for this idea you brought to us.

    I understand this is just a project, not a tutorial.. and no one shall use it as of now unless for development and giving you a hand?

    Indeed I tried it and I liked the way how it works, but as a project it is still need to be well constructed as it does seem to appear and disappear anytime I update the page. Also it does take long to appear for the first time when publishing it on JS section. But all in all, no one has done what you've done.. Congratulations!

    Though I hope if the Administrator and the founder of Forumactive allow this great idea to be brought out to us, because most likely a permission is needed :/

    Anyway, I switched my forum to different languages and yet the codes you provided did not translate automatically. I can help out to do the translating process for you if you needed to three different languages aside from English.

    When will you actually publish the tutorial, and would you allow a person to take it to another support forum for others to benefit too?

    Cheers my friend, looking forward to hear back from ya.

    Kind Regards,
    {L~W}
    JScript
    JScript
    Forumember


    Male Posts : 741
    Reputation : 175
    Language : PT-BR, EN
    Location : Brazil

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by JScript April 1st 2015, 12:58 pm

    @{Lone~Wolf}
    Hello, I'm glad you liked my code!

    The current code I have is more updated and fixes several bugs that this is the topic, was also added variables to support translations.

    Well, even if I finish the code and he proves fully functional, it will only be a tutorial here if the staff here will approve!

    Soon I will publish the new code that I did,

    JS
    {Lone~Wolf}
    {Lone~Wolf}
    New Member


    Male Posts : 9
    Reputation : 3
    Language : English/Arabic/Spanish/Polish
    Location : Alaska

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by {Lone~Wolf} April 1st 2015, 4:13 pm

    JScript wrote:@{Lone~Wolf}
    Hello, I'm glad you liked my code!

    The current code I have is more updated and fixes several bugs that this is the topic, was also added variables to support translations.

    Well, even if I finish the code and he proves fully functional, it will only be a tutorial here if the staff here will approve!

    Soon I will publish the new code that I did,

    JS
    Indeed, wish you the best of luck. So all in all, this project you are working on will allow a person to add another fields in the section or just be limited to the:
    [Project] CP_AddOn - Configure scripts - Page 2 XM182HG

    ?
    JScript
    JScript
    Forumember


    Male Posts : 741
    Reputation : 175
    Language : PT-BR, EN
    Location : Brazil

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by JScript April 1st 2015, 5:07 pm

    @{Lone~Wolf}

    Will not be limited only to the code belonging to picture you posted, but to any code, since the code has the header that will make it compatible with the system!
    I had to post this sample code so that you could test the system.

    JS
    {Lone~Wolf}
    {Lone~Wolf}
    New Member


    Male Posts : 9
    Reputation : 3
    Language : English/Arabic/Spanish/Polish
    Location : Alaska

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by {Lone~Wolf} April 2nd 2015, 2:45 am

    JScript wrote:@{Lone~Wolf}

    Will not be limited only to the code belonging to picture you posted, but to any code, since the code has the header that will make it compatible with the system!
    I had to post this sample code so that you could test the system.

    JS

    That's what I though! Looking forward for this to be published! Very good
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by Van-Helsing July 3rd 2015, 12:03 pm

    Hello,
    @JScript the CP_AddOn Addon tab is not appearing on Greek forums, is it only for English forums?
    JScript
    JScript
    Forumember


    Male Posts : 741
    Reputation : 175
    Language : PT-BR, EN
    Location : Brazil

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by JScript July 3rd 2015, 1:15 pm

    @Black-Shadow
    Hello!
    It should work in all languages, but do not worry about this because I consider this code very deprecated!

    I am testing a new and improved version with more features that will integrate the ACP JavaScript module.

    Comming soon,

    JS
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by Van-Helsing July 3rd 2015, 1:57 pm

    Ok @JScript,
    Thank you we are waiting for the new improved code.
    Hello
    Rhino.Freak
    Rhino.Freak
    Helper
    Helper


    Male Posts : 1248
    Reputation : 104
    Language : English
    Location : Mumbai, India

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by Rhino.Freak December 23rd 2015, 8:47 pm

    I wish more tutorials take use of this add on system.
    Ivan Ivanov
    Ivan Ivanov
    Forumember


    Male Posts : 34
    Reputation : 2
    Language : Russian
    Location : Russia

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by Ivan Ivanov February 6th 2017, 9:55 am

    And when it will work again?
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51515
    Reputation : 3519
    Language : English
    Location : United States

    [Project] CP_AddOn - Configure scripts - Page 2 Empty Re: [Project] CP_AddOn - Configure scripts

    Post by SLGray February 23rd 2017, 8:04 am

    This will no longer be supported by JScript: https://help.forumotion.com/t151137-in-memory-of-jscript-joao-carlos.



    [Project] CP_AddOn - Configure scripts - Page 2 Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.