mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-30 23:23:02 +00:00 
			
		
		
		
	Add new modules and moduletypes filter operators
This commit is contained in:
		
							
								
								
									
										39
									
								
								core/modules/filters/modules.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								core/modules/filters/modules.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| /*\ | ||||
| title: $:/core/modules/filters/modules.js | ||||
| type: application/javascript | ||||
| module-type: filteroperator | ||||
|  | ||||
| Filter operator for returning the titles of the modules of a given type in this wiki | ||||
|  | ||||
| \*/ | ||||
| (function(){ | ||||
|  | ||||
| /*jslint node: true, browser: true */ | ||||
| /*global $tw: false */ | ||||
| "use strict"; | ||||
|  | ||||
| /* | ||||
| Export our filter function | ||||
| */ | ||||
| exports.modules = function(source,operator,options) { | ||||
| 	var results = [], | ||||
| 		pushModules = function(type) { | ||||
| 			$tw.utils.each($tw.modules.types[type],function(moduleInfo,moduleName) { | ||||
| 				results.push(moduleName); | ||||
| 			}); | ||||
| 		}; | ||||
| 	// Iterate through the source tiddlers | ||||
| 	if($tw.utils.isArray(source)) { | ||||
| 		$tw.utils.each(source,function(title) { | ||||
| 			pushModules(title); | ||||
| 		}); | ||||
| 	} else { | ||||
| 		$tw.utils.each(source,function(element,title) { | ||||
| 			pushModules(title); | ||||
| 		}); | ||||
| 	} | ||||
| 	results.sort(); | ||||
| 	return results; | ||||
| }; | ||||
|  | ||||
| })(); | ||||
							
								
								
									
										27
									
								
								core/modules/widgets/moduletypes.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								core/modules/widgets/moduletypes.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| /*\ | ||||
| title: $:/core/modules/filters/moduletypes.js | ||||
| type: application/javascript | ||||
| module-type: filteroperator | ||||
|  | ||||
| Filter operator for returning the names of the module types in this wiki | ||||
|  | ||||
| \*/ | ||||
| (function(){ | ||||
|  | ||||
| /*jslint node: true, browser: true */ | ||||
| /*global $tw: false */ | ||||
| "use strict"; | ||||
|  | ||||
| /* | ||||
| Export our filter function | ||||
| */ | ||||
| exports.moduletypes = function(source,operator,options) { | ||||
| 	var results = []; | ||||
| 	$tw.utils.each($tw.modules.types,function(moduleInfo,type) { | ||||
| 		results.push(type); | ||||
| 	}); | ||||
| 	results.sort(); | ||||
| 	return results; | ||||
| }; | ||||
|  | ||||
| })(); | ||||
		Reference in New Issue
	
	Block a user
	 Jeremy Ruston
					Jeremy Ruston