Senin, 15 Desember 2025

Scriplet 2

 


<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>

<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="Microsoft Border" content="none">
<meta name="Microsoft Theme" content="none">
<meta name="GENERATOR" content="Microsoft FrontPage 2.0">
<title></title>
</head>

<body background="grad.gif">

<p align="center"><font color="#000000" size="5" face="Verdana"><strong>Programming
Dynamic HTML with </strong><em><strong>Scriptlets</strong></em></font><font
color="#000000" size="4"> </font></p>

<hr>

<p><script language="VBScript"><!--
Sub window_onload()

ComboText1.Text = "Programming scriptlets"
ComboText1.Memo = "<STRONG>Scriptlets</STRONG> are a new and cool way to write reusable components with script languages."
ComboText1.MemoFont = "Times New Roman"
ComboText1.MemoColor = "Blue"
ComboText1.BkgndColor = "LightBlue"

ComboText2.Text = "ComboText Script Controls"
ComboText2.Memo = "ComboTexts are script controls written by <strong>Dino Esposito</strong>. They have a <em>Text</em> and a <em>Memo</em> property."
ComboText2.TextColor = "Red"
ComboText2.MemoColor = "Red"
ComboText2.MemoFont = "Times New Roman"
ComboText2.BkgndColor = "White"

Spin1.Value = ComboText1.ExpandBy
Spin2.Value = ComboText2.ExpandBy
end sub
--></script> <script
language="jscript" for="ComboText1" event="onscriptletevent(n,o)">
   
if( ComboText1.Expanded ) {
    Expand1.Caption = "Collapse1";
}
else {
    Expand1.Caption = "Expand1";
}
</script>
<script language="jscript" for="ComboText2"
event="onscriptletevent(n,o)">
   
if( ComboText2.Expanded ) {
    Expand2.Caption = "Collapse2";
}
else {
    Expand2.Caption = "Expand2";
}

  ComboText1.CancelEvent = 1;
</script> <font size="4"><em><strong>The
following are special Scriptlets called ComboText. <br>
Click the button to have them to drop down. <script
language="VBScript">
<!--
Sub Button1_Click()
  ComboText1.Text = Text1.Value
end sub
-->
    </script> </strong></em></font></p>

<p><object id="ComboText1" data="CboText.htm" align="absbottom"
border="0" width="400" height="25" type="text/x-scriptlet"></object>
<script language="VBScript">
<!--
Sub Check1_Change()
if Check1.Value = 0 then
ComboText1.ButtonPosition = "Left"
else
ComboText1.ButtonPosition = "Right"
end if
end sub
-->
    </script> <object id="Check1"
name="Check1"
classid="CLSID:8BD21D40-EC42-11CE-9E0D-00AA006002F3"
align="baseline" border="0" width="291" height="24"><param
name="VariousPropertyBits" value="746588179"><param
name="BackColor" value="2147483663"><param name="ForeColor"
value="2147483666"><param name="DisplayStyle" value="4"><param
name="Size" value="7691;635"><param name="Value" value="0"><param
name="Caption" value="Button on right "><param name="FontName"
value="Times New Roman"><param name="FontEffects"
value="1073741825"><param name="FontHeight" value="240"><param
name="FontCharSet" value="0"><param name="FontPitchAndFamily"
value="2"><param name="FontWeight" value="700"></object> <script
language="VBScript">
<!--
Sub Check2_Change()
if Check2.Value = 0 then
ComboText2.ButtonPosition = "Left"
else
ComboText2.ButtonPosition = "Right"
end if
end sub
-->
    </script> <object id="ComboText2"
data="CboText.htm" align="absbottom" border="0" width="400"
height="25" type="text/x-scriptlet"></object> <object id="Check2"
name="Check2"
classid="CLSID:8BD21D40-EC42-11CE-9E0D-00AA006002F3"
align="baseline" border="0" width="287" height="24"><param
name="VariousPropertyBits" value="746588179"><param
name="BackColor" value="2147483663"><param name="ForeColor"
value="2147483666"><param name="DisplayStyle" value="4"><param
name="Size" value="7585;635"><param name="Value" value="0"><param
name="Caption" value="Button on right  "><param name="FontName"
value="Times New Roman"><param name="FontEffects"
value="1073741825"><param name="FontHeight" value="240"><param
name="FontCharSet" value="0"><param name="FontPitchAndFamily"
value="2"><param name="FontWeight" value="700"></object> <br>
<font size="4"><em><strong>Here the </strong></em></font><font
color="#000000" size="4"><em><strong>scriptlet</strong></em></font><font
size="4"><em><strong> space is finished. </strong></em></font></p>

