Mercurial > hg > LGServices
view src/main/webapp/resources/js/general.js @ 77:997601ee0c6e
fix form submit issue above Chrome 56.x edition
author | Calvin Yeh <cyeh@mpiwg-berlin.mpg.de> |
---|---|
date | Wed, 03 May 2017 19:51:43 +0200 |
parents | 6ad066ddf3fe |
children | b27a99201cbe |
line wrap: on
line source
function getChromeVersion(){ var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./); return raw ? parseInt(raw[2], 10) : false; } function branchInExtractionInterface( branchId, fileId, sectionId, sectionName, bookId, bookName, userId, extractionInterfaceUrl){ // the input parameters contain fileId, since a branch means a text/many version of the text, of a section var form = document.createElement("form"); form.setAttribute("method", "post"); form.setAttribute("action", extractionInterfaceUrl + "/Extractapp/TaggingText"); // hand to controller form.setAttribute("target", "_blank"); var hiddenField0 = document.createElement("input"); hiddenField0.setAttribute("name", "branchId"); hiddenField0.setAttribute("value", branchId); form.appendChild(hiddenField0); var hiddenField1 = document.createElement("input"); hiddenField1.setAttribute("name", "fileId"); hiddenField1.setAttribute("value", fileId); form.appendChild(hiddenField1); var hiddenField2 = document.createElement("input"); hiddenField2.setAttribute("name", "userId"); hiddenField2.setAttribute("value", userId); form.appendChild(hiddenField2); var hiddenField3 = document.createElement("input"); hiddenField3.setAttribute("name", "sectionId"); hiddenField3.setAttribute("value", sectionId); form.appendChild(hiddenField3); var hiddenField4 = document.createElement("input"); hiddenField4.setAttribute("name", "sectionName"); hiddenField4.setAttribute("value", sectionName); form.appendChild(hiddenField4); var hiddenField5 = document.createElement("input"); hiddenField5.setAttribute("name", "bookId"); hiddenField5.setAttribute("value", bookId); form.appendChild(hiddenField5); var hiddenField6 = document.createElement("input"); hiddenField6.setAttribute("name", "bookName"); hiddenField6.setAttribute("value", bookName); form.appendChild(hiddenField6); console.log(navigator.userAgent.toLowerCase()); if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1 || getChromeVersion() > 55) { document.body.appendChild(form); form.submit(); document.body.removeChild(form); } else { form.submit(); // works under IE, neither FF nor Chrome } } function sectionInExtractionInterface(sectionId, sectionName, bookId, bookName, topicId, userId, extractionInterfaceUrl){ // the input parameters contain no fileId, since it's from searching result and haven't assigned topic Or saved var form = document.createElement("form"); form.setAttribute("method", "post"); form.setAttribute("action", extractionInterfaceUrl + "/Extractapp/TaggingText"); // hand to controller form.setAttribute("target", "_blank"); var hiddenField2 = document.createElement("input"); hiddenField2.setAttribute("name", "userId"); hiddenField2.setAttribute("value", userId); form.appendChild(hiddenField2); var hiddenField3 = document.createElement("input"); hiddenField3.setAttribute("name", "sectionId"); hiddenField3.setAttribute("value", sectionId); form.appendChild(hiddenField3); var hiddenField4 = document.createElement("input"); hiddenField4.setAttribute("name", "sectionName"); hiddenField4.setAttribute("value", sectionName); form.appendChild(hiddenField4); var hiddenField5 = document.createElement("input"); hiddenField5.setAttribute("name", "bookId"); hiddenField5.setAttribute("value", bookId); form.appendChild(hiddenField5); var hiddenField6 = document.createElement("input"); hiddenField6.setAttribute("name", "bookName"); hiddenField6.setAttribute("value", bookName); form.appendChild(hiddenField6); var hiddenField7 = document.createElement("input"); hiddenField7.setAttribute("name", "topic"); hiddenField7.setAttribute("value", topicId); form.appendChild(hiddenField7); if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1 || getChromeVersion() > 55) { document.body.appendChild(form); form.submit(); document.body.removeChild(form); } else { form.submit(); // works under IE, neither FF nor Chrome } } $(document).ready(function() { $('.double-scroll').doubleScroll(); });