![]() |
| Zurück Nach oben Weiter |
HTML-Seite: Beispiel 2 (Tabelle mit bubble-sort sortieren) |
Dies ist eine HTML-Beispieldatei mit einem eingebetteten JScript. Für das Beispiel muss das Authentic Browser Plug-In (CAB-Datei und Lizenzdatei) auf Ihrem Computer installiert werden. Nähere Informationen finden Sie auf der Altova-Homepage.
Der Code gibt an:
| • | wie das Browser Plug-In aufgerufen werden soll. Passen Sie den Code bitte an und geben Sie den Pfad zu Ihrer CAB-Datei, Lizenzdatei und dem Class Identifier Ihrer Browser Plug-In-Version an (trusted oder untrusted). |
| • | wie eine Datei in das Browser Plug-In geladen werden soll. Passen Sie bitte den Code an und geben Sie den Pfad zu Ihrem Beispieldokument an. |
| • | wie Schaltflächen für einfache Cursor-Positionierungen implementiert werden. |
| • | wie komplexere Befehle wie z.B. die Sortierung von Tabellen implementiert werden. |
| • | wie das 'SelectionChanged'-Ereignis verwendet wird. |
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>test page For Authentic Browser Plug-in</title>
<SCRIPT LANGUAGE="javascript" For=objPlugIn EVENT="ControlInitialized">
var strSampleRoot = "http://myRoot/myPath/myDocBaseName";
objPlugIn.SchemaLoadObject.URL = strSampleRoot + ".xsd";
objPlugIn.XMLDataLoadObject.URL = strSampleRoot + ".xml";
objPlugIn.DesignDataLoadObject.URL = strSampleRoot + ".sps";
objPlugIn.StartEditing();
</SCRIPT>
<SCRIPT ID="clientEventHandlers" LANGUAGE="javascript">
var objCurrentRange = Null;
Function BtnDocumentBegin() { objPlugIn.AuthenticView.DocumentBegin.Select(); }
Function BtnDocumentEnd() { objPlugIn.AuthenticView.DocumentEnd.Select(); }
Function BtnWholeDocument() { objPlugIn.AuthenticView.WholeDocument.Select(); }
Function BtnSelectNextWord() { objPlugIn.AuthenticView.Selection.SelectNext(1).Select(); }
Function BtnSortDepartmentOnClick()
{
var objCursor = Null;
var objTableStart = Null;
var objBubble = Null;
var strField1 = "";
var strField1 = "";
var nColIndex = 0;
var nRows = 0;
objCursor = objPlugIn.AuthenticView.Selection;
If (objCursor.IsInDynamicTable())
{
// calculate current column index
nColIndex = 0;
While (True)
{
try { objCursor.GotoPrevious(11); }
catch (err) { break; }
nColIndex++;
}
// GoTo begin of table
objTableStart = objCursor.ExpandTo(9).CollapsToBegin().Clone();
// count number of table rows
nRows = 1;
While (True)
{
try { objTableStart.GotoNext(10); }
catch (err) { break; }
nRows++;
}
// bubble sort through table
For (var i = 0; i < nRows - 1; i++)
{
// Select correct column In first table row
objBubble = objCursor.ExpandTo(9).CollapsToBegin().Clone();
objBubble.Goto (11, nColIndex, 2).ExpandTo(6);
// bubble
For (var j = 0; j < nRows - i - 1; j++)
{
strField1 = objBubble.Text;
strField2 = objBubble.GotoNext(10).Goto (11, nColIndex, 2).ExpandTo(6).Text;
If (strField1 > strField2)
{
objBubble.MoveRowUp();
objBubble.GotoNext(10).Goto (11, nColIndex, 2).ExpandTo(6);
}
}
}
}
}
</SCRIPT>
</head>
<body>
<Object id="objPlugIn"
codeBase="http://myCabfileLocation/AuthenticBrowserEdition_DE.cab#Version=7,0,1,0"
classid="clsid:91DDF44A-DFD1-4F47-8EE3-4CBE874584F7"
width="100%" height="80%" VIEWASTEXT>
<PARAM NAME="EntryHelpersEnabled" VALUE="TRUE">
<PARAM NAME="SaveButtonAutoEnable" VALUE="TRUE">
</Object>
<TABLE>
<TR>
<TD><Input Type="button" value="Goto Begin" id="B1" onclick="BtnDocumentBegin()"></TD>
<TD><Input Type="button" value="Goto End" name="B2" onclick="BtnDocumentEnd()"></TD>
<TD><Input Type="button" value="Whole Document" name="B3" onclick="BtnWholeDocument()"></TD>
<TD><Input Type="button" value="Select Next Word" name="B4" onclick="BtnSelectNextWord()"></TD>
</TR>
<TR>
<TD><Input Type="button" value="Sort Table by this Column" id="B6" onclick="BtnSortDepartmentOnClick()"</TD>
</TR>
</TABLE>
<TABLE id=SelTable border=1>
<TR><TD id=SelTable_FirstTextPosition></TD><TD id=SelTable_LastTextPosition></TD></TR>
<TR><TD id=SelTable_FirstXMLData></TD><TD id=SelTable_FirstXMLDataOffset></TD></TR>
<TR><TD id=SelTable_LastXMLData></TD><TD id=SelTable_LastXMLDataOffset></TD></TR>
<TR><TD id=SelTable_Text></TD></TR>
</TABLE>
</body>
<SCRIPT LANGUAGE=javascript For=objPlugIn EVENT=selectionchanged>
var CurrentSelection = Null;
CurrentSelection = objPlugIn.AuthenticView.Selection;
SelTable_FirstTextPosition.innerHTML = CurrentSelection.FirstTextPosition;
SelTable_LastTextPosition.innerHTML = CurrentSelection.LastTextPosition;
SelTable_FirstXMLData.innerHTML = CurrentSelection.FirstXMLData.Parent.Name;
SelTable_FirstXMLDataOffset.innerHTML = CurrentSelection.FirstXMLDataOffset;
SelTable_LastXMLData.innerHTML = CurrentSelection.LastXMLData.Parent.Name;
SelTable_LastXMLDataOffset.innerHTML = CurrentSelection.LastXMLDataOffset;
</SCRIPT>
</html>
|