function ItemRatingCallBack( vote, ident ) { xajax_jsRate(vote, ident); } var mcr_rating = new Object(); /* * This function is used to rate Multicriteria Rating fields. * * NOTES: * Sometimes the form (mcrform) which is used here is enclosed * by the outer adminForm. So, there are some workarounds here. * '_EN_SEP_' is just a separator. */ function MCRRatingCallBack(vote, id) { var fieldData = id.split(new RegExp("_EN_SEP_")); if (fieldData.length == 3) { var s = ''; var recId = fieldData[ 0 ]; var varName = fieldData[ 1 ]; var uid = fieldData[ 2 ]; var fName = ''; varName = varName.replace(/ /, mcr_rating[uid].spaceSeparator); // Put the vote. for (var i = 0; i < mcr_rating[uid].fields.length; i++){ if (mcr_rating[uid].fields[ i ].name == varName) { mcr_rating[uid].fields[ i ].vote = vote; fName = mcr_rating[uid].fields[ i ].viewName; } } if (fName.indexOf('__') == 0) fName = fName.substr( 2 ); insertRatingInfo(fName, vote + '%', uid); // show the save button var saveButton = 'mcr_save_button_' + recId + uid; document.getElementById(saveButton).style.display = 'block'; } } function insertRatingInfo(description, vote, uid) { var id = mcr_rating[uid].id; var pos = description.indexOf(mcr_rating[uid].separator); if (pos > 0){ description = description.substr(0, pos); } var vater = document.getElementById('mcr_user_ratings' + id + uid); // Elements to insert var tr = document.createElement("tr"); var tdLeft = document.createElement("td"); var tdRight = document.createElement("td"); // text to insert var descText = document.createTextNode(description); var voteText = document.createTextNode(vote); // Check the thead text. headInserted = mcr_rating[uid].headInserted; if (!headInserted || headInserted == 'undefined') { var tr2 = document.createElement("tr"); var td = document.createElement("td"); var td2 = document.createElement("td"); var titleText = document.createTextNode(mcr_rating[uid].headText); td.appendChild(titleText); tr2.appendChild( td ); tr2.appendChild( td2 ); vater.appendChild( tr2 ); mcr_rating[uid].headInserted = true; } tdLeft.appendChild( descText ); tdRight.appendChild( voteText ); tr.appendChild(tdLeft); tr.appendChild(tdRight); vater.appendChild( tr ); } /* * Warning: this function modifies the url! */ function mcrsubmit(uid) { mcr_rating[uid].url = en_removeParam(mcr_rating[uid].url, 'user_id'); var form = en_createForm(uid); form.submit(); } function en_createForm(uid) { if (mcr_rating[uid].formCreated) return document.forms[mcr_rating[uid].formName]; //var debugStr = ''; var p = document.body; var form = document.createElement('form'); var inp = null; form.method = 'post'; form.name = mcr_rating[uid].formName; form.action = mcr_rating[uid].url; for (var i = 0; i < mcr_rating[uid].fields.length; i++){ inp = document.createElement('input'); inp.type = 'hidden'; inp.name = 'fields[' + mcr_rating[uid].id + '][' + mcr_rating[uid].fields[ i ].name + ']'; inp.value = mcr_rating[uid].fields[ i ].vote; form.appendChild( inp ); //debugStr += 'name: ' + inp.name + ' value: ' + inp.value + '\n'; } inp = document.createElement('input'); inp.type = 'hidden'; inp.name = mcr_rating[uid].saveCmd.name; inp.value = mcr_rating[uid].saveCmd.value; form.appendChild( inp ); p.appendChild( form ); mcr_rating[uid].formCreated = true; //alert (debugStr); return form; } function en_removeParam(url, param) { var i = url.indexOf(param); if (i >= 0) { var last = url.indexOf('&', i); if (last > 0) { return url.substr(0, i) + url.substr(last + 1); } else return url.substr(0, i); } return url; }