xhr.onerror = function() { console.log('Fatal error: ' + xhr); t_vote__showError(opts.voteID, ''); }; xhr.send(formData);}/** * Converts a multi-level object to a single-level one with question and answer data to send * * @param {object} objData - object with data * @param {string | undefined} strKey - str array key + index * @returns {object} - return new object */ function t_vote__getObjParams(objData, strKey) { var newObj = {}; var strKey = strKey ? strKey : ''; Array.prototype.forEach.call(Object.keys(objData), function(key) { if (Array.isArray(objData[key])) { Array.prototype.forEach.call(objData[key], function(obj, ind) { if (obj instanceof Object) { strKey = key + '[' + ind + ']'; Object.assign(newObj, t_vote__getObjParams(obj, strKey)); strKey = ''; } else { var str = strKey + '[' + key + ']' + '[]'; newObj[str] = obj; } }); } else { if (strKey) { var str = strKey + '[' + key + ']'; newObj[str] = objData[key]; } else { newObj[key] = objData[key]; } } }); return newObj;}/** * Overwrites cookies on successful request * * @param {object} data - request result * @param {object} opts - data params vote */function t_vote__writeSendCookie(data, opts) { if (data['message'] === 'ok') { t_vote__setCookie('vote' + data['voteid'], opts.voteHash, { expires: 3600 * 24, }); if (opts.type === 'single') { t_vote__setCookie('voteresult' + data['voteid'], opts.answerID, { expires: 3600 * 24, }); t_vote__setCookie('vote_candelete' + data['voteid'], 'yes', { expires: 1800, }); } }}/** * Overwrite the voice when you click on the selected voice again in a single vote * * @param {object} opts - data params vote */function t_vote__itemDelete_single(opts) { opts.seconds_fromStart = (new Date().getTime() - opts.startDate.getTime()) / 1000; t_vote__changeVoteCondition(opts, 'remove'); opts.voteEl.classList.add('js-vote-sending'); opts.voteEl.classList.remove('t-vote_sended'); t_vote__addLoadingStyle(opts.voteEl); opts.voteHash = t_vote__getCookie('vote' + opts.voteID); var sendData = { voteid: opts.voteID,