Post by Chris on Jul 6, 2014 17:27:50 GMT -8
OK, version 1.0.4 has been submitted for online library approval and as discussed it now exposes a few properties and methods that might be useful to other plugins:
window.eton = {
"eton_word_count" : {
/*
* currently active counting mode (words or characters)
*/
"mode" : "words",
/*
* reference to the WYSIWYG object created by Proboards
* or created for quick reply by the plugin
*/
"wysiwyg" : [Object object],
/*
* character count
*/
"last_length_count" : 16,
/*
* word count
*/
"last_word_count" : 2,
/*
* list of limits considered for this page, a limit is defined in plugin settings and can be scoped to the entire forum, categories, boards or threads. Threads are the most powerful and will override any other limit in effect.
* Limit Precedence (strongest to weakest): Threads >> Boards >> Categories >> Forum
*/
"limits" : {
"forum" : {
"limit" : "2999999",
"limit_type" : "min_length",
"exclude_members" : [],
"exclude_groups" : []
}
},
/*
* limit determined to apply to this particular page and user
* (example below is a forum limit set to 2,999,999 minimum words effectively preventing any posting given the max length of a post is 2^18 )
*/
"effective_limit" : {
"name" : "Forum Name",
"source" : "forum",
"id" : 0,
"limit" : "2999999",
"mode" : "words",
"type" : "min_length" //min_length, max_length, min_char_length, max_char_length
},
/*
* The validation object used to enforce the effective limit
*/
"validation" : {
"name" : "message_word_length",
"field" : "message",
"opts" : {
"area_of_effect" : ".ui-wysiwyg .editors",
"min_length" : "2999999"
},
"message" : "Your words count is below the limit of 2999999 words set for this forum"
},
/*
* plugin settings
*/
"settings" : {
"default_mode" : "words",
"no_limit_no_show" : "noshow",
"paste_html" : "paste",
"put_count_in_post" : "postcount",
"alternative_target_id" : "",
"limit_type" : "min_length",
"limit_threshold" : "2999999",
"limit_staff" : "staff",
"exempt_members" : [],
"exempt_groups" : [],
"limit_threads" : [{
"thread" : "15",
"limit_type" : "min_length",
"limit" : "750",
"exclude_members" : [],
"exclude_groups" : []
}, {
"thread" : "37",
"limit_type" : "min_length",
"limit" : "1",
"exclude_members" : [],
"exclude_groups" : []
}, {
"thread" : "14",
"limit_type" : "none",
"limit" : "0",
"exclude_members" : [],
"exclude_groups" : []
}, {
"thread" : "36",
"limit_type" : "min_length",
"limit" : "-3",
"exclude_members" : [],
"exclude_groups" : []
}, {
"thread" : "29",
"limit_type" : "max_char_length",
"limit" : "11",
"exclude_members" : [],
"exclude_groups" : []
}
],
"limit_boards" : [{
"board" : [
"9"
],
"limit_type" : "none",
"limit" : "",
"exclude_members" : [],
"exclude_groups" : []
}, {
"board" : [
"3",
"1"
],
"limit_type" : "min_length",
"limit" : "5",
"exclude_members" : [],
"exclude_groups" : []
}
],
"limit_categories" : [],
"enable_enhanced" : [
"enhance"
],
"enable_monetary" : "monetary",
"money_mode" : "proportional",
"word_up" : [{
"min_words" : "9",
"money" : "-20.00"
}
],
"ignores" : [{
"bbcode" : "quote",
"html" : "div.quote"
}, {
"bbcode" : "code",
"html" : "code"
}, {
"bbcode" : "img",
"html" : "img"
}
],
"word_regex" : "",
"post_pattern" : "/(%[wc]c#[-+\\d]*)/gi",
"bbcode_max" : "",
"enable_debugging" : [
"debug",
"debug_limits",
"debug_plugins"
]
},
/**
* Method: getAutoformByField
*
* Searches an autoForm array and returns match(es) based on the specified field
*
* Parameters:
* AUTOFORMARRAY - *array* an array of plain javascript objects
* FIELD - *string* The name of the field in each object that should be searched
* VALUE - *string* OPTIONAL value used to compare against the field, if omitted then all entries possessing the specified field will be returned (existence)
* MULTIPLE - *boolean* OPTIONAL a flag indicating whether to return an array of ALL found (if set to true) or return only the first object found (if set to false/undefined)
*
* Returns:
* *object* / *array* / *undefined*
*/
"getAutoformByField" : function (autoformArray, field, value, multiple),
/**
* Method: getEditorText
*
* Determines the active editor (bbcode or visual) then preprocesses the text before returning
* HTML and BBCODE tags (that are recognized) are removed as part of the preprocessing
* Special tags (defined in plugin settings) such as QUOTE and CODE will also have their contents removed so they can be ignored while counting
*
* Returns:
* *string* - the normalized text pulled from the current editor
*/
"getEditorText" : function ()
}
}