diff options
author | nacho <nacho@ownyourbits.com> | 2018-12-31 01:59:26 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2019-01-05 04:14:53 +0300 |
commit | 497edb8d9471c05ace0868e2d6c2f092dca7c030 (patch) | |
tree | 94e08ea7cc0741e40a6c60ca83b181951cf9a955 /ncp-web | |
parent | bc0271e359749aadc9c782cab8b7dddf41220b3b (diff) |
add restore defaults btn
Diffstat (limited to 'ncp-web')
-rw-r--r-- | ncp-web/css/ncp.css | 2 | ||||
-rw-r--r-- | ncp-web/elements.php | 37 | ||||
-rw-r--r-- | ncp-web/index.php | 2 | ||||
-rw-r--r-- | ncp-web/js/ncp.js | 16 |
4 files changed, 48 insertions, 9 deletions
diff --git a/ncp-web/css/ncp.css b/ncp-web/css/ncp.css index 87fa4808..c5ae5727 100644 --- a/ncp-web/css/ncp.css +++ b/ncp-web/css/ncp.css @@ -1337,6 +1337,6 @@ a#versionlink:hover { color: white; } -.pwd-btn { +.pwd-btn, .default-btn { cursor: pointer; } diff --git a/ncp-web/elements.php b/ncp-web/elements.php index aa853280..2a6c5734 100644 --- a/ncp-web/elements.php +++ b/ncp-web/elements.php @@ -25,7 +25,29 @@ HTML; // default to text input if (!array_key_exists('type', $param)) { - $ret .= "<td><input type=\"text\" name=\"$param[name]\" id=\"$ncp_app-$param[id]\" value=\"$param[value]\" size=\"40\"></td>"; + $suggest = ''; + if (array_key_exists('suggest', $param)) + $suggest = $param['suggest']; + + $default = ''; + if (array_key_exists('default', $param)) + $default = $param['default']; + + $ret .= "<td> + <input type=\"text\" + name=\"$param[name]\" + id=\"$ncp_app-$param[id]\" + value=\"$param[value]\" + default=\"$default\" + placeholder=\"$suggest\" + size=\"40\">"; + + if (array_key_exists('default', $param)) + { + $ret .= "<img class=\"default-btn\" title=\"restore defaults\" src=\"../img/info.svg\">"; + } + + $ret .= "</td>"; } // checkbox @@ -34,14 +56,23 @@ HTML; $checked = ""; if ($param['value'] == 'yes') $checked = 'checked'; - $ret .= "<td><input type=\"checkbox\" id=\"$ncp_app-$param[id]\" name=\"$param[name]\" value=\"$param[value]\" $checked></td>"; + $ret .= "<td><input type=\"checkbox\" + id=\"$ncp_app-$param[id]\" + name=\"$param[name]\" + value=\"$param[value]\" + $checked> + </td>"; } // password else if ($param['type'] == 'password') { $ret .= "<td>"; - $ret .= "<input type=\"password\" name=\"$param[name]\" id=\"$ncp_app-$param[id]\" value=\"$param[value]\" size=\"40\">"; + $ret .= "<input type=\"password\" + name=\"$param[name]\" + id=\"$ncp_app-$param[id]\" + value=\"$param[value]\" + size=\"40\">"; $ret .= "<img class=\"pwd-btn\" title=\"show password\" src=\"../img/info.svg\">"; $ret .= "</td>"; } diff --git a/ncp-web/index.php b/ncp-web/index.php index b2452ac0..7e9e5604 100644 --- a/ncp-web/index.php +++ b/ncp-web/index.php @@ -117,7 +117,7 @@ HTML; </a> <a id=versionlink target="_blank" href="https://github.com/nextcloud/nextcloudpi/blob/master/changelog.md"> <?php - $version = "v0.0"; + $version = "v0.0.0"; $ver_file = "/usr/local/etc/ncp-version"; if (file_exists($ver_file)) $version = file_get_contents($ver_file); diff --git a/ncp-web/js/ncp.js b/ncp-web/js/ncp.js index 954bc3e4..e94c29c0 100644 --- a/ncp-web/js/ncp.js +++ b/ncp-web/js/ncp.js @@ -34,7 +34,7 @@ function switch_to_section(section) $( '#dashboard-wrapper' ).hide(); $( '#nc-config-wrapper' ).hide(); $( '#' + section + '-wrapper' ).show(); - $( '#' + selectedID ).set('-active'); + $( '#app-navigation ul' ).set('-active'); selectedID = null; } @@ -102,7 +102,7 @@ function set_sidebar_click_handlers() if ( window.innerWidth <= 768 ) close_menu(); - $( '#' + selectedID ).set('-active'); + $( '#app-navigation ul' ).set('-active'); app_clicked(this); history.pushState(null, selectedID, "?app=" + selectedID); }); @@ -251,7 +251,7 @@ $(function() }).error( errorMsg ); }); - // Update notification + // Show password button $( '.pwd-btn' ).on('click', function(e) { var input = this.trav('previousSibling', 1); @@ -260,13 +260,21 @@ $(function() else if ( input.get('.type') == 'text' ) input.set('.type', 'password'); }); + + // Reset to defaults button + $( '.default-btn' ).on('click', function(e) + { + var input = this.trav('previousSibling', 1); + input.set('.value', input.get('@default')); + }); + // Update notification $( '#notification' ).on('click', function(e) { if ( lock ) return; lock = true; - $( '#' + selectedID ).set('-active'); + $( '#app-navigation ul' ).set('-active'); app_clicked( $('#nc-update') ); |