<hr>

<p><object id="Spin1" name="Spin1"
classid="clsid:8BD21D10-EC42-11CE-9E0D-00AA006002F3"
align="baseline" border="0" width="49" height="24"><param
name="VariousPropertyBits" value="746604571"><param
name="MaxLength" value="3"><param name="Size" value="1305;635"><param
name="FontCharSet" value="0"><param name="FontPitchAndFamily"
value="2"><param name="ParagraphAlign" value="2"><param
name="FontWeight" value="0"></object> <strong>Pixels by which the
ComboText #1 will expand. <script language="VBScript"><!--
Sub Expand1_Click()
if ComboText1.Expanded then
  ComboText1.Collapse
else
  ComboText1.ExpandBy = Spin1.Text
  ComboText1.Expand
end if
end sub
--></script> <script
language="VBScript"><!--
Sub Expand2_Click()
if ComboText2.Expanded then
  ComboText2.Collapse
else
  ComboText2.ExpandBy = Spin2.Text
  ComboText2.Expand
end if
end sub
--></script> <object id="Expand1" name="Expand1"
classid="CLSID:D7053240-CE69-11CD-A777-00DD01143C57"
align="middle" border="0" width="96" height="26"><param
name="Caption" value="Expand1"><param name="Size"
value="2540;847"><param name="FontCharSet" value="0"><param
name="FontPitchAndFamily" value="2"><param name="ParagraphAlign"
value="3"><param name="FontWeight" value="0"></object> <br>
<object id="Spin2" name="Spin2"
classid="clsid:8BD21D10-EC42-11CE-9E0D-00AA006002F3"
align="baseline" border="0" width="49" height="24"><param
name="VariousPropertyBits" value="746604571"><param
name="MaxLength" value="3"><param name="Size" value="1305;635"><param
name="FontCharSet" value="0"><param name="FontPitchAndFamily"
value="2"><param name="ParagraphAlign" value="2"><param
name="FontWeight" value="0"></object>Pixels by which the
ComboText #2 will expand. <object id="Expand2" name="Expand2"
classid="CLSID:D7053240-CE69-11CD-A777-00DD01143C57"
align="middle" border="0" width="96" height="27"><param
name="Caption" value="Expand2"><param name="Size"
value="2540;706"><param name="FontCharSet" value="0"><param
name="FontPitchAndFamily" value="2"><param name="ParagraphAlign"
value="3"><param name="FontWeight" value="0"></object> </strong></p>

<hr>

<p><font size="4"><em><strong>Now, try to modify the content of
the ComboTexts. Type in some text for the Text or Memo
properties.</strong></em></font></p>

<p><object id="Text1" name="Text1"
classid="CLSID:8BD21D10-EC42-11CE-9E0D-00AA006002F3"
align="baseline" border="0" width="635" height="24"><param
name="VariousPropertyBits" value="746604571"><param name="Size"
value="2540;635"><param name="FontCharSet" value="0"><param
name="FontPitchAndFamily" value="2"><param name="FontWeight"
value="0"></object> <br>
<object id="Button1" name="Button1"
classid="CLSID:D7053240-CE69-11CD-A777-00DD01143C57"
align="baseline" border="0" width="96" height="25"><param
name="Caption" value="Text #1"><param name="Size"
value="2540;670"><param name="FontCharSet" value="0"><param
name="FontPitchAndFamily" value="2"><param name="ParagraphAlign"
value="3"><param name="FontWeight" value="0"></object> <script
language="VBScript">
<!--
Sub Button2_Click()
ComboText1.Memo = Text1.Value
end sub
-->
    </script> <object id="Button2" name="Button2"
classid="CLSID:D7053240-CE69-11CD-A777-00DD01143C57"
align="baseline" border="0" width="96" height="25"><param
name="Caption" value="Memo #1"><param name="Size"
value="2540;670"><param name="FontCharSet" value="0"><param
name="FontPitchAndFamily" value="2"><param name="ParagraphAlign"
value="3"><param name="FontWeight" value="0"></object> <script
language="VBScript">
<!--
Sub Button3_Click()
ComboText2.Text = Text1.Value
end sub
-->
    </script> <object id="Button3" name="Button3"
