Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-26-2001, 06:37 PM
ErrOr ErrOr is offline
 
Join Date: Nov 2001
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #2  
Old 12-16-2001, 05:25 PM
Gimp Gimp is offline
 
Join Date: Nov 2001
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i dont exactly understand what you want to do but u can use javascript just like u would use it in html
Reply With Quote
  #3  
Old 12-16-2001, 05:38 PM
damicatz damicatz is offline
 
Join Date: Oct 2001
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05679 seconds
  • Memory Usage 2,181KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete