UserLastActivity

UserLastActivity is a script that displays the date and time (datetime) of the most recent logged local activity by a specified user. The user may be specified by name or id. The format of the datetime is automatically determined by Javascript's toLocalString function. If the specified user does not have activity on the wiki, the script will display a "no activity" message instead of a datetime. If the script cannot find the specified user, nothing will be displayed.
== ==
== ==
The configuration options for this script simply provide a means to restrict the type of logs used to determine the datetime. The options are properties of the script's configuration object which can be created in a community's JS with the following lines of code.
if (!window.andrewds1021) {
 window.andrewds1021 = {
 user_last_activity: {}
 };
} else if (!window.andrewds1021.user_last_activity) {
 window.andrewds1021.user_last_activity = {};
}
The two types of logs that can be searched are contributions and log events. These correspond to what would be returned by visiting Special:Contributions/Username and Special:Log/Username respectively. At this time, the script does not allow log events to be filtered by event type. By default, the script uses both types of logs when determining the datetime. To prevent use of contributions, place this line of code below the code creating the script's configuration object.
window.andrewds1021.user_last_activity.edits = false;
To prevent the use of logs, use this line instead.
window.andrewds1021.user_last_activity.logs = false;
If both log types are disabled, the script will not return any datetimes and all placeholders will remain unaltered.
== ==
The script must know where and for which users to insert datetimes. The location of the insertion should be indicated using a placeholder element. To indicate that an element is a placeholder for this script, add UserLastActivity as a class to the element. The contents of a placeholder element will be replaced with the corresponding datetime. The user may be specified by either name or id. The script will attempt to use the id first. If the id is deemed invalid, the script will attempt to use the name instead. If the name is also deemed invalid, the corresponding placeholder will remain unaltered. The name or id of the user is specified by adding the appropriate attribute to the placeholder.
=== data-userlastactivity-username ===
This attribute is used to specify the user by name. The name is case-sensitive and underscores will be replaced with spaces. Some characters may need to be escaped. To escape a character, use its HTML entity. Characters that do not require escaping may still be specified as HTML entities if desired. If the user has renamed their account, this attribute must be updated to match the new name. If not, the script will return the "no activity" message.
=== data-userlastactivity-userid ===
This attribute is used to specify the user by id. A user's id should remain the same even if their account gets renamed. Valid ids should be integers greater than 0.
== ==
=== Table ===
 	 	ID Value 	ID Value 	ID Value 	ID Value 	ID Value 	ID Value 	ID Value 	ID Value
 	 	None 	Declared 	Empty 	Anon (0) 	Removed (3) 	Invalid (-1) 	Valid (9605025) 	
Name Value	None 	No Change 	No Change 	No Change 	No Change 	No Change 	No Change 	Datetime for Andrewds1021 (contribs|logs)	
Name Value	Declared 	No Change 	No Change 	No Change 	No Change 	No Change 	No Change 	Datetime for Andrewds1021 (contribs|logs)	
Name Value	Empty 	No Change 	No Change 	No Change 	No Change 	No Change 	No Change 	Datetime for Andrewds1021 (contribs|logs)	
Name Value	Anon (An unknown anonymous user) 	No Change 	No Change 	No Change 	No Change 	No Change 	No Change 	Datetime for Andrewds1021 (contribs|logs)	
Name Value	Anon IP (72.34.11.146) 	No Change 	No Change 	No Change 	No Change 	No Change 	No Change 	Datetime for Andrewds1021 (contribs|logs)	
Name Value	Non-Existent (Andrewds1022) 	No Change 	No Change 	No Change 	No Change 	No Change 	No Change 	Datetime for Andrewds1021 (contribs|logs)	
Name Value	Valid (Andrewds1021) 	Datetime for Andrewds1021 (contribs|logs)	Datetime for Andrewds1021 (contribs|logs)	Datetime for Andrewds1021 (contribs|logs)	Datetime for Andrewds1021 (contribs|logs)	Datetime for Andrewds1021 (contribs|logs)	Datetime for Andrewds1021 (contribs|logs)	Datetime for Andrewds1021 (contribs|logs)	
Name Value	Non-Latin Characters (机智的小鱼君) 	Datetime for 机智的小鱼君 (contribs|logs) 	Datetime for 机智的小鱼君 (contribs|logs) 	Datetime for 机智的小鱼君 (contribs|logs) 	Datetime for 机智的小鱼君 (contribs|logs) 	Datetime for 机智的小鱼君 (contribs|logs) 	Datetime for 机智的小鱼君 (contribs|logs) 	Datetime for Andrewds1021 (contribs|logs)	
Name Value	 	 	 	 	 	 	 	 	
Name Value	 	 	 	 	 	 	 	 	
Name Value	 	 	 	 	 	 	 	 	
Name Value	 	 	 	 	 	 	 	 	
Name Value	 	 	 	 	 	 	 	 	
Name Value	 	 	 	 	 	 	 	 	
Name Value	 	 	 	 	 	 	 	 	
== Additional Notes ==
* This script makes multiple serial API requests to retrieve the necessary data. If the current page does not contain any placeholders, no requests will be made. Otherwise, the total number of requests is two more than the number of valid unique users specified on the page.
* Due to a difference in API behavior, migration to UCP revealed a previously undetected issue with the script. This issue appears when a page has more than 50 elements requiring user activity data. A rework is required to fix this issue and will likely take some time. For now, there should be no issue as long as the number of elements requiring user data is less than 50 per page.
* This script does not account for activity in Feeds-based discussion features. Unless and until Feeds activity is available to wiki-side JS, it will not be possible to incorporate that activity.