classid="CLSID:D7053240-CE69-11CD-A777-00DD01143C57"
align="baseline" border="0" width="96" height="25"><param
name="Caption" value="Text #2"><param name="Size"
value="2540;670"><param name="FontCharSet" value="0"><param
name="FontPitchAndFamily" value="2"><param name="ParagraphAlign"
value="3"><param name="FontWeight" value="0"></object> <script
language="VBScript">
<!--
Sub Button4_Click()
ComboText2.Memo = Text1.Value
end sub
-->
    </script> <object id="Button4" name="Button4"
classid="CLSID:D7053240-CE69-11CD-A777-00DD01143C57"
align="baseline" border="0" width="103" height="25"><param
name="Caption" value="Memo #2"><param name="Size"
value="2540;670"><param name="FontCharSet" value="0"><param
name="FontPitchAndFamily" value="2"><param name="ParagraphAlign"
value="3"><param name="FontWeight" value="0"></object> </p>

<p>&nbsp;</p>
</body>
</html>

<!DOCTYPE HTML PUBLIC "-//IETF//DAREA HTML//EN">

<html id=MyPage>


<head>

<meta http-equiv="Content-Type"

content="text/html; charset=iso-8859-1">

<meta name="Microsoft Theme" content="none">

<meta name="Microsoft Border" content="none">

<meta name="GENERATOR" content="Microsoft FrontPage 2.0">

<title>ComboText Scriptlet</title>

</head>


<body>


<script language="JavaScript"> 

</script>


<script language="VBscript" for="window" event="onload">

    InitComboText 

</script>


<script language="VBscript" for="document" event="onclick">

    if window.event.srcElement.id = "push" then

   DoInsertText

else

if window.event.srcElement.id = "pop" then

   DoRemoveText

end if

end if

</script>



<script language="VBscript">


' utility for quoting

' -------------------------------------------------------

Function Quote( s )

   s = Chr(34) + s + Chr(34)

   Quote = s

End Function



' Prepare the HTML string for Title

' -------------------------------------------------------

Function FormatText

   sPrefix = "<DIV id=text>" 

   sSuffix = "  " + "<br></DIV>"

   if mButtonPosition = "Right" then

       sBody = mText + "  " + mPushImage

   else

      sBody =  mPushImage + "  " + mText

   end if


   FormatText = sPrefix + sBody + sSuffix

End Function



' Prepare the HTML string for Memo

' -------------------------------------------------------

Function FormatMemo

   sPrefix = "<DIV id=memo>"

   sSuffix = "  " + "</DIV>"

   

   if mButtonPosition = "Right" then

       sBody = mMemo + "  " + sImage

   else

      sBody =  sPopImage + "  " + mMemo

   end if


   FormatMemo = sPrefix + sBody + sSuffix

End Function



' Initialize the control

' -------------------------------------------------------

Sub InitComboText 


  ' save some standard settings

  document.body.style.setAttribute "marginTop", "0" 

  document.body.style.setAttribute "marginBottom", "0" 

  document.body.style.setAttribute "marginLeft", "0" 

  document.body.style.setAttribute "marginRight", "0" 


  ' put text

  DoPutText mText

  document.fgColor = mTextColor

  document.bgColor = mBkgndColor

  


  ' make selectable the scriplet content

  if InScriptlet then

    window.external.selectableContent = mSelectable

  end if

End Sub




' Add new text

' -------------------------------------------------------

Sub DoInsertText

document.body.insertAdjacentHTML "BeforeEnd", FormatMemo

DoModify "memo", "fontFamily", mMemoFont

    DoModify "memo", "fontSize", mMemoFontSize

    DoModify "memo", "fontWeight", mMemoFontWeight

    DoModify "memo", "color", mMemoColor

DoModify "memo", "marginLeft", 5


    ' change image

Set coll = document.images

Set elem = coll.item(0)

elem.outerHTML = mPopImage



    MyPage.style.pixelHeight = MyPage.style.pixelHeight + mExpandBy

    if InScriptlet then

      window.external.scrollbar = True  

    end if

    mExpanded = True


    if InScriptlet then

       window.external.RaiseEvent "OnExpand", window.document 

    end if

 

