New button causes existing to stop working


Recommended Posts

I started to get into plugin development and for my first one I wanted to create a simple one with only one button on the docker page.

 

Adding the button works like a charm, but afterwards the button "Container Size" stops working.

 

This is my whole plugin code at the moment:

$('<input/>', {
    type: 'button',
    onclick: 'openShowRunCommandDialog()',
    value: 'Show Run Command',
    style: 'display:none'
}).insertAfter('div.content > input:last');

function openShowRunCommandDialog() {
    alert("Works!");
}

The exception thrown in the console:

70306971_Screenshot2023-06-04at04_22_21.thumb.png.6d1ec7d6114866bc0f99b963126fd743.png

 

The plugin in question: docker.ui-runcmd.

 

Since the insert does exactly what it supposed to do, I am a little bit lost. I guess I am missing something, but I followed other plugins and can't find it :( 

 

Any help is appreciated, thank you :) 

Link to comment

That cannot be all if it is working.  I assume that what you have posted is the contents of a .page file?  - If so it is missing all the HTML elements.   The function being called is a Javascript function and your code shows no HTML elements that put it inside a <script> tag.

Link to comment

Thanks for the reply :) Sorry, I should have mentioned it, that is the content of a js files which I load in a page file. The matching page file looks like the following

 

Menu="Docker"
---
<script src="/plugins/docker.ui-runcmd/include/docker.ui-runcmd.js" />

 

I wanted to split page file and actual code so syntax highlighting in vscode works like expected. For completion, my plg file looks like the following

 

<?xml version="1.0" standalone="yes"?>
<!DOCTYPE PLUGIN [
    <!ENTITY name "docker.ui-runcmd">
    <!ENTITY author "Bastians-Bits">
    <!ENTITY version "2023.06.03j">
    <!ENTITY github "Bastians-Bits/unraid.docker">
    <!ENTITY plugdir "/usr/local/emhttp/plugins/&name;">
    <!ENTITY pluginURL "https://raw.githubusercontent.com/&github;/main/&name;/&name;.plg">
    <!ENTITY md5 "40f329a921c9965eed0f027adc693c4b">
]>

<PLUGIN name="&name;"
    author="&author;"
    version="&version;"
    pluginURL="&pluginURL;"
    icon="docker"
    support="https://github.com/Bastians-Bits/unraid.docker"
    min="6.11.5">

    <CHANGES>
###0000.00.02
- Test 1 Block

###0000.00.01
- Test 2 Blocks

###0000.00.00
- Initial Release
    </CHANGES>

    <!-- Installation -->

    <!-- Remove the old version -->
    <FILE Run="/bin/bash">
        <INLINE>
            rm -f $(ls /boot/config/plugins/&name;/&name;*.txz 2&gt;/dev/null | grep -v '&version;')
        </INLINE>
    </FILE>

    <!-- Download the new file -->
    <FILE Name="/boot/config/plugins/&name;/&name;-&version;.txz" Run="upgradepkg --install-new">
        <URL>https://raw.github.com/&github;/main/archive/&name;/&name;-&version;.txz</URL>
        <MD5>&md5;</MD5>
    </FILE>

    <!-- Post installation -->
    <FILE Run="/bin/bash">
        <INLINE>
            echo ""
            echo "----------------------------------------------------"
            echo " &name; has been installed."
            echo " Version: &version;"
            echo "----------------------------------------------------"
            echo ""
        </INLINE>
    </FILE>

    <!-- De-installation -->

    <!-- Remove the plugin and all files -->
    <FILE Run="/bin/bash" Method="remove">
        <INLINE>
            removepkg &name;-&version;
            rm -rf &plugdir;
            rm -rf /boot/config/plugins/&name;
        </INLINE>
    </FILE>
</PLUGIN>

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.