Analyze this code: html.RenderCreate('toggle', function(addon, data) { let attributes =…
- User
Analyze this code: html.RenderCreate('toggle', function(addon, data) { let attributes = data('attributes', {}); let action = data('action', []);
if(action.length === 2 || action.length === 3) { attributes['action'] = action[0]; attributes['action-type'] = 'PUT'; attributes['action-modal'] = false; attributes['data-id'] = action[1]; attributes['data-value'] = '$checked'; if(action.length === 3) { attributes['data-' + dh.sanitize(action[2])] = '$checked'; } } if(data('checked', false)) { attributes['checked'] = true; } else { delete attributes['checked']; } if(!('id' in attributes)) { attributes['id'] = 't' + Date.now() + Math.floor(Math.random() * (10000 - 1 + 1) + 1); } if(data('onToggle')) { attributes['identifier'] = data('identifier'); attributes['bind-click'] = 'toggle|html'; addon.CallbackAdd(attributes['identifier'] + '.onToggle', data('onToggle')); } attributes['type'] = 'checkbox'; return ` ${data('label') ? `<p>${data('label', '', true)}</p>`: ''} <label for="${attributes.id}"> <input ${dh.attributes(attributes)}> <div class="slider"></div> </label> `;});
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.