End Sub



' Remove new text

' -------------------------------------------------------

Sub DoRemoveText

    Set coll = document.images

    Set elem = coll.item(0)

    elem.outerHTML = mPushImage


    ' remove DIV tag

    Set e = GetElemById( "DIV", "memo" ) 

    e.outerHTML = ""


    MyPage.style.pixelHeight = MyPage.style.pixelHeight - mExpandBy

    if InScriptlet then 

      window.external.scrollbar = False

    end if

    mExpanded = False


    if InScriptlet  then

      window.external.RaiseEvent "OnCollapse", window.document

    end if

End Sub



' Search for the given tag and id

' ----------------------------------

Function GetElemById( tagName, idName )

  Set GetElemById = Nothing    


  Set coll = document.all.tags( tagName )

  for i=0 to coll.length-1

     if coll.item(i).id = idName then

    Set GetElemById = coll.item(i)

Exit Function

end if    

  next

  Set coll = Nothing

End Function



' Set text

' ----------------------------------

Sub DoPutText( sText ) 

  if mExpanded then

     DoRemoveText

  end if


  mText = sText

  

  Set e = GetElemById( "DIV", "text" ) 

  if Not e is Nothing then

e.outerHTML = FormatText

  end if

  DoModify "text", "fontFamily", mTextFont

  DoModify "text", "fontSize", mTextFontSize

  DoModify "text", "fontWeight", mTextFontWeight

  DoModify "text", "marginLeft", 5

  

End Sub



' Set memo text

' ----------------------------------

Sub DoPutMemo( sMemo ) 

  if mExpanded then

     DoRemoveText

  end if

  mMemo = sMemo

  

  Set e = GetElemById( "DIV", "memo" ) 

  if Not e is Nothing then

e.outerHTML = FormatMemo

  end if

  Set e = Nothing

End Sub



' Change the element styles

' ----------------------------------

Sub DoModify( idName, attrib, value ) 

   Set e = GetElemById( "DIV", idName ) 

   if Not e is Nothing then

e.style.setAttribute attrib, value

   else

Exit Sub

   end if

   Set e = Nothing


   ' this way it works fine...

   if attrib="color" And idName="memo" then

      Set coll = document.all.tags("DIV")

      coll.item(1).style.color = mMemoColor

   end if


End Sub

</script>






<script language="JavaScript">


// declare the object interface

public_description = new CreateComboText;

var InScriptlet = (typeof(window.external.version) == "string")


// Vars that match properties

/*---------------------------------*/

mExpandBy = 50;

mSelectable = 0;

mMemo = "";

mText = "";

mButtonPosition = "Left";

mTextFont = "Tahoma";

mTextFontSize = "12pt";

mTextFontWeight = "700";

mMemoFont = "Tahoma";

mMemoFontSize = "10pt";

mMemoFontWeight = "400";

mMemoColor = "Black";

mTextColor = "Blue";

mBkgndColor = "gainsboro"

mCancelEvent = 0

mExpanded = 0;



// Internals

/*---------------------------------*/

mPushImage = "<img id=" + Quote("push") + " src=push.gif align=middle alt="+Quote("Expand text")+">";

mPopImage = "<img id=" + Quote("pop") + " src=pop.gif align=middle alt="+Quote("Collapse")+">";




/*---------------------------------*/

function CreateComboText() {


// This function define the scriptlet interface in terms of 

// properties, methods and events.


    // Properties

    this.put_CancelEvent = put_CancelEvent;

    this.get_Expanded = get_Expanded;


    this.put_Text = put_Text;

    this.get_Text = get_Text;


    this.put_Memo = put_Memo;

    this.get_Memo = get_Memo;


    this.put_ExpandBy = put_ExpandBy;

    this.get_ExpandBy = get_ExpandBy;


    this.put_ButtonPosition = put_ButtonPosition;

    this.get_ButtonPosition = get_ButtonPosition;


    this.put_Selectable = put_Selectable;

    this.get_Selectable = get_Selectable;


    this.put_TextFont = put_TextFont;

    this.put_TextFontSize = put_TextFontSize;

    this.put_TextFontWeight = put_TextFontWeight;


    this.put_TextColor = put_TextColor;

    this.get_TextColor = get_TextColor;

    this.put_BkgndColor = put_BkgndColor;

    this.get_BkgndColor = get_BkgndColor;


    this.put_MemoFont = put_MemoFont;

    this.put_MemoFontSize = put_MemoFontSize;

    this.put_MemoFontWeight = put_MemoFontWeight;

    

    this.put_MemoColor = put_MemoColor;

    this.get_MemoColor = get_MemoColor;

    

    // Methods

    this.Expand = InsertMemoText;

    this.Collapse = RemoveMemoText;


    

    // Events

    this.event_OnExpand = "";

    this.event_OnCollapse = "";

}



