function splitEvents (events, id) {
	// Global events
	const rwindow = /^((after|before)print|(before)?unload|hashchange|message|o(ff|n)line|page(hide|show)|popstate|resize|storage)\b/;
	// add player ID as an event namespace so it's easier to unbind them all later
	const ret = {d: [], w: []};
	(events || '').split(' ').forEach((v) => {
		const eventName = `${v}${(id ? `.${id}` : '')}`;

		if (eventName.startsWith('.')) {
			ret.d.push(eventName);
			ret.w.push(eventName);
		}
		else {
			ret[rwindow.test(v) ? 'w' : 'd'].push(eventName);
		}
	});

	ret.d = ret.d.join(' ');
	ret.w = ret.w.join(' ');
	return ret;
}
Group a string of events into `document` (d) and `window` (w) events

@param {String} events  List of space separated events
@param {String} id      Namespace appended to events
@return {{d: Array, w: Array}}