Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Q&A] Plugin Design

Featured Replies

Greetings everyone,

 

I've just finished producing my first plugin, and learned a LOT from reviewing existing plugins and getting help from those with more knowledge than myself.  However I'm a bit stuck moving forward as I can't find examples of how to do some things...so I'd like to start a consolidated thread for plugin builders to ask/answer questions and help spread information about how to best to accomplish advanced tasks.

 

Right now, I have one big question with a few sub-parts ;).

 

1> I've noticed that my settings page is getting rather cluttered, and right now I have no less than 4 plugins in various stages of completion.  Would it be better to build a "master" plugin that takes care of installing/configuring them under the one umbrella...or continue to produce individual plugins for small tasks?

 

1a> If one plugin would be better, I get into the technical bit of the first question.  I'm trying to create a select list and show/hide div's based on the selection...then I would create a new form in each div.  However, I /think/ the function needs to be in the header, which I don't have access to as a plugin designer.  I know that simpleFeatures solved this with a lot of external .js and .css work, but I'm trying to keep things as simple as possible.

 

From what I understand, it should be as simple as:

<script type="text/javascript">
  function showhide(element){
       document.getElementById(element).style.display = element=="SphinxSearch"?"block":"none";
       document.getElementById(element).style.display = element=="NewznabCron"?"block":"none";
  }
</script>

   ...content...

<select id="type" onchange:"showhide(this.value);">
      <option value="SphinxSearch">SphinxSearch</option>
       <option value="NewznabCron">Newznab Cron</option>
</select>

<div id='SphinxSearch' style="display:block;">
   ...content...
</div>
<div id='NewznabCron' style="display:none;">
   ...content....
</div>

 

This sets the first page up properly, with the second div hidden.  However changing the selection in the dropdown doesn't change the page at all.

 

Thanks for any help!

a quick answer to your questions :)

 

1: i would always vote for single plugins, so the users can directly choose, what should be installed. to make the settings page cleaner, you can create your own sections. see the unplugged plugins or simple features for an example.

 

1a: the js code doesn't need to be in the header. it can be anywhere in the html code.

but your code a small errors. try this:

 

 

<select id="type" onchange="showhide(this.value);">
      <option value="SphinxSearch">SphinxSearch</option>
       <option value="NewznabCron">Newznab Cron</option>
</select>

 

also, if you save the setting somewhere, you should run the javascript on every page refresh, so the correct parts are hidden or visible.

  • Author

Now that I've (I think) sorted out my unraid crash issue (from General Support)...I can thank you properly for your response Benni-chan.

 

With the help if you and Influencer (Thanks for the IM last night man!).  I have a working prototype of a bundled-addon to group a lot of small things into.

 

What I need to accomplish before I can test it properly:

 

1> Sort out if "title" is the only predefined css we have..or come up with a different settings for the plugin "top bar" as it looks odd in the unRAID GUI with two gray title bars exactly the same.

2> Install packages from an rc file (shouldn't be hard, just have to work out a safe way to do it.)

3> Handle multiple forms in javascript

4> Build good "tests" to see if various bits are installed.

 

The goal at the end of this is to have a lot of "little" things bundled into one addon.  Right now the list is:

 

1> Sphinx Search

2> Newznab Cron

3> mediainfo

 

Once I get an alpha version out there I'll post for people's review...before I go wide with it.

 

 

  • Author

Ok, I give up on this one.  How do you all deal with empty/unset values on submission?

 

So I have a form that has 4 textboxes in a row, when they are left blank the pass to the rc script breaks and all the settings "below" the blank one shift up a level...this is because of how they are passed on the command line:

 

/etc/rc.d/rc.test disable foo blah frump 10

 

However, if the 3rd box is left empty it gets passed:

 

/etc/rc.d/rc.test disable foo blah  10

 

So "10" gets stored in the variable that "frump" was getting stored in, because it is just returning two spaces.

 

 

  • Author

Nevermind, just going to use a php script to process return values.

any checkbox i have in my plugin webguis don't directly submit to the form, but set the value of a hidden text input. this hidden input is the value, that will be submitted by the form

As Benni says, hidden inputs is a good way to go.  I sometimes call a validate function on form submit and this is a good place to reassign values to vars etc. 

 

It's also worth highlighting that values from disabled fields don't get passed either.  I like to have some of my text fields disabled (rather than read-only) when the plugin is running, signifying to the user that they can't change anything until the plugin status is disabled.

 

I use the validate function to re-enable the fields to get around empty values being passed.  There are more elegant solutions I'm sure, but it works for me.

 

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.