/*---------------------------------*/

function InsertMemoText() {


// This function expands the document by inserting the memo text


DoInsertText();

return 1;

}


/*---------------------------------*/

function RemoveMemoText() {

// This function collapses the document by removing the memo text


DoRemoveText();

    return 1;

}



/*---------------------------------*/

function put_CancelEvent( bYes ) {

   

   mCancelEvent = bYes

   return 1;

}



/*---------------------------------*/

function get_Expanded() {

   

   return mExpanded;

}


/*---------------------------------*/

function put_Text( sText ) {

   

   DoPutText( sText );

   return 1;

}


/*---------------------------------*/

function get_Text() {

   

   return mText;

}


/*---------------------------------*/

function put_Memo( sMemo ) {

   

   DoPutMemo( sMemo );

   return 1;

}


/*---------------------------------*/

function get_Memo() {

   

   return mMemo;

}


/*---------------------------------*/

function put_Selectable( b ) {

   

   mSelectable = b;

   if( InScriptlet ) {

     window.external.selectableContent = mSelectable;

   }

   return 1;

}


/*---------------------------------*/

function get_Selectable() {

   

   return mSelectable;

}


/*---------------------------------*/

function put_ButtonPosition( pos ) {

   

   mButtonPosition = pos;

   DoPutText( mText );

   return 1;

}


/*---------------------------------*/

function get_ButtonPosition() {

   

   return mButtonPosition;

}


/*---------------------------------*/

function put_ExpandBy( pixel ) {

   

   if( mExpanded ) {

     DoRemoveText();

   }


   mExpandBy = pixel;

   return 1;

}


/*---------------------------------*/

function get_ExpandBy() {

   

   return mExpandBy;

}


/*---------------------------------*/

function put_TextFont( font ) {

   

   mTextFont = font

   DoModify( "text", "fontFamily", mTextFont );

   return 1;

}


/*---------------------------------*/

function put_TextFontSize( size ) {


   mTextFontSize = size;

   DoModify( "text", "fontSize", mTextFontSize );

   return 1;

}


/*---------------------------------*/

function put_TextFontWeight( bold ) {

   

   mTextFontWeight = bold;

   DoModify( "text", "fontWeight", mTextFontWeight );

   return 1;

}


/*---------------------------------*/

function put_TextColor( color ) {

   

   mTextColor = color;

   document.fgColor = mTextColor;

   return 1;

}


/*---------------------------------*/

function get_TextColor( ) {

   

   return mTextColor;

}


/*---------------------------------*/

function put_MemoFont( font ) {

   

   mMemoFont = font

   DoModify( "memo", "fontFamily", mMemoFont );

   return 1;

}


/*---------------------------------*/

function put_MemoFontSize( size ) {


   mMemoFontSize = size

   DoModify( "memo", "fontSize", mMemoFontSize );

   return 1;

}


/*---------------------------------*/

function put_MemoFontWeight( bold ) {

   

   mMemoFontWeight = bold;

   DoModify( "memo", "fontWeight", mMemoFontWeight );

   return 1;

}


/*---------------------------------*/

function put_MemoColor( color ) {

   

   mMemoColor = color;

   DoModify( "memo", "color", mMemoColor );

   return 1;

}


/*---------------------------------*/

function get_MemoColor() {

   

   return mMemoColor;

}



/*---------------------------------*/

function put_BkgndColor( color ) {

   

   mBkgndColor = color;

   document.bgColor = mBkgndColor

   return 1;

}


/*---------------------------------*/

function get_BkgndColor() {

   

   return mBkgndColor;

}




</script>

<DIV id=text><br></DIV>

</body>

</html>


Tidak ada komentar: