-
Notifications
You must be signed in to change notification settings - Fork 109
IITC plugin migration guide
This guide provides step-by-step instructions on migrating existing IITC plugins to the new IITC API, introduced to replace previous internal window.*
namespace functions with a more powerful and user-friendly IITC.*
namespace.
-
Checking for API Availability: Instead of checking the IITC build date or version to determine if a certain API is available, check for the existence of the method itself.
Bad Practice:
if (iitcBuildDate <= '2023-11-20-071719') { /* ... */ }
Good Practice:
if (typeof IITC !== 'undefined' && typeof IITC.toolbox !== 'undefined') { /* ... */ }
-
Avoid Overwriting or Modifying API Methods: If the existing API does not meet your requirements, instead of modifying or overwriting the API methods, submit an issue requesting the needed functionality. This ensures the future compatibility of your plugin with API updates and improves compatibility with other plugins.
Introduced in IITC-CE v0.38.0
The Filters API allows hiding intel entities based on their properties (e.g., faction, health, timestamp). It provides a two-level API: a set of named filters that apply globally and a low-level API for generic purposes.
Example Usage:
{ portal: true, data: ['not', { history: { scoutControlled: false }, ornaments: ['some', 'sc5_p'] }] }
This filter configuration hides all portals except those never scout controlled and having a scout volatile ornament.
Documentation: Filters API Documentation
Introduced in IITC-CE v0.38.0
The Toolbox API facilitates the management of plugin buttons in the toolbox, allowing for the addition, editing, deletion of buttons, and sorting order modification.
Example Replacement: Instead of directly manipulating the DOM to add buttons:
$('#toolbox').append('<a onclick="window.plugin.myplugin.openDialog(); return false;">Test Button</a>');
Use the Toolbox API like this:
IITC.toolbox.addButton({
id: 'mybtn',
label: 'Test Button',
action: window.plugin.myplugin.openDialog
});
Documentation: Toolbox API Documentation
Introduced in IITC-CE v0.39.0
The introduction of the IITC.comm API primarily aims at enhancing support and simplifying the codebase. The previous window.chat namespace has been divided into two segments: the chat interface and tab management remains under window.chat, while functionalities related to in-chat messages have been migrated to the IITC.comm API.
To ensure backward compatibility, a proxy has been implemented that redirects calls from the deprecated window.chat functions to the new IITC.comm. Note that if a plugin overrides a deprecated window.chat function, it is automatically overridden in IITC.comm as well. This ensures that plugins work in most cases but may introduce issues due to the use of outdated code.
-
Removed:
window.chat._oldBBox
-
window.chat.handlePublic
,window.chat.handleFaction
,window.chat.handleAlerts
-
window.chat._requestPublicRunning
,window.chat._requestFactionRunning
,window.chat._requestAlertsRunning
-
Deprecated:
window.chat.tabToChannel
- Use
IITC.comm.renderMsgRow
instead ofwindow.chat.renderMsg
- Use
IITC.comm._channelsData.all
,IITC.comm._channelsData.faction
, andIITC.comm._channelsData.alerts
instead ofwindow.chat._public
,window.chat._faction
, andwindow.chat._alerts
-
Replacements and recommendations:
- Use
IITC.comm.requestChannel
instead ofwindow.chat.requestPublic
,window.chat.requestFaction
,window.chat.requestAlerts
- Use
IITC.comm.renderChannel
instead ofwindow.chat.renderPublic
,window.chat.renderFaction
,window.chat.renderAlerts
- Internal methods like
window.chat.genPostData
andwindow.chat.writeDataToHash
moved toIITC.comm
and are available for backward compatibility only
- Use
-
Moved functions
-
window.chat.parseMsgData
- moved toIITC.comm.parseMsgData
-
window.chat.renderText
- moved toIITC.comm.renderText
-
window.chat.getChatPortalName
- moved toIITC.comm.getChatPortalName
-
window.chat.renderFactionEnt
- moved toIITC.comm.renderFactionEnt
-
window.chat.renderPlayer
- moved toIITC.comm.renderPlayer
-
window.chat.renderMarkupEntity
- moved toIITC.comm.renderMarkupEntity
-
window.chat.renderMarkup
- moved toIITC.comm.renderMarkup
-
window.chat.renderData
- moved toIITC.comm.renderData
-
window.chat.renderPortal
- moved toIITC.comm.renderPortal
, with customizable string template -
window.chat.renderTimeCell
- moved toIITC.comm.renderTimeCell
, with customizable string template -
window.chat.renderNickCell
- moved toIITC.comm.renderNickCell
, with customizable string template -
window.chat.renderMsgCell
- moved toIITC.comm.renderMsgCell
, with customizable string template -
window.chat.renderMsgRow
- moved toIITC.comm.renderMsgRow
, with customizable string template -
window.chat.renderDivider
- moved toIITC.comm.renderDivider
, with customizable string template
-
Channel names now start with a capital letter (e.g. All
instead of all
). If your plugin adds new chat tabs after some tab (e.g. after all
), it is recommended to use data-channel
key instead of searching by name.
For example, instead of
[...document.querySelectorAll('#chatcontrols a')].filter(el=>el.textContent == 'all')
use
[...document.querySelectorAll('#chatcontrols a')].filter(el=>el.dataset.channel == 'all')
The IITC.comm.requestChannel
function has been introduced to replace separate functions for each channel.
For instance, instead of using
window.chat.requestPublic(getOlderMsgs, isRetry)
, use IITC.comm.requestChannel('all', getOlderMsgs, isRetry)
Similarly, the IITC.comm.renderChannel
function is introduced to replace separate rendering functions.
For example, instead of window.chat.renderPublic(oldMsgsWereAdded)
, use IITC.comm.renderChannel('all', oldMsgsWereAdded)
It is now possible to edit or replace the template strings used by certain functions:
-
IITC.comm.renderPortal
- template string inIITC.comm.portalTemplate
-
IITC.comm.renderTimeCell
- template string inIITC.comm.timeCellTemplate
-
IITC.comm.renderNickCell
- template string inIITC.comm.nickCellTemplate
-
IITC.comm.renderMsgCell
- template string inIITC.comm.msgCellTemplate
-
IITC.comm.renderMsgRow
- template string inIITC.comm.msgRowTemplate
-
IITC.comm.renderDivider
- template string inIITC.comm.dividerTemplate
While the old hooks (publicChatDataAvailable
, factionChatDataAvailable
, and alertsChatDataAvailable
) remain, a new, more general hook, commDataAvailable
, has been added. This hook functions similarly but also includes a channel
key indicating the channel.
For more details, see the documentation: IITC.comm Documentation
The IITC.comm.declarativeMessageFilter
allows for message filtering within channels, such as hiding messages from players based on a pattern or displaying only selected actions (e.g., deploying portals, creating fields).
Example Usage: To hide all messages except those from the Resistance team:
IITC.comm.declarativeMessageFilter.addRule({
id: "hideExceptResistanceTeam",
conditions: [
{ field: "player.team", value: "Resistance", invert: true },
]
});
For more details, see the documentation: IITC.comm Declarative Message Filter
Planned to be implemented in IITC-CE v0.40.0
The IITC.utils
API, introduced in IITC-CE v0.40.0, centralizes utility functions to improve code organization and simplify API interactions. Previously located in the window.
namespace, these helper functions now reside in IITC.utils
, with some functions renamed for clarity.
For legacy support, IITC intercepts old window.
function calls, redirecting them to the new IITC.utils
equivalents. This helps maintain plugin compatibility; however, updating code to use the new references is recommended for clarity and future support.
-
Moved to
IITC.utils
without renaming:-
window.getURLParam
- moved toIITC.utils.getURLParam
-
window.zeroPad
- moved toIITC.utils.zeroPad
-
window.unixTimeToString
- moved toIITC.utils.unixTimeToString
-
window.unixTimeToDateTimeString
- moved toIITC.utils.unixTimeToDateTimeString
-
window.unixTimeToHHmm
- moved toIITC.utils.unixTimeToHHmm
-
window.formatInterval
- moved toIITC.utils.formatInterval
-
window.formatDistance
- moved toIITC.utils.formatDistance
-
window.isTouchDevice
- moved toIITC.utils.isTouchDevice
-
window.scrollBottom
- moved toIITC.utils.scrollBottom
-
window.escapeJavascriptString
- moved toIITC.utils.escapeJavascriptString
-
window.escapeHtmlSpecialChars
- moved toIITC.utils.escapeHtmlSpecialChars
-
window.prettyEnergy
- moved toIITC.utils.prettyEnergy
-
window.uniqueArray
- moved toIITC.utils.uniqueArray
-
window.genFourColumnTable
- moved toIITC.utils.genFourColumnTable
-
window.convertTextToTableMagic
- moved toIITC.utils.convertTextToTableMagic
-
window.clamp
- moved toIITC.utils.clamp
-
window.clampLatLng
- moved toIITC.utils.clampLatLng
-
window.clampLatLngBounds
- moved toIITC.utils.clampLatLngBounds
-
-
Moved to
IITC.utils
with renaming:-
window.readCookie
- renamed and moved toIITC.utils.getCookie
-
window.writeCookie
- renamed and moved toIITC.utils.setCookie
-
window.eraseCookie
- renamed and moved toIITC.utils.deleteCookie
-
window.digits
- renamed and moved toIITC.utils.formatNumber
-
window.pnpoly
- renamed and moved toIITC.utils.isPointInPolygon
-
For IITC users
-
Guide on how to migrate data from an legacy version of IITC Mobile
-
(click to expand )
Cache (Data caching to prevent reloading)
Controls (Map controls/widgets)
Draw (Allow drawing things onto the current map so you may plan your next move)
Highlighter (Portal highlighters)
- Hide portal ownership
- Highlight portals by level color
- Highlight inactive portals
- Highlight portal weakness
- Highlight high level portals
- Highlight portals by my level
- Highlight portals with ornaments
- Highlight portals that need recharging
- Highlight portals with ornaments
- Highlight portals that need recharging
- Highlight portals missing resonators
- Highlight portals with infrastructure problems
Info (Display additional information)
- Available AP statistics
- Portal count
- Portals list
- Player level guess
- Localized scoreboard
- Missions
- Scoring cycle / checkpoint times
- Layer count
Layer (Additional map layers)
- Find farms on map
- Portal Level Numbers
- Overlay KML / GPX / GeoJSON
- Ingress scoring regions
- Zaprange
- Player activity tracker
- Portal Names
- Keys on map
Map Tiles (Alternative map layers)
- Stamen.com map layers
- Blank map
- Gray Google map
- Bing maps
- OpenStreetMap.org map
- Gaode (高德地图) / AutoNavi map
- Kartverket.no maps (Norway)
- Yandex maps
Portal Info (Enhanced information on the selected portal)
Tweaks (Adjust IITC settings)
Misc (Unclassified plugins)
For plugin developers
For IITC developers