Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

413 lines
14 KiB

  1. <%
  2. Response.Expires = 0
  3. Dim i,j,ix,typeFl,mx,filn,opn
  4. %>
  5. <html>
  6. <!--
  7. display expression builder list
  8. QueryString : as necessary for updcnfg.asp invocation
  9. if configuration is to be updated and window refreshed
  10. ( e.g. when raid2.asp window updates configuration )
  11. -->
  12. <head>
  13. <style type="text/css">
  14. .st1 {color:red}
  15. .act {color:menutext; background:menu; cursor:default;}
  16. .fltl {position:relative; left:-8pt; top:-14pt;}
  17. .db {}
  18. </style>
  19. <script language="JavaScript">
  20. var OpName = new Array("Equals","Not Equal","Greater Than","Greater Than or Equals","Less Than","Less Than or Equals","Contains","Not Contains");
  21. var OpOp = new Array("=","<>",">",">=","<","<=","LIKE","NOT LIKE");
  22. var OpType = new Array(1023,1023,1023,1023,1023,1023,4,4);
  23. var CombType = new Array("AND","OR");
  24. </script>
  25. <!--#include virtual="/scripts/raid/cache.asp"-->
  26. <!--#include virtual="/scripts/raid/updcnfg.asp"-->
  27. <%
  28. IncludeItemCache
  29. Response.Write "<script language=" & chr(34) & "JavaScript" & chr(34) & ">"
  30. FldArray = Application("fld" & Application("dbCache")(Session("DBSOURCE")))
  31. FltArray = Session("FltArray")
  32. Response.Write "var FldDBName = new Array("
  33. mx = UBound(FldArray,2)
  34. for i = 0 to mx
  35. if FldArray(7,i) < 12 then
  36. if i > 0 then
  37. Response.Write ","
  38. end if
  39. Response.Write chr(34) & FldArray(0,i) & chr(34)
  40. end if
  41. next
  42. Response.Write "); var FldName = new Array("
  43. for i = 0 to mx
  44. if FldArray(7,i) < 12 then
  45. if i > 0 then
  46. Response.Write ","
  47. end if
  48. Response.Write chr(34) & FldArray(1,i) & chr(34)
  49. end if
  50. next
  51. Response.Write "); var FldType = new Array("
  52. for i = 0 to mx
  53. if FldArray(7,i) < 12 then
  54. if i > 0 then
  55. Response.Write ","
  56. end if
  57. Response.Write chr(34) & FldArray(7,i) & chr(34)
  58. end if
  59. next
  60. Response.Write ");"
  61. %>
  62. function delrow() {
  63. event.srcElement.parentElement.parentElement.parentElement.deleteRow(event.srcElement.parentElement.rowIndex);
  64. }
  65. function FList() {
  66. s = window.showModalDialog( "/scripts/raid/raid4.asp?type=list", "list", "dialogWidth:300pt; dialogHeight:200pt" );
  67. if ( s != null ) {
  68. document.all.fieldlist.value = s;
  69. document.all.save.action = "/scripts/raid/raid2.asp?upd=list";
  70. document.all.save.target = "raid2";
  71. document.all.save.method = "POST";
  72. document.all.save.submit();
  73. }
  74. }
  75. function FSort() {
  76. s = window.showModalDialog( "/scripts/raid/raid4.asp?type=sort", "sort", "dialogWidth:300pt; dialogHeight:200pt" );
  77. if ( s != null ) {
  78. document.all.fieldsort.value = s;
  79. document.all.save.action = "/scripts/raid/raid2.asp?upd=sort";
  80. document.all.save.target = "raid2";
  81. document.all.save.method = "POST";
  82. document.all.save.submit();
  83. }
  84. }
  85. function updch(where) {
  86. nameFl = event.srcElement.value;
  87. for ( i = 0 ; i < FldDBName.length ; ++i )
  88. if ( FldDBName[i] == nameFl ) {
  89. typeFl = FldType[i];
  90. break;
  91. }
  92. s = "<select name=\"relop\">"
  93. for ( i = 0 ; i < OpName.length ; ++i )
  94. if ( OpType[i] & (1<<typeFl-1) )
  95. s = s + "<option value=\"" + OpOp[i] + "\">" + OpName[i];
  96. event.srcElement.parentElement.parentElement.cells[2].innerHTML = s;
  97. for ( j = 0 ; j < checkfields.length ; ++j ) {
  98. if ( checkfields[j] == nameFl ) {
  99. s = "<select class=\"inp\" name=\"cnt\" id=\"cnt\">";
  100. for ( k = 0 ; k < checks[j].length ; ++k ) {
  101. s = s + "<option value=\"" + checks[j][k] + "\""
  102. s = s + ">" + checks[j][k];
  103. }
  104. s = s + "</select>";
  105. break;
  106. }
  107. }
  108. if ( j == checkfields.length ) {
  109. s = "<input name=\"cnt\" id=\"cnt\" size=40></input>";
  110. }
  111. event.srcElement.parentElement.parentElement.cells[3].innerHTML = s;
  112. }
  113. function addrow(tbl,flddbname,relop,cnt,andor) {
  114. tbl = event.srcElement.parentElement.parentElement.parentElement;
  115. la = tbl.insertRow();
  116. for ( var i = 0 ; i < tbl.rows[0].cells.length ; ++i )
  117. la.insertCell();
  118. la.cells[1].innerText="Add";
  119. la.cells[1].className="act";
  120. la.cells[1].onclick = new Function("addrow(fl);");
  121. iNe = la.rowIndex-1;
  122. ne = tbl.rows[iNe];
  123. ne.cells[0].innerText = "Del";
  124. ne.cells[0].className = "act";
  125. ne.cells[0].onclick = new Function("delrow();");
  126. // fldname : value is DB field name
  127. ne.cells[1].className="";
  128. typeFl = 1;
  129. s = "<select id=\"dbname\" name=\"dbname\" onchange=\"updch(this)\">";
  130. for ( i = 0 ; i < FldDBName.length ; ++i ) {
  131. s = s + "<option value=\"" + FldDBName[i] + "\"";
  132. if ( flddbname != null && flddbname == FldDBName[i]) {
  133. s = s + " SELECTED";
  134. typeFl = FldType[i];
  135. }
  136. s = s + ">" + FldDBName[i];
  137. }
  138. ne.cells[1].innerHTML = s;
  139. ne.cells[1].className="";
  140. ne.cells[1].onclick = null;
  141. // relop : value SQL relop ( '=', '<>' ... )
  142. s = "<select id=\"relop\" name=\"relop\">";
  143. for ( i = 0 ; i < OpName.length ; ++i )
  144. if ( OpType[i] & typeFl ) {
  145. s = s + "<option value=\"" + OpOp[i] + "\"";
  146. if ( relop != null && OpOp[i] == relop ) {
  147. s = s + " SELECTED";
  148. }
  149. s = s + ">" + OpName[i];
  150. }
  151. ne.cells[2].innerHTML = s;
  152. ne.cells[3].innerHTML = "<input type=text id=\"cnt\" name=\"cnt\" size=40></input>"
  153. if ( cnt != null )
  154. ne.cells[3].innerText = cnt;
  155. // and/or : Value is And/Or
  156. s = "<select id=\"andor\" name=\"andor\"><option value=\"And\"";
  157. if ( andor != null && andor == "And" )
  158. s = s + " SELECTED";
  159. s = s + ">And<option value=\"Or\"";
  160. if ( andor != null && andor == "Or" )
  161. s = s + " SELECTED";
  162. s = s + ">Or</select>";
  163. ne.cells[4].innerHTML = s;
  164. }
  165. function BuildExp() {
  166. if ( document.all.item("dbname") == null )
  167. nb = 0;
  168. else if ( document.all.item("dbname").tagName == "SELECT" )
  169. nb = 1;
  170. else
  171. // this is a collection
  172. nb = document.all.item("dbname").length;
  173. s = "";
  174. for ( i = 0 ; i < nb ; ++i ) {
  175. dbname = document.all.item("dbname",i);
  176. relop = document.all.item("relop",i);
  177. andor = document.all.item("andor",i);
  178. for ( idbname = 0 ; idbname < dbname.length ; ++idbname ) {
  179. if ( dbname.item(idbname).selected ) {
  180. break;
  181. }
  182. }
  183. for ( irelop = 0 ; irelop < relop.length ; ++irelop ) {
  184. if ( relop.item(irelop).selected ) {
  185. break;
  186. }
  187. }
  188. for ( iandor = 0 ; iandor < andor.length ; ++iandor ) {
  189. if ( andor.item(iandor).selected ) {
  190. break;
  191. }
  192. }
  193. s = s + FldDBName[idbname] + " " + OpOp[irelop] + " "
  194. if ( FldType[idbname] == 2 ) // numeric
  195. s = s + document.all.item("cnt",i).value;
  196. else if ( FldType[idbname] == 4 ) { // date
  197. d = document.all.item("cnt",i).value.split("/");
  198. s = s + "{d'" + (d[2].length < 3 ? new Number(d[2])+1900 : d[2]) + "-" + (d[0].length==1 ? "0" : "") + d[0] + "-" + (d[1].length==1 ? "0" : "") + d[1] + "'}";
  199. }
  200. else {
  201. if ( OpOp[irelop] == "LIKE" || OpOp[irelop] == "NOT LIKE" )
  202. s = s + "'%" + document.all.item("cnt",i).value + "%'";
  203. else
  204. s = s + "'" + document.all.item("cnt",i).value + "'";
  205. }
  206. if ( i < nb-1 )
  207. s = s + " " + CombType[iandor] + " ";
  208. }
  209. document.all.fltexp.value = s;
  210. }
  211. function showexp() {
  212. BuildExp();
  213. s = prompt( "SQL expression: ", document.all.fltexp.value );
  214. if ( s != null ) {
  215. document.all.fltexp.value = s;
  216. }
  217. }
  218. function ExecQuery() {
  219. BuildExp();
  220. document.all.save.action = "/scripts/raid/raid2.asp?upd=flt";
  221. document.all.save.target = "raid2";
  222. document.all.save.method = "POST";
  223. document.all.save.submit();
  224. }
  225. function GoBug() {
  226. bugno = prompt( "Enter Bug number", "" );
  227. if ( bugno != null ) {
  228. window.open( "raid3.asp?BugID=" + bugno, "ntbug", "toolbar=no, menubar=no, location=no, directories=no, resizable=yes, scrollbars=yes, resizetab=yes" );
  229. }
  230. }
  231. function LoadQuery() {
  232. fname = prompt( "Enter filename", document.all.savename.value );
  233. if ( fname != null ) {
  234. if ( fname.indexOf(".") == -1 )
  235. fname = fname + ".asp";
  236. document.all.savename.value = fname;
  237. parent.window.location = "/scripts/raid/" + fname;
  238. parent.window.reload;
  239. }
  240. }
  241. function SaveQuery() {
  242. BuildExp();
  243. fname = prompt( "Enter filename where to store configuration", document.all.savename.value );
  244. if ( fname != null ) {
  245. if ( fname.indexOf(".") == -1 )
  246. fname = fname + ".asp";
  247. document.all.savename.value = fname;
  248. document.all.save.action = "/scripts/raid/save.asp?upd=sort,list,dbsource,flt,name";
  249. document.all.save.method = "POST";
  250. document.all.save.target = "raid1";
  251. document.all.save.submit();
  252. parent.window.location = "/scripts/raid/" + fname;
  253. }
  254. }
  255. function NewBug() {
  256. window.open( "raid3.asp?BugID=CREATE", "ntbug", "" );
  257. }
  258. </script>
  259. </head>
  260. <body bgcolor=#c0c0c0>
  261. <button onclick="ExecQuery()" id="ex" title="Execute query"><img src="exeq.gif"></button>
  262. <button onclick="NewBug()" title="New bug"><img src="donew.gif"></button>
  263. <input type=button id="go" OnClick="GoBug()" value="Goto"></input>
  264. <input type=button id="fl" OnClick="FList()" value="Define query field List"></input>
  265. <input type=button id="so" OnClick="FSort()" value="Define query sort order"></input>
  266. <input type=button id="ex" OnClick="showexp()" value="Edit SQL query"></input>
  267. <button id="lo" onclick="LoadQuery()" title="Load query"><img src="loadq.gif"></button>
  268. <button id="sa" onclick="SaveQuery()" title="Save query"><img src="saveq.gif"></button>
  269. <br>
  270. <form id="save" action="/scripts/raid/save.asp" method=POST>
  271. <input type=hidden name="savename" id="savename" value="<%=Session("Config")%>"></input>
  272. <input type=hidden name = "fltexp" id="fltexp""></input>
  273. <input type=hidden name = "fieldlist" id="fieldlist" value="<%=Session("FieldList")%>"></input>
  274. <input type=hidden name = "fieldsort" id="fieldsort" value="<%=Session("FieldSort")%>"></input>
  275. <table id="fl" class="fltl"><thead>
  276. <tr>
  277. <th align=left>&nbsp</th>
  278. <th align=left>Field Name</th>
  279. <th align=left>Operator</th>
  280. <th align=left width=300>Value</th>
  281. <th align=left>And/Or</th>
  282. </tr>
  283. </thead>
  284. <tbody id="act">
  285. <tr><td></td><td><select><option value="Database" class="db">Database</select></td><td><select><option value="Equals" selected>Equals</select></td>
  286. <td><select id="dbsource" name="dbsource">
  287. <%
  288. mx = UBound(Application("dbFriendlyName"))
  289. for i = 0 to mx
  290. Response.Write "<option value=" & chr(34) & i & chr(34)
  291. if i = Session("DBSOURCE") then
  292. Response.Write "selected"
  293. end if
  294. Response.Write ">" & Application("dbFriendlyName")(i)
  295. next
  296. %>
  297. </td><td><select><option value="And" selected>And</select></td></tr>
  298. <% if vbNull <> VarType(FltArray) then
  299. mx1 = UBound(FltArray,1)
  300. for i = 0 to mx1%>
  301. <tr><td class="act" onclick="delrow()">Del</td><td><select id="dbname" name="dbname" onchange="updch(this)">
  302. <%
  303. OpName = Array("Equals","Not Equal","Greater Than","Greater Than or Equals","Less Than","Less Than or Equals","Contains","Not Contains")
  304. OpOp = Array("=","<>",">",">=","<","<=","LIKE","NOT LIKE")
  305. OpType = Array(1023,1023,1023,1023,1023,1023,4,4)
  306. ix = 0
  307. filn = FltArray(i,0)
  308. opn = FltArray(i,1)
  309. mx = UBound(FldArray,2)
  310. for j = 0 to mx
  311. if FldArray(7,j) < 12 then
  312. Response.Write "<option value=" & chr(34) & FldArray(0,j) & chr(34)
  313. if filn = FldArray(0,j) then
  314. Response.Write "SELECTED"
  315. typeFl = FldArray(7,j)
  316. end if
  317. Response.Write ">" & FldArray(0,j)
  318. ix = ix + 1
  319. end if
  320. next
  321. Response.Write "</select></td>"
  322. Response.Write "<td><select id=" & chr(34) & "relop" & chr(34) & " name=" & chr(34) & "relop" & chr(34) & ">"
  323. mx = UBound(OpName)
  324. for j = 0 to mx
  325. if TRUE then
  326. Response.Write "<option value=" & chr(34) & OpOp(j) & chr(34)
  327. if opn = OpOp(j) then
  328. Response.Write "SELECTED"
  329. end if
  330. end if
  331. Response.Write ">" & OpName(j)
  332. next
  333. Response.Write "</select></td>"
  334. Response.Write "<td><input type=text id=" & chr(34) & "cnt" & chr(34) & " name=" & chr(34) & "cnt" & chr(34) & " size=40 "
  335. Response.Write " value=" & chr(34) & FltArray(i,2) & chr(34) & "></input></td>"
  336. Response.Write "<td><select id=" & chr(34) & "andor" & chr(34) & " name=" & chr(34) & "andor" & chr(34) & ">"
  337. if FltArray(i,3) = "And" then
  338. Response.Write "<option value=" & chr(34) & "And" & chr(34) & " SELECTED>And<option value=" & chr(34) & "Or" & chr(34) & ">Or"
  339. else
  340. Response.Write "<option value=" & chr(34) & "And" & chr(34) & ">And<option value=" & chr(34) & "Or" & chr(34) & " SELECTED>Or"
  341. end if
  342. Response.Write "</select></td>"
  343. next
  344. Response.Write "</tr>"
  345. end if
  346. %>
  347. <tr><td></td><td class="act" onclick="addrow(fl)">Add</td><td></td><td></td><td></td></tr>
  348. </tbody>
  349. </table></form>
  350. <%
  351. rem Response.Write "<script language=" & chr(34) & "JavaScript" & chr(34) & ">"
  352. rem mx = UBound(FltArray,1)
  353. rem for i = 0 to mx
  354. rem Response.Write "//addrow( fl," & chr(34) & FltArray(i,0) & chr(34) & ","
  355. rem Response.Write chr(34) & FltArray(i,1) & chr(34) & ","
  356. rem Response.Write chr(34) & FltArray(i,2) & chr(34) & ","
  357. rem Response.Write chr(34) & FltArray(i,3) & chr(34) & ");"
  358. rem next
  359. rem Response.Write "</script>"
  360. %>
  361. <script FOR=window EVENT=onload() language="JavaScript">
  362. BuildExp();
  363. </script>
  364. </body>
  365. </html>