Comments (2)
Depending on the browser, you might get the widget to make the password visible automatically.
I just tried this schema and I got this in ·Edge:
Alternatively, you can set a watcher for password fields where if length > 0 an icon is added to the input, and to that icon add an event listener for click to switch icons and to change the type from password to text and viceversa.
Alternatively, you could scan all your password fields and append a toggable eye when there isn't one already.
You can put this in your change event for the editor:
editor.on('change', function() {
document.querySelectorAll("[type=password]").forEach((thisField,eid) => {
if(!thisField.parentElement.querySelectorAll('i.eyetoggle').length>0) {
thisIcon=document.createElement('i');
thisIcon.addEventListener('click',function(){
if(thisField.type === "password") {
thisField.type = "text";
this.classList.add("fa-eye-slash");
this.classList.remove("fa-eye");
} else {
thisField.type = "password";
this.classList.add("fa-eye");
this.classList.remove("fa-eye-slash");
}});
thisField.style.display='inline-block';
thisField.style.width='90%'
thisIcon.style.zIndex=2
thisIcon.classList.add('eyetoggle');
thisIcon.classList.add('fa');
thisIcon.classList.add('fa-eye');
thisField.parentElement.append(thisIcon)
}
}
)
}
(of course, you should modify the style to work for you, and perhaps put a timer in the click event so it automatically turns back to password field).
Edit: Some formatting, since I wrote this in a rush in the developer tools console :D
Edit2: Modified input field to be inline block and 90% width to accomodate the icon after it, but you can do your own styling.
from json-editor.
Depending on the browser, you might get the widget to make the password visible automatically.
I just tried this schema and I got this in ·Edge:
Alternatively, you can set a watcher for password fields where if length > 0 an icon is added to the input, and to that icon add an event listener for click to switch icons and to change the type from password to text and viceversa.Alternatively, you could scan all your password fields and append a toggable eye when there isn't one already.
You can put this in your change event for the editor:
editor.on('change', function() { document.querySelectorAll("[type=password]").forEach((thisField,eid) => { if(!thisField.parentElement.querySelectorAll('i.eyetoggle').length>0) { thisIcon=document.createElement('i'); thisIcon.addEventListener('click',function(){ if(thisField.type === "password") { thisField.type = "text"; this.classList.add("fa-eye-slash"); this.classList.remove("fa-eye"); } else { thisField.type = "password"; this.classList.add("fa-eye"); this.classList.remove("fa-eye-slash"); }}); thisField.style.display='inline-block'; thisField.style.width='90%' thisIcon.style.zIndex=2 thisIcon.classList.add('eyetoggle'); thisIcon.classList.add('fa'); thisIcon.classList.add('fa-eye'); thisField.parentElement.append(thisIcon) } } ) }
(of course, you should modify the style to work for you, and perhaps put a timer in the click event so it automatically turns back to password field).
Edit: Some formatting, since I wrote this in a rush in the developer tools console :D Edit2: Modified input field to be inline block and 90% width to accomodate the icon after it, but you can do your own styling.
Thank you for the answer, this really helped me :D
from json-editor.
Related Issues (20)
- Can I Do Dependencies Only On the Default Value And Enum? HOT 1
- [bug]select2 setValue report a error and not select it HOT 8
- Starrating format isn't working properly HOT 1
- bug/regression: bool or number value does not show when remove_empty_properties=true and use_default_values=false
- Can Do a "WACTH" To Another Root "JSON Editor". HOT 4
- Auto generate schema for simple cases HOT 5
- Support for chained / nested watch HOT 2
- Add meta-data (schema builder) example HOT 1
- Validation of datetime-local fails when oneOf is used HOT 3
- An error occurs when a dependency is defined after the field that depends on it HOT 1
- Dependent field does not update when watched field changes HOT 1
- Failure to parse schema with "default": null due to unhandled exception in browser console
- select2 doesn't refer enumSource of item in array. HOT 12
- How do I add my syntax highlighting to Ace Editor? HOT 1
- test
- Enum wont be selected on load if it not the first element HOT 2
- Dependencies with false values not fullfilled HOT 1
- Adding a property breaks UI with a couple of exceptions in the console
- Cannot set (programmatically) value for "enum" string HOT 2
- compare fields HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json-editor.