Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: Enhanced XCode Tags [Userscript]

  1. #11
    Developer RyBack's Avatar
    Join Date
    Apr 2014
    Location
    In Front of the screen
    Posts
    1,595

    Default

    Quote Originally Posted by Zappa View Post
    You can triple-click to select the current line/paragraph. not only inside xcode but in any text from any website.
    Source: Triple-click - Wikipedia
    Ah yeh sorry that is already there. I meant double clicking which is supposed to select a single word.

  2. #12

    Default

    The double-click function works for the xcode blocks and the vBulletin code/html/php code blocks, so I dont think it's a good idea to remove it.
    but if it really annoys you, I can make an userscript for you to disable that.

  3. #13
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,132

    Default

    Test


    #include <iostream>
    using namespace std;
    int main()
    {
    cout << "Hello, World!";
    return 0;
    }

  4. #14

  5. #15
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,132

    Default

    Thanks for writing it man! Appreciate everything you do!

  6. #16
    Über Prodigy & Developer Razo[R]apiD's Avatar
    Join Date
    May 2010
    Location
    Poland, Lublin
    Posts
    3,247

    Default

    If you remember James, I were and I am big fan of dark style, and we had discussions before and ended up using the light one. With this change I can customize it to my preferences instead of forcing everyone to one particular style which is super awesome

  7. #17
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,132

    Default

    Yeah I remember, and this was a really cool addition I agree.

  8. #18

    Default

    How to make this work on my forum?
    I upload all the files to my server and register them in headinclude_bottom

    PHP Code:
    <!-- Modified by James -->
    <
    link rel="stylesheet" href="{vb:stylevar themePath}/xcode/prism-base.css"/>
    <
    link rel="stylesheet" href="{vb:stylevar themePath}/xcode/prism-light.css" id="light_theme" />
    <
    link rel="stylesheet" href="{vb:stylevar themePath}/xcode/prism-dark.css" id="dark_theme" />
    <
    link rel="stylesheet" href="{vb:stylevar themePath}/xcode/xcode-switch.css"/>
    <
    link rel="stylesheet" href="{vb:stylevar themePath}/xcode/fira_code.css">
    <
    script src="{vb:stylevar themePath}/xcode/prism.js"></script>
    <script src="{vb:stylevar themePath}/xcode/prism-mohaa.js?v=2"></script>
    <script src="{vb:stylevar themePath}/xcode/xcode-switch.js"></script>
    <script type="text/javascript">
        function selectElementText(el, win) {
            win = win || window;
            var doc = win.document, sel, range;
            if (win.getSelection && doc.createRange) {
                sel = win.getSelection();
                range = doc.createRange();
                range.selectNodeContents(el);
                sel.removeAllRanges();
                sel.addRange(range);
            } else if (doc.body.createTextRange) {
                range = doc.body.createTextRange();
                range.moveToElementText(el);
                range.select();
            }
        };
    $(function() {
            $('pre').on('dblclick', function(e) {
                e.preventDefault();
                selectElementText(e.currentTarget);
            });
        });
    </script>

    <!-- ------------------------------------------------------ --> 

    Next I will edit the template bbcode_html
    PHP Code:
    <div class="xcode_container">
        <
    pre class="line-numbers language-cpp"<vb:if condition="$vboptions['codemaxlines']"style="height:<vb:if condition="$blockheight<=$vboptions['codemaxlines']">{vb:math {vb:math {vb:raw blockheight}+2}}*{vb:stylevar mid_fontSize}}<vb:else />{vb:math {vb:math {vb:raw blockheight}+1}*{vb:stylevar mid_fontSize}}</vb:if>;"</vb:if>><code class="xcode  language-cpp">{vb:raw code}</code></pre>
    <
    div class="input-container" title="Toggle Color Theme"><input id="darkTheme" class="xcode_switch" type="checkbox"><label class="xcode_switch" for="darkTheme"></label></div></div
    As a result, I get a working html tag. Am I doing the right thing?


    source
    Last edited by burenkov; May 11th, 2020 at 07:17 PM.

  9. #19
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,132

    Default

    Are you doing this for vbulletin?
    You would want to add it in headinclude, not headinclude_bottom. Also you want to make sure the path's are accurate.
    I'm not sure what this

    {vb:stylevar themePath}

    returns.
    You can try doing alert(vb:stylevar themePath) to see if it returns the correct path; otherwise just type in the path to your server.

  10. #20

    Default

    I implemented it myself and everything works, but it is implemented as an html tag

    I implemented it here https://kilerru.com/showthread.php?t...2636#post12636
    Well, the question is, do I have language-cpp registered? And instead of cpp, I understand that there should be a parameter for choosing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •