mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-30 23:23:02 +00:00 
			
		
		
		
	New password macro for setting passwords
They are stored unencrypted in localStorage
This commit is contained in:
		
							
								
								
									
										43
									
								
								core/modules/macros/password.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								core/modules/macros/password.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,43 @@ | ||||
| /*\ | ||||
| title: $:/core/modules/macros/password.js | ||||
| type: application/javascript | ||||
| module-type: macro | ||||
|  | ||||
| Allows a password to be set | ||||
|  | ||||
| \*/ | ||||
| (function(){ | ||||
|  | ||||
| /*jslint node: true, browser: true */ | ||||
| /*global $tw: false */ | ||||
| "use strict"; | ||||
|  | ||||
| exports.info = { | ||||
| 	name: "password", | ||||
| 	params: { | ||||
| 		name: {byName: "default", type: "text"} | ||||
| 	} | ||||
| }; | ||||
|  | ||||
| exports.executeMacro = function() { | ||||
| 	var password = $tw.utils.getPassword(this.params.name); | ||||
| 	password = password || ""; | ||||
| 	var attributes = { | ||||
| 		type: "password", | ||||
| 		value: password | ||||
| 	}; | ||||
| 	if(this.classes) { | ||||
| 		attributes["class"] = this.classes.slice(0); | ||||
| 	} | ||||
| 	return $tw.Tree.Element("input",attributes,[],{ | ||||
| 		events: ["keyup","input"], | ||||
| 		eventHandler: this | ||||
| 	}); | ||||
| }; | ||||
|  | ||||
| exports.handleEvent = function(event) { | ||||
| 	var password = this.child.domNode.value; | ||||
| 	return $tw.utils.savePassword(this.params.name,password); | ||||
| }; | ||||
|  | ||||
| })(); | ||||
		Reference in New Issue
	
	Block a user
	 Jeremy Ruston
					Jeremy Ruston