''' try: jsFile = open('phase3.html','w+') except IOError as e: print "I/O error({0}): {1}".format(e.errno, e.strerror) except ValueError: print "Could not convert data to an integer." except: print "Unexpected error:", sys.exc_info()[0] raise ''' print("Content-Type: text/html") print "" #print(""" """) genJS.genOpenTag() genJS.javaScriptType("jquery/jquery.js", "", "") countRows = executeQuery(sql[1]) countRows = map(int, countRows) colList = executeQuery(sql[0]) #print colList colListStr = ','.join(colList) emptyLst = [] for i in range(countRows[0]): emptyLst.append("") print("<script type=\"text/javascript\">\n") print("var count = %d;var table = %s;function getValues(event, n) {if(event.which == \"9\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));var val = focusedElement.attr(\"value\");var temp = ele/n;var tempDiff = temp%%1;temp = temp - tempDiff;var temp1 = ele%%n;table[temp][temp1] = val;}else if(event.which == \"13\") {var value = \"\";var i;var rowEntry = [];for(i = (count * n); i < ((count + 1) * n); i++) {var temp;temp = document.getElementById(\"attr\" + i);if(temp != null) {value = temp.value;if(value == \'\') {alert(\"enter attribute \" + (i + 1));break;}else {rowEntry.push(value);}}}table.push(rowEntry);count++;var newTableRow = $(document.createElement(\'tr\')).attr(\"id\", \'TableRow\' + count);newTableRow.after().html("%(int(countRows[0]), str(emptyLst))) genJS.genColumnTag(int(countRows[0]), len(colList)) print(");newTableRow.appendTo(\"#idTable\");document.getElementById(\"attr\" + (count * n)).focus();}else if(event.which == \"37\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele > 0) {var input = document.getElementById(\"attr\" + (ele - 1));input.focus();var val = input.value;input.value = \'\';input.value = val;}else {var input = document.getElementById(\"attr\" + ele);input.focus();var val = input.value;input.value = \'\';input.value = val;}}else if(event.which == \"38\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele >= n) {var input = document.getElementById(\"attr\" + (ele - n));input.focus();var val = input.value;input.value = \'\';input.value = val;}}else if(event.which == \"39\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele < (count * n) + %d) {var input = document.getElementById(\"attr\" + (ele + 1));input.focus();var val = input.value;input.value = \'\';input.value = val;}}else if(event.which == \"40\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele < (count * n)) {var input = document.getElementById(\"attr\" + (ele + n));input.focus();var val = input.value;input.value = \'\';input.value = val;}}}function submitTable(n) {var i;var rowEntry = [];for(i = 0; i < n; i++)rowEntry.push(document.getElementById(\"attr\" + ((count * n) + i)).value);console.log(count);table.push(rowEntry);for(i = 0; i <= count; i++)console.log(table[i]);}</script>"%(len(colList)-1)) print("\n<body>\n<table id=\"idTable\" border=\"1\" style=\"width:100%\">\n<tr id=\"tableHead\">\n")
return resList except: print "Error: unable to fecth data" db.close() try: jsFile = open('genTable.html','w+') except IOError as e: print "I/O error({0}): {1}".format(e.errno, e.strerror) except ValueError: print "Could not convert data to an integer." except: print "Unexpected error:", sys.exc_info()[0] raise genJS.genOpenTag(jsFile) genJS.javaScriptType(jsFile, "js/jquery-1.11.3.js", "", "") countRows = executeQuery(sql[1]) countRows = map(int, countRows) colList = executeQuery(sql[0]) colListStr = ','.join(colList) emptyLst = [] for i in range(countRows[0]): emptyLst.append("") jsFile.write("<script type=\"text/javascript\">\n") jsFile.write("var count = %d;var table = %s;function getValues(event, n) {if(event.which == \"9\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));var val = focusedElement.attr(\"value\");var temp = ele/n;var tempDiff = temp%%1;temp = temp - tempDiff;var temp1 = ele%%n;table[temp][temp1] = val;}else if(event.which == \"13\") {var value = \"\";var i;var rowEntry = [];for(i = (count * n); i < ((count + 1) * n); i++) {var temp;temp = document.getElementById(\"attr\" + i);if(temp != null) {value = temp.value;if(value == \'\') {alert(\"enter attribute \" + (i + 1));break;}else {rowEntry.push(value);}}}table.push(rowEntry);count++;var newTableRow = $(document.createElement(\'tr\')).attr(\"id\", \'TableRow\' + count);newTableRow.after().html("%(int(countRows[0]), str(emptyLst))) genJS.genColumnTag(jsFile, int(countRows[0]), len(colList)) jsFile.write(");newTableRow.appendTo(\"#idTable\");document.getElementById(\"attr\" + (count * n)).focus();}else if(event.which == \"37\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele > 0) {var input = document.getElementById(\"attr\" + (ele - 1));input.focus();var val = input.value;input.value = \'\';input.value = val;}else {var input = document.getElementById(\"attr\" + ele);input.focus();var val = input.value;input.value = \'\';input.value = val;}}else if(event.which == \"38\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele >= n) {var input = document.getElementById(\"attr\" + (ele - n));input.focus();var val = input.value;input.value = \'\';input.value = val;}}else if(event.which == \"39\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele < (count * n) + %d) {var input = document.getElementById(\"attr\" + (ele + 1));input.focus();var val = input.value;input.value = \'\';input.value = val;}}else if(event.which == \"40\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele < (count * n)) {var input = document.getElementById(\"attr\" + (ele + n));input.focus();var val = input.value;input.value = \'\';input.value = val;}}}function submitTable(n) {var i;var rowEntry = [];for(i = 0; i < n; i++)rowEntry.push(document.getElementById(\"attr\" + ((count * n) + i)).value);console.log(count);table.push(rowEntry);for(i = 0; i <= count; i++)console.log(table[i]);}</script>"%(len(colList)-1)) jsFile.write("\n<body>\n<table id=\"idTable\" border=\"1\" style=\"width:100%\">\n<tr id=\"tableHead\">\n") genJS.genAttrNames(jsFile, colList)
return resList except: print "Error: unable to fecth data" db.close() try: jsFile = open('phase3.html', 'w+') except IOError as e: print "I/O error({0}): {1}".format(e.errno, e.strerror) except ValueError: print "Could not convert data to an integer." except: print "Unexpected error:", sys.exc_info()[0] raise genJS.genOpenTag(jsFile) genJS.javaScriptType(jsFile, "js/jquery-1.11.3.js", "", "") countRows = executeQuery(sql[1]) countRows = map(int, countRows) colList = executeQuery(sql[0]) colListStr = ','.join(colList) emptyLst = [] for i in range(countRows[0]): emptyLst.append("") jsFile.write("<script type=\"text/javascript\">\n") jsFile.write( "var count = %d;var table = %s;function getValues(event, n) {if(event.which == \"9\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));var val = focusedElement.attr(\"value\");var temp = ele/n;var tempDiff = temp%%1;temp = temp - tempDiff;var temp1 = ele%%n;table[temp][temp1] = val;}else if(event.which == \"13\") {var value = \"\";var i;var rowEntry = [];for(i = (count * n); i < ((count + 1) * n); i++) {var temp;temp = document.getElementById(\"attr\" + i);if(temp != null) {value = temp.value;if(value == \'\') {alert(\"enter attribute \" + (i + 1));break;}else {rowEntry.push(value);}}}table.push(rowEntry);count++;var newTableRow = $(document.createElement(\'tr\')).attr(\"id\", \'TableRow\' + count);newTableRow.after().html(" % (int(countRows[0]), str(emptyLst))) genJS.genColumnTag(jsFile, int(countRows[0]), len(colList)) jsFile.write( ");newTableRow.appendTo(\"#idTable\");document.getElementById(\"attr\" + (count * n)).focus();}else if(event.which == \"37\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele > 0) {var input = document.getElementById(\"attr\" + (ele - 1));input.focus();var val = input.value;input.value = \'\';input.value = val;}else {var input = document.getElementById(\"attr\" + ele);input.focus();var val = input.value;input.value = \'\';input.value = val;}}else if(event.which == \"38\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele >= n) {var input = document.getElementById(\"attr\" + (ele - n));input.focus();var val = input.value;input.value = \'\';input.value = val;}}else if(event.which == \"39\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele < (count * n) + %d) {var input = document.getElementById(\"attr\" + (ele + 1));input.focus();var val = input.value;input.value = \'\';input.value = val;}}else if(event.which == \"40\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele < (count * n)) {var input = document.getElementById(\"attr\" + (ele + n));input.focus();var val = input.value;input.value = \'\';input.value = val;}}}function submitTable(n) {var i;var rowEntry = [];for(i = 0; i < n; i++)rowEntry.push(document.getElementById(\"attr\" + ((count * n) + i)).value);console.log(count);table.push(rowEntry);for(i = 0; i <= count; i++)console.log(table[i]);}</script>"
""" try: jsFile = open('phase3.html','w+') except IOError as e: print "I/O error({0}): {1}".format(e.errno, e.strerror) except ValueError: print "Could not convert data to an integer." except: print "Unexpected error:", sys.exc_info()[0] raise """ print ("Content-Type: text/html") print "" # print(""" """) genJS.genOpenTag() genJS.javaScriptType("jquery/jquery.js", "", "") countRows = executeQuery(sql[1]) countRows = map(int, countRows) colList = executeQuery(sql[0]) # print colList colListStr = ",".join(colList) emptyLst = [] for i in range(countRows[0]): emptyLst.append("") print ('<script type="text/javascript">\n') print ( 'var count = %d;var table = %s;function getValues(event, n) {if(event.which == "9") {var focusedElement = $(":focus");var ele = Number(focusedElement.attr("id").slice(4));var val = focusedElement.attr("value");var temp = ele/n;var tempDiff = temp%%1;temp = temp - tempDiff;var temp1 = ele%%n;table[temp][temp1] = val;}else if(event.which == "13") {var value = "";var i;var rowEntry = [];for(i = (count * n); i < ((count + 1) * n); i++) {var temp;temp = document.getElementById("attr" + i);if(temp != null) {value = temp.value;if(value == \'\') {alert("enter attribute " + (i + 1));break;}else {rowEntry.push(value);}}}table.push(rowEntry);count++;var newTableRow = $(document.createElement(\'tr\')).attr("id", \'TableRow\' + count);newTableRow.after().html(' % (int(countRows[0]), str(emptyLst)) ) genJS.genColumnTag(int(countRows[0]), len(colList))