|
134 | 134 | {!! Theme::js('vendor/lodash/lodash.js') !!} |
135 | 135 | <script> |
136 | 136 | $(document).ready(function () { |
137 | | - $('#pNestId').select2({placeholder: 'Select a Nest'}).change(); |
138 | | - $('#pEggId').select2({placeholder: 'Select a Nest Egg'}); |
139 | 137 | $('#pPackId').select2({placeholder: 'Select a Service Pack'}); |
140 | | - }); |
141 | | - </script> |
142 | | - <script> |
143 | | - $('#pNestId').on('change', function (event) { |
| 138 | + $('#pNestId').select2({placeholder: 'Select a Nest'}).on('change', function () { |
144 | 139 | $('#pEggId').html('').select2({ |
145 | 140 | data: $.map(_.get(Pterodactyl.nests, $(this).val() + '.eggs', []), function (item) { |
146 | 141 | return { |
147 | 142 | id: item.id, |
148 | 143 | text: item.name, |
149 | 144 | }; |
150 | 145 | }), |
151 | | - }).val(Pterodactyl.server.egg_id).change(); |
152 | | - }); |
| 146 | + }); |
153 | 147 |
|
154 | | - $('#pEggId').on('change', function (event) { |
155 | | - var parentChain = _.get(Pterodactyl.nests, $('#pNestId').val(), null); |
156 | | - var objectChain = _.get(parentChain, 'eggs.' + $(this).val(), null); |
| 148 | + if (_.isObject(_.get(Pterodactyl.nests, $(this).val() + '.eggs.' + Pterodactyl.server.egg_id))) { |
| 149 | + $('#pEggId').val(Pterodactyl.server.egg_id); |
| 150 | + } |
| 151 | +
|
| 152 | + $('#pEggId').change(); |
| 153 | + }).change(); |
| 154 | +
|
| 155 | + $('#pEggId').select2({placeholder: 'Select a Nest Egg'}).on('change', function () { |
| 156 | + var selectedEgg = _.isNull($(this).val()) ? $(this).find('option').first().val() : $(this).val(); |
| 157 | + var parentChain = _.get(Pterodactyl.nests, $("#pNestId").val()); |
| 158 | + var objectChain = _.get(parentChain, 'eggs.' + selectedEgg); |
157 | 159 |
|
158 | 160 | $('#setDefaultImage').html(_.get(objectChain, 'docker_image', 'undefined')); |
159 | 161 | $('#pDockerImage').val(_.get(objectChain, 'docker_image', 'undefined')); |
|
168 | 170 | } |
169 | 171 |
|
170 | 172 | $('#pPackId').html('').select2({ |
171 | | - data: [{ id: '0', text: 'No Service Pack' }].concat( |
| 173 | + data: [{id: '0', text: 'No Service Pack'}].concat( |
172 | 174 | $.map(_.get(objectChain, 'packs', []), function (item, i) { |
173 | 175 | return { |
174 | 176 | id: item.id, |
|
202 | 204 | </div> \ |
203 | 205 | </div> \ |
204 | 206 | </div>'; |
205 | | - $('#appendVariablesTo').append(dataAppend); |
206 | | - $('#appendVariablesTo').find('#egg_variable_' + item.env_variable).val(setValue); |
| 207 | + $('#appendVariablesTo').append(dataAppend).find('#egg_variable_' + item.env_variable).val(setValue); |
207 | 208 | }); |
208 | 209 | }); |
| 210 | + }); |
209 | 211 | </script> |
210 | 212 | @endsection |
0 commit comments