Introduction
Introduction Statistics Contact Development Disclaimer Help
application.js - warvox - VoIP based wardialing tool, forked from rapid7/warvox.
git clone git://jay.scot/warvox
Log
Files
Refs
README
---
application.js (4442B)
---
1 // Place your application-specific JavaScript functions and classes here
2 // This file is automatically included by javascript_include_tag :defaul…
3 //= require jquery
4 //= require bootstrap-sprockets
5 //= require jquery_ujs
6 //= require bootstrap-lightbox
7 //= require dataTables/jquery.dataTables
8 //= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
9 //= require dataTables.hiddenTitle
10 //= require dataTables.filteringDelay
11 //= require dataTables.fnReloadAjax
12 //= require jquery.table
13 //= require dataTables_overrides
14 //= require highcharts
15
16
17 function getParameterByName(name)
18 {
19 name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
20 var regexS = "[\\?&]" + name + "=([^&#]*)";
21 var regex = new RegExp(regexS);
22 var results = regex.exec(window.location.href);
23 if(results == null)
24 return "";
25 else
26 return decodeURIComponent(results[1].replace(/\+/g, " "));
27 }
28
29
30 /*
31 * If the given select element is set to "", disables every other element
32 * inside the select's form.
33 */
34 function disable_fields_if_select_is_blank(select) {
35 var formElement = Element.up(select, "form");
36 var fields = formElement.getElements();
37
38 Element.observe(select, "change", function(e) {
39 var v = select.getValue();
40 for (var i in fields) {
41 if (fields[i] != select && fields[i].type && fie…
42 if (v != "") {
43 fields[i].disabled = true
44 } else {
45 fields[i].disabled = false;
46 }
47 }
48 }
49 });
50 }
51
52 function enable_fields_with_checkbox(checkbox, div) {
53 var fields;
54
55 if (!div) {
56 div = Element.up(checkbox, "fieldset")
57 }
58
59 f = function(e) {
60 fields = div.descendants();
61 var v = checkbox.getValue();
62 for (var i in fields) {
63 if (fields[i] != checkbox && fields[i].type && f…
64 if (!v) {
65 fields[i].disabled = true
66 } else {
67 fields[i].disabled = false;
68 }
69 }
70 }
71 }
72 f();
73 Element.observe(checkbox, "change", f);
74 }
75
76 function placeholder_text(field, text) {
77 var formElement = Element.up(field, "form");
78 var submitButton = Element.select(formElement, 'input[type="subm…
79
80 if (field.value == "") {
81 field.value = text;
82 field.setAttribute("class", "placeholder");
83 }
84
85 Element.observe(field, "focus", function(e) {
86 field.setAttribute("class", "");
87 if (field.value == text) {
88 field.value = "";
89 }
90 });
91 Element.observe(field, "blur", function(e) {
92 if (field.value == "") {
93 field.setAttribute("class", "placeholder");
94 field.value = text;
95 }
96 });
97 submitButton.observe("click", function(e) {
98 if (field.value == text) {
99 field.value = "";
100 }
101 });
102 }
103
104
105 function submit_checkboxes_to(path, token) {
106 var f = document.createElement('form');
107 f.style.display = 'none';
108
109 /* Set the post destination */
110 f.method = "POST";
111 f.action = path;
112
113 /* Create the authenticity_token */
114 var s = document.createElement('input');
115 s.setAttribute('type', 'hidden');
116 s.setAttribute('name', 'authenticity_token');
117 s.setAttribute('value', token);
118 f.appendChild(s);
119
120 /* Copy the checkboxes from the host form */
121 $("input[type=checkbox]").each(function(i,e) {
122 if (e.checked) {
123 var c = document.createElement('input');
124 c.setAttribute('type', 'hidden');
125 c.setAttribute('name', e.getAttribute('name') …
126 c.setAttribute('value', e.getAttribute('value') …
127 f.appendChild(c);
128 }
129 })
130
131 /* Look for hidden variables in checkbox form */
132 $("input[type=hidden]").each(function(i,e) {
133 if ( e.getAttribute('name').indexOf("[]") != -1 ) {
134 var c = document.createElement('input');
135 c.setAttribute('type', 'hidden');
136 c.setAttribute('name', e.getAttribute('name') …
137 c.setAttribute('value', e.getAttribute('value') …
138 f.appendChild(c);
139 }
140 })
141
142 /* Copy the search field from the host form */
143 $("input#search").each(function (i,e) {
144 if (e.getAttribute("class") != "placeholder") {
145 var c = document.createElement('input');
146 c.setAttribute('type', 'hidden');
147 c.setAttribute('name', e.getAttribute('name') …
148 c.setAttribute('value', e.value );
149 f.appendChild(c);
150 }
151 });
152
153 /* Append to the main form body */
154 document.body.appendChild(f);
155 f.submit();
156 return false;
157 }
158
159
160 // Look for the other half of this in app/coffeescripts/forms.coffee
161 function enableSubmitButtons() {
162 $("form.formtastic input[type='submit']").each(function(elmt) {
163 elmt.removeClassName('disabled'); elmt.removeClassName('submitting');
164 });
165 }
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.