📄 newtempl.ssc
字号:
if( space == -1 ) {
columnTagList[columnTagCount] = columnTag;
columnTagCount++;
break;
}
columnTagList[columnTagCount] = columnTag.substring( 0, space );
columnTagCount++;
columnTag = columnTag.substring( space + 1, columnTag.length );
}
}
if( columnTagCount > 1 ) {
// a list was specified so check that there are the correct number of column tags
if( columnTagCount != columnCount ) {
document.writeln( IntlStr.wizNewTempl.wrongNumberOfColumnTags );
return false;
}
}
text += '<' + resultTag + '>\r\n';
text += formatTag + '<' + rowTag + '>\r\n';
for( i = 1; i <= columnCount; i++ ) {
if( columnTagCount > 1 ) {
text += '<' + columnTagList[i-1] + '>' + dataTag + '</' + columnTagList[i-1] +'>\r\n';
} else {
text += '<' + columnTagList[0] + '>' + dataTag + '</' + columnTagList[0] +'>\r\n';
}
}
text += '</' + rowTag + '>' + eformatTag + '\r\n';
text += '</' + resultTag + '>\r\n';
// save the tag set if requested
if( !useSavedTagSet ) {
var setName = wiz.xmlcustomsavepage.items[0].value;
var setDesc = wiz.xmlcustomsavepage.items[1].value;
if( setName != null && setName != '' ) {
var setText = '<RESULT>' + resultTag + '</RESULT>\r\n';
setText += '<ROW>' + rowTag + '</ROW>\r\n';
for( i = 0; i < columnTagCount; i++ ) {
setText += '<COLUMN>' + columnTagList[i] + '</COLUMN>\r\n';
}
// create the xml folder if necessary
xmlFolder = site.GetDocument( webRoot.location + "/system/xml" );
if( xmlFolder == null ) {
xmlFolder = site.CreateDocument( webRoot.location + '/system/xml',
'directory', '', '' );
if( xmlFolder == null ) {
document.writeln( formatString( IntlStr.unableToCreate, webRoot.location + '/system/xml' ) );
}
}
if( xmlFolder != null ) {
// create the document to hold the tag set
setName = webRoot.location + '/system/xml/' + setName + '.xml';
var setDoc = site.CreateDocument( setName, 'text', setDesc, setText );
if( setDoc == null ) {
document.writeln( formatString( IntlStr.unableToCreate, setName ) );
}
}
}
}
}
return true;
}
// mainline
var wiz;
var i;
// the following are defined so that the tags will be accepted as strings
var sqlTag = '<!-' + '-SQL\r\n';
var formatTag = '<!-' + '-formatting-' + '->';
var eformatTag = '<!-' + '-/formatting-' + '->';
var dataTag = '<!-' + '-data-' + '->';
var endTag = ' -' + '->\r\n';
// set up the wizard
// enter a name for the document
wiz.namepage = new wizardPage( 'Text',
IntlStr.wizNewTempl.p1.title,
IntlStr.wizNewTempl.p1.explanation,
IntlStr.wizNewTempl.p1.question
);
// enter a descripton for the document
wiz.descpage = new wizardPage( 'TextArea',
IntlStr.wizNewTempl.p2.title,
IntlStr.wizNewTempl.p2.explanation,
IntlStr.wizNewTempl.p2.question
);
// enter the SQL query
wiz.sqlpage = new wizardPage( 'SQL',
IntlStr.wizNewTempl.p3.title,
IntlStr.wizNewTempl.p3.explanation,
IntlStr.wizNewTempl.p3.question
);
// choose whether to create an HTML or XML document
wiz.doctypepage = new wizardPage( 'Choice',
IntlStr.wizNewTempl.doctypepage.title,
IntlStr.wizNewTempl.doctypepage.explanation,
IntlStr.wizNewTempl.doctypepage.question,
IntlStr.wizNewTempl.doctypepage.choices,
0,
docTypeNext
);
// choose which HTML format to use for the data
wiz.formatpage = new wizardPage( 'Choice',
IntlStr.wizNewTempl.p4.title,
IntlStr.wizNewTempl.p4.explanation,
IntlStr.wizNewTempl.p4.question,
IntlStr.wizNewTempl.p4.choices,
0,
-1
);
// choose to enter new XML tags or use saved tags
wiz.xmltypepage = new wizardPage( 'Choice',
IntlStr.wizNewTempl.xmltypepage.title,
IntlStr.wizNewTempl.xmltypepage.explanation,
IntlStr.wizNewTempl.xmltypepage.question,
IntlStr.wizNewTempl.xmltypepage.choices,
0,
xmlTypeNext
);
// enter a new XML tag set
var newtagItems;
newTagItems[0] = new wizardItem( 'Text', IntlStr.wizNewTempl.xmlcustompage.item1Label );
newTagItems[1] = new wizardItem( 'Text', IntlStr.wizNewTempl.xmlcustompage.item2Label );
newTagItems[2] = new wizardItem( 'Text', IntlStr.wizNewTempl.xmlcustompage.item3Label );
wiz.xmlcustompage = new wizardAdvanced(
IntlStr.wizNewTempl.xmlcustompage.title,
IntlStr.wizNewTempl.xmlcustompage.explanation,
newTagItems
);
// save the XML tag set
var saveTagItems;
saveTagItems[0] = new wizardItem( 'Text', IntlStr.wizNewTempl.xmlcustomsavepage.item1Label );
saveTagItems[1] = new wizardItem( 'Text', IntlStr.wizNewTempl.xmlcustomsavepage.item2Label );
wiz.xmlcustomsavepage = new wizardAdvanced(
IntlStr.wizNewTempl.xmlcustomsavepage.title,
IntlStr.wizNewTempl.xmlcustomsavepage.explanation,
saveTagItems,
-1
);
// choose from saved XML tag sets
var savedXMLList = null;
var savedXMLFileList = null;
var j = 0;
var xmlFolder = site.GetDocument( webRoot.location + "/system/xml" );
if( xmlFolder != null ) {
xmlList = xmlFolder.GetDirectory();
for( i in xmlList ) {
// build one list for display (includes description) and one list of path names
savedXMLList[j] = xmlList[i].name;
savedXMLFileList[j] = xmlList[i].location;
if( xmlList[i].description != null
&& xmlList[i].description != '' ) {
savedXMLList[j] += ' (' + xmlList[i].description + ')';
}
j++;
}
xmlFolder = null;
}
wiz.xmlpredefinedpage = new wizardPage( 'Choice',
IntlStr.wizNewTempl.xmlpredefinedpage.title,
IntlStr.wizNewTempl.xmlpredefinedpage.explanation,
IntlStr.wizNewTempl.xmlpredefinedpage.question,
savedXMLList,
0
);
// call the wizard
if( site.CreateWizard( wiz ) ) {
// create the new template
var templname = wiz.namepage.value;
// Check if the name already contains an extension
// If not, add the extension .stm
if( templname.indexOf( '.' ) == -1 ) {
templname += '.stm';
}
var fullname = document.location + '/' + templname;
var templdesc = wiz.descpage.value;
var docType = wiz.doctypepage.value;
var sqlQuery = wiz.sqlpage.value;
var text;
var queryConnecton;
var sqlQueryResult;
var columnCount;
var result;
if( docType == IntlStr.wizNewTempl.doctypepage.choices[0] ) {
// HTML document
result = generateHTMLDocument();
} else {
// XML document
result = generateXMLDocument();
}
if( result ) {
sqlQueryResult = null;
var newdoc = site.CreateDocument( fullname, 'text', templdesc, text, wiz.sqlpage.connectionId );
if( newdoc == null ) {
document.writeln( formatString( IntlStr.unableToCreate, fullname ) );
}
}
}
// }}
-->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -