A simple attribute translator example
445
// the conditional statement
var trueStart;
// The beginning of the true case
var falseStart;
// The beginning of the false case
var trueValue;
// The HTML that would render in the true case
var attName;
// The name of the attribute that is being'
// set conditionally.
var equalSign;
// The position of the equal sign just to the
// left of the <#, if there is one
var transAtt;
// The entire translated attribute
var transValue;
// The value that must be URL-encoded
var back3FromStart;
// Three characters back from the start position
// (used to find equal sign to the left of <#
var tokens;
// An array of all the attributes set in the true case
var end;
// The end of the current conditional statement.
// As long as there's still a <# conditional that hasn't been
// translated
while (start != -1){
back3FromStart = start-3;
end = outStr.indexOf(' #>',start);
equalSign = outStr.indexOf('="<# if',back3FromStart);
attAndValue = (equalSign != -1)?false:true;
trueStart = outStr.indexOf('then', start);
falseStart = outStr.indexOf(' else', start);
trueValue = outStr.substring(tr5, falseStart);
tokens = dreamweaver.getTokens(trueValue,' ');
// If attAndValue is false, find out what attribute you're
// translating by backing up from the equal sign to the
// first space. The substring between the space and the
// equal sign is the attribute.
if (!attAndValue){
for (var i=equalSign; i > 0; i--){
if (outStr.charAt(i) == " "){
attName = outStr.substring(i+1,equalSign);
break;
}
}
Summary of Contents for DREAMWEAVER 8-EXTENDING DREAMWEAVER
Page 1: ...Extending Dreamweaver...
Page 8: ...8 Contents...
Page 14: ...14 Introduction...
Page 16: ......
Page 54: ...54 Customizing Dreamweaver...
Page 96: ...96 Customizing Code View...
Page 98: ......
Page 110: ...110 Extending Dreamweaver...
Page 138: ......
Page 166: ...166 Insert Bar Objects...
Page 180: ...180 Commands...
Page 248: ...248 Toolbars...
Page 260: ...260 Reports...
Page 278: ...278 Tag Libraries and Editors...
Page 288: ...288 Property Inspectors...
Page 378: ...378 Server Behaviors...
Page 398: ...398 Data Sources...
Page 432: ...432 Server Models...
Page 456: ...456 Data Translators...
Page 482: ......
Page 492: ...492 The Shared Folder...