vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   jave script in php !!! (https://vborg.vbsupport.ru/showthread.php?t=32716)

ErrOr 11-26-2001 06:37 PM

hello


i have this java script:

[code]

<SCRIPT LANGUAGE = "VBScript">

Const KeyColor = "#0021E6"
Const REMColor = "#008000"
Dim oWindow,oDocument,oSelect,oSelectRange,key,grep
Set oWindow = window.external.menuArguments
Set oSource = oWindow.event.srcElement
Set oDocument = oWindow.document
Set oSelect = oDocument.selection
Set oSelectRange = oSelect.createRange()

'KeyWords, Add more keywords if You Want !
KeyWords="Access,Alias,And,Append,As,Binary,Boolea n,ByRef,Byte,ByVal,Circle,Close,Const,Currency,Dat e,Decimal,Declare,Dim,Do,Double,Each,Else,ElseIf,E mpty,End,Enum,Erase,Error,Event,Exit,False,For,Fun ction,Get,Global,GoTo,If,In,Input,Integer,Let,Lib, Line,Lock,Long,Loop,Mod,New,Next,Not,Null,Object,O n,Open,Or,Output,Preserve,Private,Property,Public, ReDim,Resume,Set,Shared,Single,String,Sub,Then,To, True,Type,Until,Variant,Wend,While,WithEvents,Writ e,Xor"

key = Split(KeyWords, ",")

Set grep = New regexp
If oSource.tagName = "TEXTAREA" Then
oSelectRange.text = "
Code:

" & GetColoredCode(oSelectRange.text) & "[ /code]"
End If


Function GetColoredCode(Stxt)
Dim i,j,Data,RepData,lineArray,QtArray,Matches

Data = " " & Stxt & " "
grep.Global = True
grep.IgnoreCase = True
For i = 0 To UBound(key)
 grep.Pattern = "[\s(, ]" & key(i) & "[\s), ]"
Set Matches = grep.Execute(Data)
 For Each Mch In Matches
  RepData = Left(Mch.Value, 1) & "[CLR]" & key(i) & "[/CLR]" & Right(Mch.Value, 1)
  Data = Replace(Data, Mch.Value, RepData, 1, 1, vbTextCompare)
 Next
Next

Data = Mid(Data, 2, Len(Data) - 2)

lineArray = Split(Data, vbCrLf)

    For i = 0 To UBound(lineArray)
        QtArray = Split(lineArray(i), Chr(34))
        For j = 0 To UBound(QtArray)
            Apop = InStr(1, QtArray(j), "'")
            If ((j Mod 2 = 0) Or (j = UBound(QtArray))) And Apop > 0 Then
                QtArray = CommentFrom(QtArray, j, Apop)
                Exit For
            ElseIf (j Mod 2 <> 0) Then
                QtArray(j) = StripTags(QtArray(j))
            End If
        Next
        lineArray(i) = Join(QtArray, Chr(34))
    Next

Data = Join(lineArray, vbCrLf)
Data = Replace(Data, "[CLR]", "[color=" & Chr(34) & KeyColor & Chr(34) & "]")
Data = Replace(Data, "[/CLR]", "[/color]")
Data = Replace(Data, "[REM]", "[color=" & Chr(34) & REMColor & Chr(34) & "]")
Data = Replace(Data, "[/REM]", "[/color]")

GetColoredCode = Data
End Function

Function CommentFrom(srcArray,ByVal idx,ByVal pos)
Dim i,hd
If pos = 1 Then
 hd = ""
Else
 hd = Left(srcArray(idx), pos - 1)
End If
srcArray(idx) = hd & "[REM]" & StripTags(Mid(srcArray(idx), pos))
If idx < UBound(srcArray) Then
  For i = idx + 1 To UBound(srcArray)
  srcArray(i) = StripTags(srcArray(i))
  Next
End If
srcArray(UBound(srcArray)) = srcArray(UBound(srcArray)) & "[/REM]"
CommentFrom = srcArray
End Function

Function StripTags(ByVal Strin)
  StripTags = Strin
  grep.Pattern = "\[/?CLR\]"
  If grep.Test(Strin) Then
    StripTags = grep.Replace(Strin, "")
  End If
End Function

</SCRIPT>

i think you know what it does,, any way it used to color the words so it looks like a visual basic code,, just like [ php ] tag..
now i wsant to use this in my forums,, how and where should i add this??

thanx

Gimp 12-16-2001 05:25 PM

i dont exactly understand what you want to do but u can use javascript just like u would use it in html

damicatz 12-16-2001 05:38 PM

I took a look at your code. Correct me if I'm wrong, this code searchs for things between the tag code in brackets right? If so you would only have to put it in your showthread template.

Be aware that since your using Client Side vbScript and not Javascript that as far as I know your code will only work in Internet Explorer.


All times are GMT. The time now is 07:05 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01380 seconds
  • Memory Usage 1,724KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete