<!--
+---------------------------------------------------------------------------+
VB-WORLD Forums - Tagging Scripts 1.0
Programmed By G.Kumaraguru {Active}
+---------------------------------------------------------------------------+
-->
<SCRIPT LANGUAGE = "VBScript">
Dim oWindow,oDocument,oSelect,oSelectRange,Clr
Set oWindow = window.external.menuArguments
Set oSource = oWindow.event.srcElement
Set oDocument = oWindow.document
Set oSelect = oDocument.selection
Set oSelectRange = oSelect.createRange()
If oSource.tagName = "TEXTAREA" Then
StrtClr = GetColor("Choose The Starting color")
If StrtClr = -1 Then
oWindow.alert("You Need to Have CommonDialog Activex Control Installed!")
Else
EndClr = GetColor("Choose the Ending Color")
oSelectRange.text = CodeGrad(oSelectRange.text,StrtClr,EndClr)
End If
End If
Function CodeGrad(Src,StrtClr,EndClr)
If Src = "" Then Exit Function
Dim ResString,CChar,HexClr,CC,j,Pcent
For j = 1 To Len(Src)
CChar = Mid(Src, j, 1)
Pcent = (j / Len(Src)) * 100
If Asc(CChar) <> 13 And Asc(CChar) <> 10 Then
CC = GradientColor(StrtClr, EndClr, Pcent)
ResString = ResString & "[Color=" & Chr(34) & HexColor(CC) & Chr(34) & "]" & CChar & "[/Color]"
Else
ResString = ResString & CChar
End If
Next
CodeGrad = ResString
End Function
Function HexColor(Color)
Dim Red,Green,Blue
Red = Color And &HFF&
Green = (Color And &HFF00&) \ 256
Blue = (Color And &HFF0000) \ 65536
HexColor = "#" & Hexify(Red) & Hexify(Green) & Hexify(Blue)
End Function
Function Hexify(Color)
Dim HexNum
HexNum = Hex(Color)
If Len(HexNum) = 1 Then
HexNum = "0" & HexNum
End If
Hexify = HexNum
End Function
Function GetColor(msg)
Dim Dlg
On Error Resume Next
Set Dlg = CreateObject("MSComDlg.CommonDialog")
If Err.Number = 0 Then
Err.Clear
oWindow.alert(msg)
Dlg.CancelError = True
Dlg.ShowColor()
If Err.Number = 0 Then
Err.Clear
GetColor = Clng(Dlg.Color)
Set Dlg = Nothing
End If
Else
GetColor = -1
End If
End Function
Function GradientColor(ByVal A,ByVal B,ByVal p)
If p > 100 Or p < 0 Then Exit Function
If A > 16777215 Or A < 0 Then Exit Function
If B > 16777215 Or B < 0 Then Exit Function
Dim rStart,gStart,bStart,rEnd,gEnd,bEnd
bStart = Int(A / 65536)
gStart = Int((A - bStart * 65536) / 256)
rStart = Int(A - gStart * 256 - bStart * 65536)
bEnd = Int(B / 65536)
gEnd = Int((B - bEnd * 65536) / 256)
rEnd = Int(B - gEnd * 256 - bEnd * 65536)
GradientColor = RGB(rStart - ((rStart - rEnd) * (p / 100)), gStart - ((gStart - gEnd) * (p / 100)), bStart - ((bStart - bEnd) * (p / 100)))
End Function
</SCRIPT>