//Globale variables app.getSharedData().changeLanguage = false; app.getSharedData().strings = ""; var form = app.getForm("F_Form1"); /** * Returns the "str" attribute from the provided list for the specified language. * In this case the list object is an object array like: * * [{"lang": "English", "str":"Name"},{"lang": "French", "str":"Nom"},{"lang": "Spanish", "str":"Nombre"}] * * theList: the list object * theLang: the language to return, it must match the string in the "lang" attribute * * return: the value of the "str" attribute */ app.getSharedData().getLangStr = function(theList, theLang) { var str = ""; for(var i=0;i 0) { for(var j=0;j element var td = qFields.item(j); //get the child var qInput = td.getElementsByTagName("input"); var qName = get(qInput, 0).name; var searchStr = '_option' + colNum.toString(); if(qName.indexOf(searchStr) != -1) { get(qInput, 0).title = newString; } } //change the column titles - get elements by class name var questionList = document.getElementsByClassName(surveyID); var tempItem = get(questionList, 0); var tempQText = tempItem.getElementsByClassName("rating-title"); get(tempQText, colNum).innerHTML = newString; } } /** * Can be used to change the title of most objects in a form. This function was built by inspecting the HTML * that was generated by FEB 8.0. * * Note: Because this is undocumented, if the HTML changes in future releases then it * will potentially break this function. * * theID: the ID of the item to change and it must be in the format: form.getId() + "-" + thePID + "-" + theItemID * secClassName: the css class of the object: * fields (single, multi, number, email, password, etc) = "lfFormLabel" * surveyWidget = "lfFormFieldSurveyTitle" */ app.getSharedData().changeItemTitle = function(itemID, theID, secClassName, newString) { var w = get(itemID, "__widget"); debugger; //get elements by class name var questionList = document.getElementsByClassName(theID); var tempItem = get(questionList, 0); var tempQText = tempItem.getElementsByClassName(secClassName); //gets the inner label object and sets its value get(tempQText, 0).innerHTML = newString; } /** * Sorts the table by PID, FID, index. The column ID's are hard-coded in this function * want to pass and array of column ids, the table should be sorted in the order provided * * theItem: the Table object to sort */ app.getSharedData().sortTable = function(theItem) { var tblLength = theItem.getLength(); //build the array with all the columns var records = new Array(); for(var i = 0; i < tblLength; i++) { var newObj = {pageID: theItem.get(i).F_TPageID.getValue() , fieldID: theItem.get(i).F_TItemID.getValue(), type: theItem.get(i).F_TItemType.getValue(), index: theItem.get(i).F_TIndex.getValue(),lang: theItem.get(i).F_TLang.getValue(),str: theItem.get(i).F_TLabelText.getValue()}; set(records, i, newObj); } //sort the list if(records !== null) { records.sort(function(a,b) { var pid1 = get(a, 'pageID'); var pid2 = get(b, 'pageID'); var fid1 = get(a, 'fieldID'); var fid2 = get(b, 'fieldID'); var in1 = get(a, 'index'); var in2 = get(b, 'index'); //sort by PID if(pid1 !== pid2) { if(pid1 < pid2) return -1; if(pid1 > pid2) return 1; return 0; } //sort by FID if(fid1 !== fid2) { if(fid1 < fid2) return -1; if(fid1 > fid2) return 1; return 0; } //sort by index if(in1 !== in2) { if(in1 < in2) return -1; if(in1 > in2) return 1; return 0; } }); //clear the table theItem.setValue(new Array()); //add each record back in for(var j=0;j< records.length;j++) { var row = theItem.createNew(); row.F_TPageID.setValue(get(get(records,j), 'pageID')); row.F_TItemID.setValue(get(get(records,j), 'fieldID')); row.F_TItemType.setValue(get(get(records,j), 'type')); row.F_TIndex.setValue(get(get(records,j), 'index')); row.F_TLang.setValue(get(get(records,j), 'lang')); row.F_TLabelText.setValue(get(get(records,j), 'str')); theItem.add(row); } } } //check to see if entry exists in the table first app.getSharedData().checkTableForEntry = function(theTable, pageID, fieldID, lang, label) { var entryFound = false; for(var i = 0; i < theTable.getLength(); i++) { var row = theTable.get(i); if(get(row, 'F_TPageID').getValue() === pageID && get(row, 'F_TItemID').getValue() === fieldID && get(row, 'F_TLang').getValue() === lang && get(row, 'F_TLabelText').getValue() === label) { entryFound = true; break; } } return entryFound; }