MCPcopy Create free account
hub / github.com/cppla/ServerStatus / fieldHTML

Function fieldHTML

web/js/app.js:736–749  ·  view source on GitHub ↗
(field, item)

Source from the content-addressed store, hash-verified

734 $('deleteConfigItemBtn').disabled = !editing;
735}
736function fieldHTML(field, item){
737 const value = item[field.name] ?? field.default ?? '';
738 if(field.type === 'checkbox'){
739 return `<label class="check-row"><input name="${esc(field.name)}" type="checkbox" ${value ? 'checked' : ''} /> <span>${esc(field.label)}</span></label>`;
740 }
741 const required = field.required ? ' required' : '';
742 const min = field.min != null ? ` min="${field.min}"` : '';
743 const max = field.max != null ? (field.type === 'number' ? ` max="${field.max}"` : ` maxlength="${field.max}"`) : '';
744 const placeholder = field.placeholder ? ` placeholder="${esc(field.placeholder)}"` : '';
745 if(field.type === 'textarea'){
746 return `<label class="wide"><span>${esc(field.label)}</span><textarea name="${esc(field.name)}"${required}${placeholder}>${esc(value)}</textarea></label>`;
747 }
748 return `<label><span>${esc(field.label)}</span><input name="${esc(field.name)}" type="${field.type || 'text'}" value="${esc(value)}"${required}${min}${max}${placeholder} /></label>`;
749}
750function clearConfigForm(){
751 S.admin.selectedIndex = -1;
752 renderConfigList();

Callers 1

renderConfigEditorFunction · 0.85

Calls 1

escFunction · 0.85

Tested by

no test coverage detected