new Policy()
manage an arbitrary policy
Example
var policy = new Policy( namespace, {
// objects:
v : v, // Variables object
bb: bb, // BulletinBoard object
mc: mc, // MiscellaneousCache object
vi: vi, // Violations object
// configuration:
severity_level: { html: 'no action', type: 'none' },
thread_id : 1234,
thread_desc : 'thread description',
loading_html : 'loading, please wait...'
});
Methods
-
protected_build_keys(keys, context)
Build keys to pass to an action
-
Name Type Description keys
Array.<Object> keys to pass context
string some keys should only be passed in certain contexts Example
var args = policy._build_keys([ { type: 'severity' , value: my_severity_level }, { type: 'username' , name: 'username' , value: user }, { type: 'usernames', name: 'usernames', value: all_users }, { type: 'literal' , name: 'name' , value: 'value' } ]);
-
protected_build_widget_args(args, keys)
Build arguments to pass to a widget
-
Name Type Description args
Object arguments to pass keys
Array.<Object> keys to pass Example
var args = this._build_widget_args({foo: 'bar'}, [ { type: 'severity' , value: my_severity_level }, { type: 'username' , name: 'username' , value: user }, { type: 'usernames', name: 'usernames', value: all_users }, { type: 'literal', name: 'name' , value: 'value' } ], Array.prototype.slice.call( arguments, 1 ));
-
check(name){string}
Check if a name exists in the policy's namespace
-
Name Type Description name
string variable name Returns:
Type Description string variable -
protectedclose_thread(){Action}
Close the thread targeted by this policy
-
Returns:
Type Description Action -
protecteddeadline_action(level, more){Action}
Build an action for a deadline widget
-
Name Type Description level
Object optional severity level more
Object repeatable arguments Returns:
Type Description Action -
protecteddeadline_args(level, more){Object}
Build values to initialise or update a deadline widget
-
Name Type Description level
Object optional severity level more
Object repeatable arguments Returns:
Type Description Object deadline arguments -
protectedduplicate_account_list_args(level, more){Object}
Build values to initialise or update a duplicate_account_list widget
-
Name Type Description level
Object optional severity level more
Object repeatable arguments Returns:
Type Description Object duplicate_account_list arguments -
protectedextra_post_action(level, more){Action}
Build an action for an extra_post widget
-
Name Type Description level
Object optional severity level more
Object repeatable arguments Returns:
Type Description Action -
protectedextra_post_args(level, more){Object}
Build values to initialise or update an extra_post widget
-
Name Type Description level
Object optional severity level more
Object repeatable arguments Returns:
Type Description Object extra_post arguments -
get(name){string}
Resolve a name in the policy's namespace
-
Name Type Description name
string variable name Returns:
Type Description string variable -
protectedkeys(keys)
Build keys to pass to an action
-
Name Type Description keys
Object keys to pass -
protectednotification_selector_action(level, more){Action}
Build an action for a notification_selector widget
-
Name Type Description level
Object optional severity level more
Object repeatable arguments Returns:
Type Description Action -
protectednotification_selector_args(level, more){Object}
Build values to initialise or update a notification_selector widget
-
Name Type Description level
Object optional severity level more
Object repeatable arguments Returns:
Type Description Object notification_selector arguments -
resolve(names, keys, parser){string}
Resolve a name in the policy's namespace
-
Name Type Description names
string | Array.<string> name(s) of variable within the namespace keys
Object.<string, *> optional keys used to instantiate the variable parser
string optional parser used for the variable ('string', 'array of items' or 'hash of arrays', default: 'string') Returns:
Type Description string variable -
resolve_post(name){string}
Get a frequently used thread or post ID
-
Name Type Description name
string post name Returns:
Type Description string thread/post ID -
protectedseverity_slider_args(level, more){Object}
Build values to initialise or update a severity_slider widget
-
Name Type Description level
Object optional severity level more
Object repeatable arguments Returns:
Type Description Object severity_slider arguments