Scripting question
Hi Chaps,
This is not a topic about a problem with ActiveWidgets, on the contrary, it's an issue with my limited knowledge of javascript.
What I would like to do, is perform a grid refresh if a file exists on the server and do nothing if it doesn't. I've put the code in I'm executing and it works fine but I need to call the vbscript stuff, but link it in to the following function:
window.setTimeout(function(){
table.setURL('mayexist.csv');
table.request();
}, 2000);
}
I guess I'm into the territory of calling a vbscript function from javascript.
Here's the html I am running:
<%
' **********************************
' Function to check file Existance
' **********************************
Function IsFileExists(byVal FileName)
If FileName = "" Then
IsFileExists = False
Exit Function
End If
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists( FileName ) = True Then
IsFileExists = True
Else
IsFileExists = False
End If
Set objFSO = Nothing
End Function
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Test</title>
<style>body {font: 8px Tahoma}</style>
<!-- include links to the script and stylesheet files -->
<script src="runtime/lib/aw.js"></script>
<link href="runtime/styles/xp/aw.css" rel="stylesheet"></link>
<!-- change default styles, set control size and position -->
<style>
#myGrid {height: 660px; width: 2000px}
#myGrid .aw-column-0 {width: 130px}
#myGrid .aw-column-1 {width: 180px}
#myGrid .aw-column-2 {width: 180px}
#myGrid .aw-column-3 {width: 180px}
#myGrid .aw-column-4 {width: 180px}
#myGrid .aw-column-5 {width: 180px}
#myGrid .aw-column-6 {width: 180px}
#myGrid .aw-column-7 {width: 180px}
#myGrid .aw-column-8 {width: 180px}
#myGrid .aw-column-9 {width: 180px}
#myGrid .aw-column-10 {width: 180px}
#myGrid .aw-cells-selected {background: none;}
#myGrid .aw-rows-selected {background:none;}
</style>
</head>
<!-- page layout -->
<body>
<!-- insert control tag -->
<span id="myGrid"></span>
<!-- create controls -->
<script>
var grid = new AW.UI.Grid;
grid.setId("myGrid");
grid.setHeaderVisible(false);
grid.setColumnIndices([0,1,2,3,4,5,6,7,8,9]);
grid.setColumnCount(10);
grid.refresh();
</script>
<script>
var table = new AW.CSV.Table;
table.response1 = table.response;
table.response = function(text){
this.response1(text);
var rowCount = this.getCount();
if (rowCount != grid.getRowCount()) {
grid.setRowCount(rowCount);
grid.refresh();
}
var columns = grid.getColumnIndices();
for (var r=0; r<rowCount;r++){
for (var i=0; i<columns.length;i++){
var c = columns[i];
var v = this.getData(c, r);
if (v != grid.getCellText(c, r)){
grid.setCellText(v, c, r);
highlight(c, r);
}
}
}
function highlight(c, r){
var e = grid.getCellTemplate(c, r).element();
if (e) {
e.style.color = "black";
window.setTimeout(function(){
e.style.color = "black";
e = null;
}, 1000);
}
}
window.setTimeout(function(){
table.setURL('mayexist.csv');
table.request();
}, 2000);
}
table.setURL('willexist.csv');
table.request() ;
</script>
<%
Dim FileName
FileName = "checkifexist.log"
FileName = Server.MapPath("/" & FileName)
If IsFileExists(FileName) = True Then
<!-- "I've put a msgbox in here for true but would really like the table.setURL('mayexist.csv') stuff" -->
msg = "exists"
Response.Write("<" & "script language=VBScript>")
Response.Write("MsgBox """ & msg & """<" & "/script>")
Else
<!-- "do nothing" -->
End If
%>
</body>
</html>
This is not a topic about a problem with ActiveWidgets, on the contrary, it's an issue with my limited knowledge of javascript.
What I would like to do, is perform a grid refresh if a file exists on the server and do nothing if it doesn't. I've put the code in I'm executing and it works fine but I need to call the vbscript stuff, but link it in to the following function:
window.setTimeout(function(){
table.setURL('mayexist.csv');
table.request();
}, 2000);
}
I guess I'm into the territory of calling a vbscript function from javascript.
Here's the html I am running:
<%
' **********************************
' Function to check file Existance
' **********************************
Function IsFileExists(byVal FileName)
If FileName = "" Then
IsFileExists = False
Exit Function
End If
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists( FileName ) = True Then
IsFileExists = True
Else
IsFileExists = False
End If
Set objFSO = Nothing
End Function
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Test</title>
<style>body {font: 8px Tahoma}</style>
<!-- include links to the script and stylesheet files -->
<script src="runtime/lib/aw.js"></script>
<link href="runtime/styles/xp/aw.css" rel="stylesheet"></link>
<!-- change default styles, set control size and position -->
<style>
#myGrid {height: 660px; width: 2000px}
#myGrid .aw-column-0 {width: 130px}
#myGrid .aw-column-1 {width: 180px}
#myGrid .aw-column-2 {width: 180px}
#myGrid .aw-column-3 {width: 180px}
#myGrid .aw-column-4 {width: 180px}
#myGrid .aw-column-5 {width: 180px}
#myGrid .aw-column-6 {width: 180px}
#myGrid .aw-column-7 {width: 180px}
#myGrid .aw-column-8 {width: 180px}
#myGrid .aw-column-9 {width: 180px}
#myGrid .aw-column-10 {width: 180px}
#myGrid .aw-cells-selected {background: none;}
#myGrid .aw-rows-selected {background:none;}
</style>
</head>
<!-- page layout -->
<body>
<!-- insert control tag -->
<span id="myGrid"></span>
<!-- create controls -->
<script>
var grid = new AW.UI.Grid;
grid.setId("myGrid");
grid.setHeaderVisible(false);
grid.setColumnIndices([0,1,2,3,4,5,6,7,8,9]);
grid.setColumnCount(10);
grid.refresh();
</script>
<script>
var table = new AW.CSV.Table;
table.response1 = table.response;
table.response = function(text){
this.response1(text);
var rowCount = this.getCount();
if (rowCount != grid.getRowCount()) {
grid.setRowCount(rowCount);
grid.refresh();
}
var columns = grid.getColumnIndices();
for (var r=0; r<rowCount;r++){
for (var i=0; i<columns.length;i++){
var c = columns[i];
var v = this.getData(c, r);
if (v != grid.getCellText(c, r)){
grid.setCellText(v, c, r);
highlight(c, r);
}
}
}
function highlight(c, r){
var e = grid.getCellTemplate(c, r).element();
if (e) {
e.style.color = "black";
window.setTimeout(function(){
e.style.color = "black";
e = null;
}, 1000);
}
}
window.setTimeout(function(){
table.setURL('mayexist.csv');
table.request();
}, 2000);
}
table.setURL('willexist.csv');
table.request() ;
</script>
<%
Dim FileName
FileName = "checkifexist.log"
FileName = Server.MapPath("/" & FileName)
If IsFileExists(FileName) = True Then
<!-- "I've put a msgbox in here for true but would really like the table.setURL('mayexist.csv') stuff" -->
msg = "exists"
Response.Write("<" & "script language=VBScript>")
Response.Write("MsgBox """ & msg & """<" & "/script>")
Else
<!-- "do nothing" -->
End If
%>
</body>
</html>
Tim
June 10,