Skip to content
Snippets Groups Projects
Commit 865644f8 authored by Bruno Nocera Zanette's avatar Bruno Nocera Zanette
Browse files

Store all Javascript at the same place

Store all Javascript at the same place
parent aebf9744
No related branches found
No related tags found
No related merge requests found
......@@ -70,6 +70,85 @@
document.getElementById(id).id=id+"_stylized";
}
function showRedirect(){
var radioElements = document.getElementsByName("radioButton");
console.log("${path}");
for (var i=0; i < radioElements.length; i++)
if(radioElements[i].checked == true) {
var pathHeader = window.location.href.substring(0,window.location.href.lastIndexOf("${path}"));
if ("${select}" == "false")
window.location.href=pathHeader+"${path}/"+radioElements[i].value;
else {
var str = "${pathShow}";
pathHeader = window.location.href.substring(0,window.location.href.lastIndexOf("programas/"));
window.location.href=pathHeader+str+"/"+radioElements[i].value;
}
}
}
function updateRedirect(){
var radioElements = document.getElementsByName("radioButton");
for (var i=0; i < radioElements.length; i++)
if(radioElements[i].checked == true) {
var pathHeader = window.location.href.substring(0,window.location.href.lastIndexOf("${path}"));
var form = "${path}".indexOf("ocorrenciamunicipais") != -1 ? "?formUpdate" : "?form";
window.location.href=pathHeader+"${path}/"+radioElements[i].value+form;
}
}
function deleteRedirect(){
var radioElements = document.getElementsByName("radioButton");
for (var i=0; i < radioElements.length; i++)
if(radioElements[i].checked == true) {
var pathHeader = window.location.href.substring(0,window.location.href.lastIndexOf("${path}"));
document.deleteForm.action = pathHeader+"${path}/"+radioElements[i].value;
return confirm('${delete_confirm_msg}');
}
}
function post(){
var form = document.getElementById("programa") == null ? document.getElementById("ocorrenciaMunicipal") : document.getElementById("programa");
console.log(form);
form.action = selectRedirect();
form.submit();
}
function selectRedirect(){
var radioElements = document.getElementsByName("radioButton");
var selected ="";
for (var i=0; i < radioElements.length; i++){
if(radioElements[i].checked == true) {
selected += radioElements[i].value + "+";
}
}
selected = selected.substring(0,selected.lastIndexOf("+"));
var progIndex = window.location.pathname.indexOf("/programas");
if(progIndex == -1){
progIndex = window.location.pathname.indexOf("/ocorrenciamunicipais");
var pathHeader = window.location.pathname.substring(0,progIndex)+"/ocorrenciamunicipais";
}else{
var pathHeader = window.location.pathname.substring(0,progIndex)+"/programas";
}
pathHeader = pathHeader.charAt(pathHeader.length - 1) == "/" ? pathHeader.slice(0,pathHeader.length-1) : pathHeader;
if(window.location.pathname.indexOf("pesquisa") != -1){
pathHeader += "/pesquisa";
}
var form = "";
if("${Itinerante}"=="true"){
form = "/formItinerante/";
}else{
form = "/form/";
}
return pathHeader+form+selected;
}
</script>
<table class="table-with-utilbox">
......@@ -287,91 +366,6 @@
</table>
<script type="text/javascript">
function showRedirect(){
var radioElements = document.getElementsByName("radioButton");
console.log("${path}");
for (var i=0; i &lt; radioElements.length; i++)
if(radioElements[i].checked == true) {
var pathHeader = window.location.href.substring(0,window.location.href.lastIndexOf("${path}"));
if ("${select}" == "false")
window.location.href=pathHeader+"${path}/"+radioElements[i].value;
else {
var str = "${pathShow}";
pathHeader = window.location.href.substring(0,window.location.href.lastIndexOf("programas/"));
window.location.href=pathHeader+str+"/"+radioElements[i].value;
}
}
}
function updateRedirect(){
var radioElements = document.getElementsByName("radioButton");
for (var i=0; i &lt; radioElements.length; i++)
if(radioElements[i].checked == true) {
var pathHeader = window.location.href.substring(0,window.location.href.lastIndexOf("${path}"));
var form = "${path}".indexOf("ocorrenciamunicipais") != -1 ? "?formUpdate" : "?form";
window.location.href=pathHeader+"${path}/"+radioElements[i].value+form;
}
}
function deleteRedirect(){
var radioElements = document.getElementsByName("radioButton");
for (var i=0; i &lt; radioElements.length; i++)
if(radioElements[i].checked == true) {
var pathHeader = window.location.href.substring(0,window.location.href.lastIndexOf("${path}"));
document.deleteForm.action = pathHeader+"${path}/"+radioElements[i].value;
return confirm('${delete_confirm_msg}');
}
}
function post(){
var form = document.getElementById("programa") == null ? document.getElementById("ocorrenciaMunicipal") : document.getElementById("programa");
console.log(form);
form.action = selectRedirect();
form.submit();
}
function selectRedirect(){
var radioElements = document.getElementsByName("radioButton");
var selected ="";
for (var i=0; i &lt; radioElements.length; i++){
if(radioElements[i].checked == true) {
selected += radioElements[i].value + "+";
}
}
selected = selected.substring(0,selected.lastIndexOf("+"));
var progIndex = window.location.pathname.indexOf("/programas");
if(progIndex == -1){
progIndex = window.location.pathname.indexOf("/ocorrenciamunicipais");
var pathHeader = window.location.pathname.substring(0,progIndex)+"/ocorrenciamunicipais";
}else{
var pathHeader = window.location.pathname.substring(0,progIndex)+"/programas";
}
pathHeader = pathHeader.charAt(pathHeader.length - 1) == "/" ? pathHeader.slice(0,pathHeader.length-1) : pathHeader;
if(window.location.pathname.indexOf("pesquisa") != -1){
pathHeader += "/pesquisa";
}
var form = "";
if("${Itinerante}"=="true"){
form = "/formItinerante/";
}else{
form = "/form/";
}
return pathHeader+form+selected;
}
</script>
</c:if>
</jsp:root>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment