xref: /aoo41x/main/sd/res/webview/common.inc (revision 7aab1a1c)
1*707d5dc6SAndrew Rist/**************************************************************
2*707d5dc6SAndrew Rist *
3*707d5dc6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*707d5dc6SAndrew Rist * or more contributor license agreements.  See the NOTICE file
5*707d5dc6SAndrew Rist * distributed with this work for additional information
6*707d5dc6SAndrew Rist * regarding copyright ownership.  The ASF licenses this file
7*707d5dc6SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*707d5dc6SAndrew Rist * "License"); you may not use this file except in compliance
9*707d5dc6SAndrew Rist * with the License.  You may obtain a copy of the License at
10*707d5dc6SAndrew Rist *
11*707d5dc6SAndrew Rist *   http://www.apache.org/licenses/LICENSE-2.0
12*707d5dc6SAndrew Rist *
13*707d5dc6SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*707d5dc6SAndrew Rist * software distributed under the License is distributed on an
15*707d5dc6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*707d5dc6SAndrew Rist * KIND, either express or implied.  See the License for the
17*707d5dc6SAndrew Rist * specific language governing permissions and limitations
18*707d5dc6SAndrew Rist * under the License.
19*707d5dc6SAndrew Rist *
20*707d5dc6SAndrew Rist *************************************************************/
21*707d5dc6SAndrew Rist
22cdf0e10cSrcweir<%
23cdf0e10cSrcweir
24cdf0e10cSrcweirpublic const cnRefreshTime  = 5    ' refresh time in seconds
25cdf0e10cSrcweir
26cdf0e10cSrcweir' filename for file with all pictures and file containing the name of the current picture
27cdf0e10cSrcweirpublic const csFilePicture= "picture.txt"
28cdf0e10cSrcweirpublic const csFileCurrent= "currpic.txt"
29cdf0e10cSrcweir
30cdf0e10cSrcweir' constants for file-access
31cdf0e10cSrcweirconst ForReading    =  1
32cdf0e10cSrcweirconst ForWriting    =  2
33cdf0e10cSrcweir
34cdf0e10cSrcweir' new-line delimiter
35cdf0e10cSrcweirDim FILE_LINE_DELIMITER
36cdf0e10cSrcweirFILE_LINE_DELIMITER = vbCRLF
37cdf0e10cSrcweir
38cdf0e10cSrcweir'/**
39cdf0e10cSrcweir' * Get data from file using a given separator.
40cdf0e10cSrcweir' */
41cdf0e10cSrcweirfunction File_getDataVirtual( sFilename, sServerPath, sSeperator )
42cdf0e10cSrcweir    call Err.Clear()
43cdf0e10cSrcweir
44cdf0e10cSrcweir    Dim aFSObject, sServerFileName
45cdf0e10cSrcweir
46cdf0e10cSrcweir    Set aFSObject = CreateObject("Scripting.FileSystemObject")
47cdf0e10cSrcweir    sServerFileName = aFSObject.BuildPath( Server.MapPath( sServerPath ), sFileName )
48cdf0e10cSrcweir
49cdf0e10cSrcweir    File_getDataVirtual = ""
50cdf0e10cSrcweir    if Err.Number = 0 then
51cdf0e10cSrcweir        File_getDataVirtual = File_read( sServerFileName )
52cdf0e10cSrcweir        If Not IsNull(File_getDataVirtual) Then
53cdf0e10cSrcweir            File_getDataVirtual = Replace( File_getDataVirtual, FILE_LINE_DELIMITER, sSeperator)
54cdf0e10cSrcweir            File_getDataVirtual = Split( File_getDataVirtual, sSeperator)
55cdf0e10cSrcweir        End If
56cdf0e10cSrcweir    end if
57cdf0e10cSrcweirend function
58cdf0e10cSrcweir
59cdf0e10cSrcweir'/**
60cdf0e10cSrcweir' * Get data from a file
61cdf0e10cSrcweir' */
62cdf0e10cSrcweirfunction File_read( sFilename )
63cdf0e10cSrcweir    call Err.Clear()
64cdf0e10cSrcweir
65cdf0e10cSrcweir    Dim aFSObject, aStream
66cdf0e10cSrcweir
67cdf0e10cSrcweir    Set aFSObject = CreateObject( "Scripting.FileSystemObject" )
68cdf0e10cSrcweir    Set aStream = aFSObject.OpenTextFile( sFilename, ForReading )
69cdf0e10cSrcweir
70cdf0e10cSrcweir    while not aStream.AtEndOfStream
71cdf0e10cSrcweir        File_read = File_read + aStream.ReadLine + FILE_LINE_DELIMITER
72cdf0e10cSrcweir    wend
73cdf0e10cSrcweir
74cdf0e10cSrcweir    aStream.Close
75cdf0e10cSrcweirend function
76cdf0e10cSrcweir
77cdf0e10cSrcweir'/**
78cdf0e10cSrcweir' * Get data from a file given by filename and virtual pathname
79cdf0e10cSrcweir' */
80cdf0e10cSrcweirFunction File_readVirtual(sFileName, sServerPath)
81cdf0e10cSrcweir    call Err.Clear()
82cdf0e10cSrcweir
83cdf0e10cSrcweir    Dim aFSObject, sServerFileName
84cdf0e10cSrcweir
85cdf0e10cSrcweir    Set aFSObject = CreateObject("Scripting.FileSystemObject")
86cdf0e10cSrcweir    sServerFileName = aFSObject.BuildPath( Server.MapPath( sServerPath ), sFileName )
87cdf0e10cSrcweir
88cdf0e10cSrcweir    File_readVirtual = ""
89cdf0e10cSrcweir    if Err.Number = 0 then
90cdf0e10cSrcweir        File_readVirtual = File_read( sServerFileName )
91cdf0e10cSrcweir    end if
92cdf0e10cSrcweirEnd Function
93cdf0e10cSrcweir
94cdf0e10cSrcweir'/**
95cdf0e10cSrcweir' * Write data to a file
96cdf0e10cSrcweir' */
97cdf0e10cSrcweirfunction File_write( sFileName, sText )
98cdf0e10cSrcweir    call Err.Clear()
99cdf0e10cSrcweir
100cdf0e10cSrcweir    Dim aFSObject, aFile
101cdf0e10cSrcweir
102cdf0e10cSrcweir    Set aFSObject = CreateObject( "Scripting.FileSystemObject" )
103cdf0e10cSrcweir    if Err.Number = 0 then
104cdf0e10cSrcweir        Set aFile = aFSObject.CreateTextFile( sFileName, TRUE )
105cdf0e10cSrcweir        if Err.Number = 0 then
106cdf0e10cSrcweir            aFile.Write( sText )
107cdf0e10cSrcweir            aFile.Close
108cdf0e10cSrcweir        end if
109cdf0e10cSrcweir    end if
110cdf0e10cSrcweir
111cdf0e10cSrcweir    File_write = ( Err.Number = 0 )
112cdf0e10cSrcweirend function
113cdf0e10cSrcweir
114cdf0e10cSrcweir'/**
115cdf0e10cSrcweir' * Write data to a file given by filename and virtual pathname
116cdf0e10cSrcweir' */
117cdf0e10cSrcweirfunction File_writeVirtual( sFileName, sServerPath, sText )
118cdf0e10cSrcweir    call Err.Clear()
119cdf0e10cSrcweir
120cdf0e10cSrcweir    Dim aFSObject, aServerFile
121cdf0e10cSrcweir
122cdf0e10cSrcweir    Set aFSObject = CreateObject( "Scripting.FileSystemObject" )
123cdf0e10cSrcweir    aServerFile = aFSObject.BuildPath( Server.MapPath( sServerPath ), sFileName )
124cdf0e10cSrcweir
125cdf0e10cSrcweir    If Err.Number = 0 Then
126cdf0e10cSrcweir        File_writeVirtual = File_write( aServerFile, sText )
127cdf0e10cSrcweir    else
128cdf0e10cSrcweir        File_writeVirtual = false
129cdf0e10cSrcweir    End If
130cdf0e10cSrcweirend function
131cdf0e10cSrcweir%>