<commit_before>/***
|''Name''|TiddlySpaceMembers|
|''Version''|0.5.2|
|''Description''|provides a UI for managing space members|
|''Status''|@@beta@@|
|''Source''|http://github.com/TiddlySpace/tiddlyspace/raw/master/src/plugins/TiddlySpaceMembers.js|
|''Requires''|TiddlySpaceConfig TiddlySpaceUserControls|
!Usage
<<TiddlySpaceMembers list>> provides list of members
<<TiddlySpaceMembers add>> creates a form to add new members.
!HTMLForm
<div class='memberForm'>
	<div class='messageArea'></div>
	<form action="#">
		<fieldset>
			<legend />
			<dl>
				<dt>Username:</dt>
				<dd><input type="text" name="username" /></dd>
			</dl>
			<p class="annotation" />
			<input type="submit" />
		</fieldset>
	</form>
</div>
!Code
***/
//{{{
(function($) {

var macro = config.macros.TiddlySpaceMembers = {
	formTemplate: store.getTiddlerText(tiddler.title + "##HTMLForm"),
	locale: {
		authError: "list of members is only visible to members of space <em>%0</em>",
		listError: "error retrieving members for space <em>%0</em>: %1",
		addLabel: "Add member",
		noUserError: "user <em>%0</em> does not exist",
		delTooltip: "click to remove member",
		delPrompt: "Are you sure you want to remove member %0?",
		delError: "error removing member %0: %1",
		addMessage: "please wait..."
	},

	handler: function(place, macroName, params, wikifier, paramString, tiddler) {
		var space = config.extensions.tiddlyspace.currentSpace.name;
		var host = config.extensions.tiddlyweb.host;
		this.space = new tiddlyweb.Space(space, host); // XXX: singleton
		var mode = params[0];
		if(!readOnly) {
			if(mode == "add") {
				macro.generateForm(place);
			} else {
				var container = $("<div />").appendTo(place);
				macro.refresh(container);
			}
		} else {
			var msg = this.locale.authError.format([this.space.name]);
			this.notify(msg, container);
		}
	},
	refresh: function(container) {
		var callback = function(data, status, xhr) {
			container.empty();
			macro.displayMembers(data, container);
		};
		var errback = function(xhr, error, exc) {
			var msg = xhr.status == 403 ? "authError" : "listError";
			msg = macro.locale[msg].format([macro.space.name, error]);
			macro.notify(msg, container);
		};
		this.space.members().get(callback, errback);
	},<commit_msg>fixed an earlier breakage on TiddlySpaceMembers<commit_after>/***
|''Name''|TiddlySpaceMembers|
|''Version''|0.5.3|
|''Description''|provides a UI for managing space members|
|''Status''|@@beta@@|
|''Source''|http://github.com/TiddlySpace/tiddlyspace/raw/master/src/plugins/TiddlySpaceMembers.js|
|''Requires''|TiddlySpaceConfig TiddlySpaceUserControls|
!Usage
<<TiddlySpaceMembers list>> provides list of members
<<TiddlySpaceMembers add>> creates a form to add new members.
!HTMLForm
<div class='memberForm'>
	<div class='messageArea'></div>
	<form action="#">
		<fieldset>
			<legend />
			<dl>
				<dt>Username:</dt>
				<dd><input type="text" name="username" /></dd>
			</dl>
			<p class="annotation" />
			<input type="submit" />
		</fieldset>
	</form>
</div>
!Code
***/
//{{{
(function($) {

var macro = config.macros.TiddlySpaceMembers = {
	formTemplate: store.getTiddlerText(tiddler.title + "##HTMLForm"),
	locale: {
		authError: "list of members is only visible to members of space <em>%0</em>",
		listError: "error retrieving members for space <em>%0</em>: %1",
		addLabel: "Add member",
		noUserError: "user <em>%0</em> does not exist",
		delTooltip: "click to remove member",
		delPrompt: "Are you sure you want to remove member %0?",
		delError: "error removing member %0: %1",
		addMessage: "please wait..."
	},

	handler: function(place, macroName, params, wikifier, paramString, tiddler) {
		var space = config.extensions.tiddlyspace.currentSpace.name;
		var host = config.extensions.tiddlyweb.host;
		this.space = new tiddlyweb.Space(space, host); // XXX: singleton
		var mode = params[0];
		var container;
		if(!readOnly) {
			if(mode == "add") {
				macro.generateForm(place);
			} else {
				container = $("<div />").appendTo(place);
				macro.refresh(container);
			}
		} else {
			var msg = this.locale.authError.format([this.space.name]);
			container = $("<div />").appendTo(place);
			this.notify(msg, container);
		}
	},
	refresh: function(container) {
		var callback = function(data, status, xhr) {
			$(container).empty();
			macro.displayMembers(data, container);
		};
		var errback = function(xhr, error, exc) {
			var msg = xhr.status == 403 ? "authError" : "listError";
			msg = macro.locale[msg].format([macro.space.name, error]);
			macro.notify(msg, container);
		};
		this.space.members().get(callback, errback);
	},
{'fraction_non_alphanumeric': 0.17761873780091086, 'fraction_numerical': 0.006072435480373021, 'mean_word_length': 4.438679245283019, 'pattern_counts': {'":': 0, '<': 62, '<?xml version=': 0, '>': 62, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '502689', 'n_tokens_mistral': 1741, 'n_tokens_neox': 1579, 'n_words': 371}