#!/bin/sh
# MetaCard 2.4 stack
# The following is not ASCII text,
# so now would be a good time to q out of more
exec mc $0 "$@"
P ChatRev M19 3"0on closeStackRequest
if (the target is "card" && quote & "chat" & quote) or (the target is "card" && quote & "login" & quote) or
(the target is "card" && quote & "register" & quote) or (the target is "card" && quote & "settings" & quote) then
answer warning "Are you sure you want to close this stack (and disconnect)?" with "Okay" or "Cancel"
if it is "Okay" then
send "disconnect" to btn "Connect" of cd 1
if the environment is "development" then
save this stack
pass closestackrequest
end if
cleanUp
quit
end if
else
pass closestackrequest
end if
end closeStackRequest
on preOpenStack
global gChatRevShortName, gMainStackRect
if (the target is "card" && quote & "chat" & quote) or (the target is "card" && quote & "login" & quote) or
(the target is "card" && quote & "register" & quote) or (the target is "card" && quote & "settings" & quote) then
put the short name of this stack into gChatRevShortName
send "restoreStyleMenu" to btn "Style Storage" of cd "Chat" of stack gChatRevShortName
readPrefs
get the result
if gMainStackRect is a rect then
set the rect of stack gChatRevShortName to gMainStackRect
else
set the rect of this stack to 1,1,640,480
set the loc of me to the screenLoc
end if
set the label of btn "Status" of cd 2 of stack gChatRevShortName to "Disconnect"
lock messages
set the menuHistory of btn "Go" to 1
set the label of btn "Connect" to "Connect"
setFieldBackColor
if the platform is not "MacOS" then
hide btn "iTunes" of cd "Settings" of stack gChatRevShortName
end if
unlock messages
end if
pass preOpenStack
end preOpenStack
-- handler added by Mark S
on openStack
global gChatRevShortName
if (the target is "card" && quote & "chat" & quote) or (the target is "card" && quote & "login" & quote) then
choose browse tool
checkLastMessageSentTime
send "setMenus" to btn "Style Storage" cd "Chat" of stack gChatRevShortName
if the platform is "MacOS" then
show btn "iTunes" of cd "Settings" of stack gChatRevShortName
else
hide btn "iTunes" of cd "Settings" of stack gChatRevShortName
end if
end if
pass openStack
end openStack
-- handler added by Mark S
on checkLastMessageSentTime
global gChatRevShortName
if the cLastMessageSentTime of cd 2 is empty then
set the cLastMessageSentTime of cd 2 to the long time
end if
put the cLastMessageSentTime of cd 2 into myIdleTime
put ((fld "Idle Time" of cd 4 of stack gChatRevShortName)*60) into myTimeLimit
convert myIdleTime to seconds
if the label of btn "Status" of cd 2 of stack gChatRevShortName is not "Disconnect" then
if (the seconds - myidleTime) > myTimeLimit then
set the label of btn "Status" of cd 2 of stack gChatRevShortName to "Away"
end if
end if
put ((fld "Idle Time" of cd 4 of stack gChatRevShortName) * 60) - 1 into myIdleTimeSecs
send "checkLastMessageSentTime" to me in myIdleTimeSecs seconds
end checkLastMessageSentTime
on preOpenCard
lock screen
revUpdateGeometry
pass preOpenCard
end preOpenCard
-- handler by Mark S
-- replace smileys
function replaceSmileys theMsg
put smileyServer() into mySmileServer
put false into mySmileyFound
if the hilite of btn "Replace smileys" of cd 4 is true then
implementedSmileys smiley
put mySmileysList() into mySmileys
repeat with x = 1 to (number of lines of mySmileys)
put smiley[x] into tempVar --for debugging
if smiley[x] is in theMsg then
put true into mySmileyFound
put the length of smiley[x] into mySmileyLength
repeat until smiley[x] is not in theMsg
put offset(smiley[x],theMsg) into c
delete char (c+1) to (c+mySmileyLength-1) of theMsg
put ("") into char c of theMsg
end repeat
end if
end repeat
if mySmileyFound then put "
" after theMsg
end if
return (theMsg & numToChar(11) & mySmileyFound)
end replaceSmileys
function smileyServer
global gChatRevShortName
put line lineoffset(the label of btn "Smile Server" of cd 4 of stack gChatRevShortName,btn "Smile Server" of cd 4 of stack gChatRevShortName) of the cServers of btn "Smile Server" of cd 4 of stack gChatRevShortName into mySmileServer
if last char of mySmileServer is not "/" then put "/" after mySmileServer
return mySmileServer
end smileyServer
function mySmileysList
put "smile.gif" & return &
"wink.gif" & return &
"sad.gif" & return &
"cry.gif" & return &
"rasp.gif" & return &
"grin.gif" & return &
"shock.gif" & return &
"love.gif" & return &
"rolleyes.gif" & return &
"cool.gif" & return &
"sneaky.gif" & return &
"bored.gif" into mySmileys
return mySmileys
end mySmileysList
on implementedSmileys @smiley
put ":-)" into smiley[1]
put ";-)" into smiley[2]
put ":-(" into smiley[3]
put ":'-(" into smiley[4]
put ":-p" into smiley[5]
put ":-D" into smiley[6]
put "=:-o" into smiley[7]
put ":-*" into smiley[8]
put ":-/" into smiley[9]
put "8-)" into smiley[10]
put ":^)" into smiley[11]
put ":-|" into smiley[12]
end implementedSmileys
on saveStackRequest
global gChatRevShortName
cleanUp
pass saveStackRequest
end saveStackRequest
on cleanUp
global gChatRevShortName,gLogViewerApp
set the cursor to watch
set the itemDelimiter to numToChar(11)
put btn "IP List" of cd 1 of stack gChatRevShortName into item 1 of myPrefs
put the label of btn "IP List" of cd 1 of stack gChatRevShortName into item 2 of myPrefs
put fld "Name" of cd 1 of stack gChatRevShortName into item 3 of myPrefs
put fld "Pass" of cd 1 of stack gChatRevShortName into item 4 of myPrefs
put fld "Port" of cd 1 of stack gChatRevShortName into item 5 of myPrefs
put fld "Nickname" of cd 3 of stack gChatRevShortName into item 6 of myPrefs
put fld "Password" of cd 3 of stack gChatRevShortName into item 7 of myPrefs
put fld "E-Mail" of cd 3 of stack gChatRevShortName into item 8 of myPrefs
put fld "MouseOver" of cd 3 of stack gChatRevShortName into item 9 of myPrefs
put fld "About" of cd 3 of stack gChatRevShortName into item 10 of myPrefs
put fld "Message Sound" of cd 4 of stack gChatRevShortName into item 11 of myPrefs
put fld "Login Sound" of cd 4 of stack gChatRevShortName into item 12 of myPrefs
put fld "Path" of cd 4 of stack gChatRevShortName into item 13 of myPrefs
put fld "Autoreply Message" of cd 4 of stack gChatRevShortName into item 14 of myPrefs
put fld "Idle Time" of cd 4 of stack gChatRevShortName into item 15 of myPrefs
-- put fld "Login Sound" of cd 4 of stack gChatRevShortName into item 16 of myPrefs
put the hilite of btn "Receive HTML" of cd 4 of stack gChatRevShortName into item 17 of myPrefs
put the hilite of btn "Replace Smileys" of cd 4 of stack gChatRevShortName into item 18 of myPrefs
put the hilite of btn "Press enter for multiple lines" of cd 4 of stack gChatRevShortName into item 19 of myPrefs
put the label of btn "Smile Server" of cd 4 of stack gChatRevShortName into item 20 of myPrefs
put btn "IP URL" of cd 1 of stack gChatRevShortName into item 21 of myPrefs
put the label of btn "IP URL" of cd 1 of stack gChatRevShortName into item 22 of myPrefs
put the rect of this stack into item 23 of myPrefs
put fld "IP" of cd 1 of stack gChatRevShortName into item 24 of myPrefs
put the backgroundcolor of grc "message" of cd 4 of stack gChatRevShortName into item 25 of myPrefs
put the backgroundcolor of grc "privmessage" of cd 4 of stack gChatRevShortName into item 26 of myPrefs
put the thumbPosition of scrollbar "Sound Level" of cd 4 of stack gChatRevShortName into item 27 of myPrefs
set the thumbPosition of scrollbar "Sound Level" of cd 4 of stack gChatRevShortName to 75
put the hilite of btn "Save to file" of cd 4 of stack gChatRevShortName into item 28 of myPrefs
set the hilite of btn "Save to file" of cd 4 of stack gChatRevShortName to false
put gLogViewerApp into item 29 of myPrefs
put the thumbposition of scrollbar "sound level" of cd 4 into item 30 of myPrefs
put the hilite of btn "Enable Speech" of cd 4 into item 31 of myPrefs
put the loc of window "Colour Palette" into item 32 of myPrefs
put the textSize of fld "Chat" of cd "Chat" of stack gChatRevShortName into item 33 of myPrefs
put the textFont of fld "Chat" of cd "Chat" of stack gChatRevShortName into item 34 of myPrefs
if there is a window "Colour Palette" then
put the bottomLeft of window "Colour Palette" into item 35 of myPrefs
else
put the cCustomLoc of stack "Colour Palette" into item 35 of myPrefs
end if
if there is a window "Smileys" then
put the bottomLeft of window "Smileys" into item 36 of myPrefs
else
put the cCustomLoc of stack "Smileys" into item 36 of myPrefs
end if
put the short name of this stack & return & myPrefs into myPrefs
put myPrefs into url ("file:" & stackToFilename("User Data/User Data"))
put empty into btn "IP List" of cd 1 of stack gChatRevShortName
set the fileName of image "Default Smile" of cd 2 of stack gChatRevShortName to empty
set the icon of btn "Insert Smile" of cd 2 of stack gChatRevShortName to empty
put empty into fld "Enter" of cd 2 of stack gChatRevShortName
put empty into fld "Chat" of cd 2 of stack gChatRevShortName
put empty into fld "Members" of cd 2 of stack gChatRevShortName
put empty into fld "Log" of cd 1 of stack gChatRevShortName
put empty into fld "Name" of cd 1 of stack gChatRevShortName
put empty into fld "Pass" of cd 1 of stack gChatRevShortName
put empty into fld "IP" of cd 1 of stack gChatRevShortName
put empty into fld "Port" of cd 1 of stack gChatRevShortName
put empty into fld "Nickname" of cd 3 of stack gChatRevShortName
put empty into fld "Password" of cd 3 of stack gChatRevShortName
put empty into fld "E-Mail" of cd 3 of stack gChatRevShortName
put empty into fld "MouseOver" of cd 3 of stack gChatRevShortName
put empty into fld "About" of cd 3 of stack gChatRevShortName
put empty into fld "Message Sound" of cd 4 of stack gChatRevShortName
put empty into fld "Login Sound" of cd 4 of stack gChatRevShortName
put empty into fld "Path" of cd 4 of stack gChatRevShortName
put empty into btn "IP URL" of cd 1 of stack gChatRevShortName
set the label of btn "IP URL" of cd 1 of stack gChatRevShortName to empty
repeat for each char x in "pbiu"
set the hilite of btn x of cd 2 of stack gChatRevShortName to false
end repeat
set the cTextStyle of fld "Enter" of cd 2 of stack gChatRevShortName to empty
set the itemDel to comma
put "Threads,Text,Edit,Thread,Create" into myForumFields
repeat for each item x in myForumFields
put empty into fld x of cd "Forum"
end repeat
set the backgroundColor of graphic "Selected Colour" of cd 1 of stack "Colour Palette" to 0,0,0
set the backgroundColor of graphic "Old Colour" of cd 1 of stack "Colour Palette" to 0,0,0
set the fileName of image "Smiley" of cd 4 to empty
if there is a window "Smileys" then close window "Smileys"
if there is a window "Colour Palette" then close window "Colour Palette"
end cleanUp
on readPrefs
global gChatRevShortName,gMainStackRect,gLogViewerApp
put "http://www.revolutionboard.de/bvg/ip.txt" into myDfltURL
put empty into myPrefs
set the cursor to watch
put stackToFilename("User Data") into myUserDataFolder
if there is not a folder myUserDataFolder then create folder myUserDataFolder
if there is not a folder (myUserDataFolder & "/Smileys") then
put "(Local" into line 5 of btn "Smile Server" of cd 4 of stack gChatRevShortName
else
put "Local" into line 5 of btn "Smile Server" of cd 4 of stack gChatRevShortName
end if
put stackToFilename("User Data/User Data") into myPrefsFilePath
put "file:" before myPrefsFilePath
put url myPrefsFilePath into myPrefs
if myPrefs is not empty then
if line 1 of myPrefs is not (the short name of this stack) then
beep
answer warning "Sorry, the user data are incompatible with this version" & return & " of ChatRev." &&
"Please enter your user data again." with "Okay"
end if
end if
delete line 1 of myPrefs
set the cServers of btn "Smile Server" of cd 4 of stack gChatRevShortName to allSmileServers()
set the itemDelimiter to numToChar(11)
put item 1 of myPrefs into btn "IP List" of cd 1 of stack gChatRevShortName
set the label of btn "IP List" of cd 1 of stack gChatRevShortName to item 2 of myPrefs
put item 3 of myPrefs into fld "Name" of cd 1 of stack gChatRevShortName
put item 4 of myPrefs into fld "Pass" of cd 1 of stack gChatRevShortName
if item 5 of myPrefs is not empty then
put item 5 of myPrefs into fld "Port" of cd 1 of stack gChatRevShortName
else
put "80" into fld "Port" of cd 1 of stack gChatRevShortName
end if
put item 6 of myPrefs into fld "Nickname" of cd 3 of stack gChatRevShortName
put item 7 of myPrefs into fld "Password" of cd 3 of stack gChatRevShortName
put item 8 of myPrefs into fld "E-Mail" of cd 3 of stack gChatRevShortName
put item 9 of myPrefs into fld "MouseOver" of cd 3 of stack gChatRevShortName
put item 10 of myPrefs into fld "About" of cd 3 of stack gChatRevShortName
put item 11 of myPrefs into fld "Message Sound" of cd 4 of stack gChatRevShortName
if there is a file (item 11 of myPrefs) then
set the filename of player "message sound" of card "chat" to (item 11 of myPrefs)
set the filename of player "message sound" of cd "Settings" to (item 11 of myPrefs)
else
set the filename of player "message sound" of card "chat" to empty
set the filename of player "message sound" of cd "Settings" to empty
end if
if item 12 of myPrefs is not empty then
put item 12 of myPrefs into fld "Login Sound" of cd 4 of stack gChatRevShortName
if there is a file (item 12 of myPrefs) then
set the filename of player "login sound" of card "chat" to (item 12 of myPrefs)
set the filename of player "login sound" to (item 12 of myPrefs)
else
set the filename of player "login sound" of card "chat" to empty
set the filename of player "login sound" of cd "Settings" to empty
end if
else
put "beep" into fld "Login Sound" of cd 4 of stack gChatRevShortName
end if
put item 13 of myPrefs into fld "Path" of cd 4 of stack gChatRevShortName
if item 14 of myPrefs is not empty then
put item 14 of myPrefs into fld "Autoreply Message" of cd 4 of stack gChatRevShortName
else
put "I am currently away from my computer." into fld "Autoreply Message" of cd 4 of stack gChatRevShortName
end if
if item 15 of myPrefs is not empty then
put item 15 of myPrefs into fld "Idle Time" of cd 4 of stack gChatRevShortName
else
put 20 into fld "Idle Time" of cd 4 of stack gChatRevShortName
end if
--put item 16 of myPrefs into fld "Login Sound" of cd 4 of stack gChatRevShortName
if item 17 of myPrefs is not empty then set the hilite of btn "Receive HTML" of cd 4 of stack gChatRevShortName to item 17 of myPrefs
if item 18 of myPrefs is not empty then
set the hilite of btn "Replace Smileys" of cd 4 of stack gChatRevShortName to item 18 of myPrefs
set the enabled of btn "Smile Server" of cd 4 of stack gChatRevShortName to item 18 of myPrefs
end if
if item 19 of myPrefs is not empty then set the hilite of btn "Press enter for multiple lines" of cd 4 of stack gChatRevShortName to item 19 of myPrefs
if item 20 of myPrefs is not empty then
set the label of btn "Smile Server" of cd 4 of stack gChatRevShortName to item 20 of myPrefs
else
set the label of btn "Smile Server" of cd 4 of stack gChatRevShortName to line 1 of btn "Smile Server" of cd 4 of stack gChatRevShortName
end if
if item 21 of myPrefs is not empty then
put item 21 of myPrefs into btn "IP URL" of cd 1 of stack gChatRevShortName
set the label of btn "IP URL" of cd 1 of stack gChatRevShortName to item 22 of myPrefs
else
put myDfltURL into btn "IP URL" of cd 1 of stack gChatRevShortName
set the label of btn "IP URL" to myDfltURL
end if
put item 23 of myPrefs into gMainStackRect
put the itemDelimiter into myOldDel
set the itemDelimiter to comma
add 20 to last item of gMainStackRect
set the itemDelimiter to myOldDel
put item 24 of myPrefs into fld "IP" of cd 1 of stack gChatRevShortName
if item 25 of myPrefs is not empty then
set the backgroundcolor of grc "message" of cd 4 of stack gChatRevShortName to item 25 of myPrefs
else
set the backgroundcolor of grc "message" of cd 4 of stack gChatRevShortName to 255,0,0
end if
if item 26 of myPrefs is not empty then
set the backgroundcolor of grc "privmessage" of cd 4 of stack gChatRevShortName to item 26 of myPrefs
else
set the backgroundcolor of grc "privmessage" of cd 4 of stack gChatRevShortName to "30,58,238"
end if
if item 27 of myPrefs is a number then
set the thumbPosition of scrollbar "Sound Level" of cd 4 of stack gChatRevShortName to item 27 of myPrefs
else
set the thumbPosition of scrollbar "Sound Level" of cd 4 of stack gChatRevShortName to 75
end if
if item 28 of myPrefs is not empty then
set the hilite of btn "Save to file" of cd 4 of stack gChatRevShortName to item 28 of myPrefs
else
set the hilite of btn "Save to file" of cd 4 of stack gChatRevShortName to false
end if
if (char 1 of menuItem 5 of btn "Smile Server" of cd 4 of stack gChatRevShortName is "(") and
(the label of btn "Smile Server" of cd 4 of stack gChatRevShortName is "Local") then
set the label of btn "Smile Server" of cd 4 of stack gChatRevShortName to line 1 of btn "Smile Server" of cd 4 of stack gChatRevShortName
end if
put (line (lineoffset(the label of btn "Smile Server" of cd 4,btn "Smile Server" of cd 4)) of the cServers of cd btn "Smile Server" of cd 4) into mySmileServer
if char 1 to 8 of mySmileServer is "binfile:" then delete char 1 to 8 of mySmileServer
set the fileName of image "Default Smile" of cd 2 to mySmileServer & "smile.gif"
get the result
set the icon of btn "Insert Smile" of cd 2 to the short id of image "Default Smile" of cd 2
set the fileName of image "Smiley" of cd 4 to mySmileServer & "smile.gif"
put item 29 of myPrefs into gLogViewerApp
if item 30 of myPrefs is not empty then
set the thumbposition of scrollbar "sound level" of cd 4 to item 30 of myPrefs
else
set the thumbposition of scrollbar "sound level" of cd 4 to 50
end if
if item 31 of myPrefs is in "true,false" then
set the hilite of btn "Enable Speech" of cd 4 to item 31 of myPrefs
else
set the hilite of btn "Enable Speech" of cd 4 to false
end if
if item 32 of myPrefs is a point then
put the loc of window "Colour Palette" into item 32 of myPrefs
end if
set the textSize of fld "Chat" of cd "Chat" of stack gChatRevShortName to item 33 of myPrefs
set the textFont of fld "Chat" of cd "Chat" of stack gChatRevShortName to item 34 of myPrefs
if item 35 of myPrefs is a point then
set the cCustomLoc of stack "Colour Palette" to item 35 of myPrefs
else
set the cCustomLoc of stack "Colour Palette" to empty
end if
if item 36 of myPrefs is a point then
set the cCustomLoc of stack "Smileys" to item 36 of myPrefs
else
set the cCustomLoc of stack "Smileys" to empty
end if
end readPrefs
function smileURL theSmiley
put smileyServer() into mySmileServer
implementedSmileys smiley
put mySmileysList() into mySmileys
repeat with x = 1 to number of lines of mySmileys
if smiley[x] is theSmiley then
return mySmileServer & line x of mySmileys
end if
end repeat
end smileURL
function stackToFilename theFile
set the itemDelimiter to "/"
if the platform is "MacOS" then
put macSysVersion() into myMacSysVersion
else
put 0 into myMacSysVersion
end if
if myMacSysVersion < 10 then
-- Mac Classic, Linux, Windows
put item 1 to -2 of value(word 2 of the long name of stack (the mainStack of this stack)) into myPath
-- put item 1 to -2 of value(word 2 of long name of stack (the mainStack of this stack)) into myPath
else if myMacSysVersion >= 10 then
-- Mac OS X
put item 1 to -5 of value(word 2 of the long name of stack (the mainStack of this stack)) into myPath
--put item 1 to -5 of value(word 2 of long name of stack (the mainStack of this stack)) into myPath
end if
if char 1 of theFile is not "/" then put "/" after myPath
return myPath & theFile
end stackToFilename
function macSysVersion
put the itemDelimiter into myOldDel
set the itemdelimiter to "."
put item 1 of the systemVersion into myOSVersion
set itemDelimiter to myOldDel
return myOSVersion
end macSysVersion
on commandKeyDown k
switch k
case "S"
if the environment is "development" then
save this stack
readPrefs
end if
break
case (k is in "'?/")
send ("commandKeyDown" && quote & "/" & quote) to this cd
break
default
pass commandKeyDown
beak
end switch
end commandKeyDown
function allSmileServers
return "http://home.wanadoo.nl/mark.sch/smile/" & return &
"http://www.ihug.org/ehug/smile/" & return &
"http://www.ihug.org/ehug/smile2/" & return &
"http://homepage.mac.com/bvg/smilies/" & return &
"binfile:" & stackToFilename("User Data/Smileys/")
end allSmileServers
function removeFinalEmptyLines theHtmlData
repeat until (char -7 to -1 of last word of theHtmlData) is not "
on closeStackRequest
if (the target is "card" && quote & "chat" & quote) or (the target is "card" && quote & "login" & quote) or ¬
(the target is "card" && quote & "register" & quote) or (the target is "card" && quote & "settings" & quote) then
answer warning "Are you sure you want to close this stack (and disconnect)?" with "Okay" or "Cancel"
if it is "Okay" then
send "disconnect" to btn "Connect" of cd 1
if the environment is "development" then
save this stack
pass closestackrequest
end if
cleanUp
quit
end if
else
pass closestackrequest
end if
end closeStackRequest
on preOpenStack
global gChatRevShortName, gMainStackRect
if (the target is "card" && quote & "chat" & quote) or (the target is "card" && quote & "login" & quote) or ¬
(the target is "card" && quote & "register" & quote) or (the target is "card" && quote & "settings" & quote) then
put the short name of this stack into gChatRevShortName
send "restoreStyleMenu" to btn "Style Storage" of cd "Chat" of stack gChatRevShortName
readPrefs
get the result
if gMainStackRect is a rect then
set the rect of stack gChatRevShortName to gMainStackRect
else
set the rect of this stack to 1,1,640,480
set the loc of me to the screenLoc
end if
set the label of btn "Status" of cd 2 of stack gChatRevShortName to "Disconnect"
lock messages
set the menuHistory of btn "Go" to 1
set the label of btn "Connect" to "Connect"
setFieldBackColor
if the platform is not "MacOS" then
hide btn "iTunes" of cd "Settings" of stack gChatRevShortName
end if
unlock messages
end if
pass preOpenStack
end preOpenStack
-- handler added by Mark S
on openStack
global gChatRevShortName
if (the target is "card" && quote & "chat" & quote) or (the target is "card" && quote & "login" & quote) then
choose browse tool
checkLastMessageSentTime
send "setMenus" to btn "Style Storage" cd "Chat" of stack gChatRevShortName
if the platform is "MacOS" then
show btn "iTunes" of cd "Settings" of stack gChatRevShortName
else
hide btn "iTunes" of cd "Settings" of stack gChatRevShortName
end if
end if
pass openStack
end openStack
-- handler added by Mark S
on checkLastMessageSentTime
global gChatRevShortName
if the cLastMessageSentTime of cd 2 is empty then
set the cLastMessageSentTime of cd 2 to the long time
end if
put the cLastMessageSentTime of cd 2 into myIdleTime
put ((fld "Idle Time" of cd 4 of stack gChatRevShortName)*60) into myTimeLimit
convert myIdleTime to seconds
if the label of btn "Status" of cd 2 of stack gChatRevShortName is not "Disconnect" then
if (the seconds - myidleTime) > myTimeLimit then
set the label of btn "Status" of cd 2 of stack gChatRevShortName to "Away"
end if
end if
put ((fld "Idle Time" of cd 4 of stack gChatRevShortName) * 60) - 1 into myIdleTimeSecs
send "checkLastMessageSentTime" to me in myIdleTimeSecs seconds
end checkLastMessageSentTime
on preOpenCard
lock screen
revUpdateGeometry
pass preOpenCard
end preOpenCard
-- handler by Mark S
-- replace smileys
function replaceSmileys theMsg
put smileyServer() into mySmileServer
put false into mySmileyFound
if the hilite of btn "Replace smileys" of cd 4 is true then
implementedSmileys smiley
put mySmileysList() into mySmileys
repeat with x = 1 to (number of lines of mySmileys)
put smiley[x] into tempVar --for debugging
if smiley[x] is in theMsg then
put true into mySmileyFound
put the length of smiley[x] into mySmileyLength
repeat until smiley[x] is not in theMsg
put offset(smiley[x],theMsg) into c
delete char (c+1) to (c+mySmileyLength-1) of theMsg
put ("<img src=" & quote & mySmileServer & line x of mySmileys & quote & ">") into char c of theMsg
end repeat
end if
end repeat
if mySmileyFound then put "<br> " after theMsg
end if
return (theMsg & numToChar(11) & mySmileyFound)
end replaceSmileys
function smileyServer
global gChatRevShortName
put line lineoffset(the label of btn "Smile Server" of cd 4 of stack gChatRevShortName,btn "Smile Server" of cd 4 of stack gChatRevShortName) of the cServers of btn "Smile Server" of cd 4 of stack gChatRevShortName into mySmileServer
if last char of mySmileServer is not "/" then put "/" after mySmileServer
return mySmileServer
end smileyServer
function mySmileysList
put "smile.gif" & return & ¬
"wink.gif" & return & ¬
"sad.gif" & return & ¬
"cry.gif" & return & ¬
"rasp.gif" & return & ¬
"grin.gif" & return & ¬
"shock.gif" & return & ¬
"love.gif" & return & ¬
"rolleyes.gif" & return & ¬
"cool.gif" & return & ¬
"sneaky.gif" & return & ¬
"bored.gif" into mySmileys
return mySmileys
end mySmileysList
on implementedSmileys @smiley
put ":-)" into smiley[1]
put ";-)" into smiley[2]
put ":-(" into smiley[3]
put ":'-(" into smiley[4]
put ":-p" into smiley[5]
put ":-D" into smiley[6]
put "=:-o" into smiley[7]
put ":-*" into smiley[8]
put ":-/" into smiley[9]
put "8-)" into smiley[10]
put ":^)" into smiley[11]
put ":-|" into smiley[12]
end implementedSmileys
on saveStackRequest
global gChatRevShortName
cleanUp
pass saveStackRequest
end saveStackRequest
on cleanUp
global gChatRevShortName,gLogViewerApp
set the cursor to watch
set the itemDelimiter to numToChar(11)
put btn "IP List" of cd 1 of stack gChatRevShortName into item 1 of myPrefs
put the label of btn "IP List" of cd 1 of stack gChatRevShortName into item 2 of myPrefs
put fld "Name" of cd 1 of stack gChatRevShortName into item 3 of myPrefs
put fld "Pass" of cd 1 of stack gChatRevShortName into item 4 of myPrefs
put fld "Port" of cd 1 of stack gChatRevShortName into item 5 of myPrefs
put fld "Nickname" of cd 3 of stack gChatRevShortName into item 6 of myPrefs
put fld "Password" of cd 3 of stack gChatRevShortName into item 7 of myPrefs
put fld "E-Mail" of cd 3 of stack gChatRevShortName into item 8 of myPrefs
put fld "MouseOver" of cd 3 of stack gChatRevShortName into item 9 of myPrefs
put fld "About" of cd 3 of stack gChatRevShortName into item 10 of myPrefs
put fld "Message Sound" of cd 4 of stack gChatRevShortName into item 11 of myPrefs
put fld "Login Sound" of cd 4 of stack gChatRevShortName into item 12 of myPrefs
put fld "Path" of cd 4 of stack gChatRevShortName into item 13 of myPrefs
put fld "Autoreply Message" of cd 4 of stack gChatRevShortName into item 14 of myPrefs
put fld "Idle Time" of cd 4 of stack gChatRevShortName into item 15 of myPrefs
-- put fld "Login Sound" of cd 4 of stack gChatRevShortName into item 16 of myPrefs
put the hilite of btn "Receive HTML" of cd 4 of stack gChatRevShortName into item 17 of myPrefs
put the hilite of btn "Replace Smileys" of cd 4 of stack gChatRevShortName into item 18 of myPrefs
put the hilite of btn "Press enter for multiple lines" of cd 4 of stack gChatRevShortName into item 19 of myPrefs
put the label of btn "Smile Server" of cd 4 of stack gChatRevShortName into item 20 of myPrefs
put btn "IP URL" of cd 1 of stack gChatRevShortName into item 21 of myPrefs
put the label of btn "IP URL" of cd 1 of stack gChatRevShortName into item 22 of myPrefs
put the rect of this stack into item 23 of myPrefs
put fld "IP" of cd 1 of stack gChatRevShortName into item 24 of myPrefs
put the backgroundcolor of grc "message" of cd 4 of stack gChatRevShortName into item 25 of myPrefs
put the backgroundcolor of grc "privmessage" of cd 4 of stack gChatRevShortName into item 26 of myPrefs
put the thumbPosition of scrollbar "Sound Level" of cd 4 of stack gChatRevShortName into item 27 of myPrefs
set the thumbPosition of scrollbar "Sound Level" of cd 4 of stack gChatRevShortName to 75
put the hilite of btn "Save to file" of cd 4 of stack gChatRevShortName into item 28 of myPrefs
set the hilite of btn "Save to file" of cd 4 of stack gChatRevShortName to false
put gLogViewerApp into item 29 of myPrefs
put the thumbposition of scrollbar "sound level" of cd 4 into item 30 of myPrefs
put the hilite of btn "Enable Speech" of cd 4 into item 31 of myPrefs
put the loc of window "Colour Palette" into item 32 of myPrefs
put the textSize of fld "Chat" of cd "Chat" of stack gChatRevShortName into item 33 of myPrefs
put the textFont of fld "Chat" of cd "Chat" of stack gChatRevShortName into item 34 of myPrefs
if there is a window "Colour Palette" then
put the bottomLeft of window "Colour Palette" into item 35 of myPrefs
else
put the cCustomLoc of stack "Colour Palette" into item 35 of myPrefs
end if
if there is a window "Smileys" then
put the bottomLeft of window "Smileys" into item 36 of myPrefs
else
put the cCustomLoc of stack "Smileys" into item 36 of myPrefs
end if
put the short name of this stack & return & myPrefs into myPrefs
put myPrefs into url ("file:" & stackToFilename("User Data/User Data"))
put empty into btn "IP List" of cd 1 of stack gChatRevShortName
set the fileName of image "Default Smile" of cd 2 of stack gChatRevShortName to empty
set the icon of btn "Insert Smile" of cd 2 of stack gChatRevShortName to empty
put empty into fld "Enter" of cd 2 of stack gChatRevShortName
put empty into fld "Chat" of cd 2 of stack gChatRevShortName
put empty into fld "Members" of cd 2 of stack gChatRevShortName
put empty into fld "Log" of cd 1 of stack gChatRevShortName
put empty into fld "Name" of cd 1 of stack gChatRevShortName
put empty into fld "Pass" of cd 1 of stack gChatRevShortName
put empty into fld "IP" of cd 1 of stack gChatRevShortName
put empty into fld "Port" of cd 1 of stack gChatRevShortName
put empty into fld "Nickname" of cd 3 of stack gChatRevShortName
put empty into fld "Password" of cd 3 of stack gChatRevShortName
put empty into fld "E-Mail" of cd 3 of stack gChatRevShortName
put empty into fld "MouseOver" of cd 3 of stack gChatRevShortName
put empty into fld "About" of cd 3 of stack gChatRevShortName
put empty into fld "Message Sound" of cd 4 of stack gChatRevShortName
put empty into fld "Login Sound" of cd 4 of stack gChatRevShortName
put empty into fld "Path" of cd 4 of stack gChatRevShortName
put empty into btn "IP URL" of cd 1 of stack gChatRevShortName
set the label of btn "IP URL" of cd 1 of stack gChatRevShortName to empty
repeat for each char x in "pbiu"
set the hilite of btn x of cd 2 of stack gChatRevShortName to false
end repeat
set the cTextStyle of fld "Enter" of cd 2 of stack gChatRevShortName to empty
set the itemDel to comma
put "Threads,Text,Edit,Thread,Create" into myForumFields
repeat for each item x in myForumFields
put empty into fld x of cd "Forum"
end repeat
set the backgroundColor of graphic "Selected Colour" of cd 1 of stack "Colour Palette" to 0,0,0
set the backgroundColor of graphic "Old Colour" of cd 1 of stack "Colour Palette" to 0,0,0
set the fileName of image "Smiley" of cd 4 to empty
if there is a window "Smileys" then close window "Smileys"
if there is a window "Colour Palette" then close window "Colour Palette"
end cleanUp
on readPrefs
global gChatRevShortName,gMainStackRect,gLogViewerApp
put "http://www.revolutionboard.de/bvg/ip.txt" into myDfltURL
put empty into myPrefs
set the cursor to watch
put stackToFilename("User Data") into myUserDataFolder
if there is not a folder myUserDataFolder then create folder myUserDataFolder
if there is not a folder (myUserDataFolder & "/Smileys") then
put "(Local" into line 5 of btn "Smile Server" of cd 4 of stack gChatRevShortName
else
put "Local" into line 5 of btn "Smile Server" of cd 4 of stack gChatRevShortName
end if
put stackToFilename("User Data/User Data") into myPrefsFilePath
put "file:" before myPrefsFilePath
put url myPrefsFilePath into myPrefs
if myPrefs is not empty then
if line 1 of myPrefs is not (the short name of this stack) then
beep
answer warning "Sorry, the user data are incompatible with this version" & return & " of ChatRev." && ¬
"Please enter your user data again." with "Okay"
end if
end if
delete line 1 of myPrefs
set the cServers of btn "Smile Server" of cd 4 of stack gChatRevShortName to allSmileServers()
set the itemDelimiter to numToChar(11)
put item 1 of myPrefs into btn "IP List" of cd 1 of stack gChatRevShortName
set the label of btn "IP List" of cd 1 of stack gChatRevShortName to item 2 of myPrefs
put item 3 of myPrefs into fld "Name" of cd 1 of stack gChatRevShortName
put item 4 of myPrefs into fld "Pass" of cd 1 of stack gChatRevShortName
if item 5 of myPrefs is not empty then
put item 5 of myPrefs into fld "Port" of cd 1 of stack gChatRevShortName
else
put "80" into fld "Port" of cd 1 of stack gChatRevShortName
end if
put item 6 of myPrefs into fld "Nickname" of cd 3 of stack gChatRevShortName
put item 7 of myPrefs into fld "Password" of cd 3 of stack gChatRevShortName
put item 8 of myPrefs into fld "E-Mail" of cd 3 of stack gChatRevShortName
put item 9 of myPrefs into fld "MouseOver" of cd 3 of stack gChatRevShortName
put item 10 of myPrefs into fld "About" of cd 3 of stack gChatRevShortName
put item 11 of myPrefs into fld "Message Sound" of cd 4 of stack gChatRevShortName
if there is a file (item 11 of myPrefs) then
set the filename of player "message sound" of card "chat" to (item 11 of myPrefs)
set the filename of player "message sound" of cd "Settings" to (item 11 of myPrefs)
else
set the filename of player "message sound" of card "chat" to empty
set the filename of player "message sound" of cd "Settings" to empty
end if
if item 12 of myPrefs is not empty then
put item 12 of myPrefs into fld "Login Sound" of cd 4 of stack gChatRevShortName
if there is a file (item 12 of myPrefs) then
set the filename of player "login sound" of card "chat" to (item 12 of myPrefs)
set the filename of player "login sound" to (item 12 of myPrefs)
else
set the filename of player "login sound" of card "chat" to empty
set the filename of player "login sound" of cd "Settings" to empty
end if
else
put "beep" into fld "Login Sound" of cd 4 of stack gChatRevShortName
end if
put item 13 of myPrefs into fld "Path" of cd 4 of stack gChatRevShortName
if item 14 of myPrefs is not empty then
put item 14 of myPrefs into fld "Autoreply Message" of cd 4 of stack gChatRevShortName
else
put "I am currently away from my computer." into fld "Autoreply Message" of cd 4 of stack gChatRevShortName
end if
if item 15 of myPrefs is not empty then
put item 15 of myPrefs into fld "Idle Time" of cd 4 of stack gChatRevShortName
else
put 20 into fld "Idle Time" of cd 4 of stack gChatRevShortName
end if
--put item 16 of myPrefs into fld "Login Sound" of cd 4 of stack gChatRevShortName
if item 17 of myPrefs is not empty then set the hilite of btn "Receive HTML" of cd 4 of stack gChatRevShortName to item 17 of myPrefs
if item 18 of myPrefs is not empty then
set the hilite of btn "Replace Smileys" of cd 4 of stack gChatRevShortName to item 18 of myPrefs
set the enabled of btn "Smile Server" of cd 4 of stack gChatRevShortName to item 18 of myPrefs
end if
if item 19 of myPrefs is not empty then set the hilite of btn "Press enter for multiple lines" of cd 4 of stack gChatRevShortName to item 19 of myPrefs
if item 20 of myPrefs is not empty then
set the label of btn "Smile Server" of cd 4 of stack gChatRevShortName to item 20 of myPrefs
else
set the label of btn "Smile Server" of cd 4 of stack gChatRevShortName to line 1 of btn "Smile Server" of cd 4 of stack gChatRevShortName
end if
if item 21 of myPrefs is not empty then
put item 21 of myPrefs into btn "IP URL" of cd 1 of stack gChatRevShortName
set the label of btn "IP URL" of cd 1 of stack gChatRevShortName to item 22 of myPrefs
else
put myDfltURL into btn "IP URL" of cd 1 of stack gChatRevShortName
set the label of btn "IP URL" to myDfltURL
end if
put item 23 of myPrefs into gMainStackRect
put the itemDelimiter into myOldDel
set the itemDelimiter to comma
add 20 to last item of gMainStackRect
set the itemDelimiter to myOldDel
put item 24 of myPrefs into fld "IP" of cd 1 of stack gChatRevShortName
if item 25 of myPrefs is not empty then
set the backgroundcolor of grc "message" of cd 4 of stack gChatRevShortName to item 25 of myPrefs
else
set the backgroundcolor of grc "message" of cd 4 of stack gChatRevShortName to 255,0,0
end if
if item 26 of myPrefs is not empty then
set the backgroundcolor of grc "privmessage" of cd 4 of stack gChatRevShortName to item 26 of myPrefs
else
set the backgroundcolor of grc "privmessage" of cd 4 of stack gChatRevShortName to "30,58,238"
end if
if item 27 of myPrefs is a number then
set the thumbPosition of scrollbar "Sound Level" of cd 4 of stack gChatRevShortName to item 27 of myPrefs
else
set the thumbPosition of scrollbar "Sound Level" of cd 4 of stack gChatRevShortName to 75
end if
if item 28 of myPrefs is not empty then
set the hilite of btn "Save to file" of cd 4 of stack gChatRevShortName to item 28 of myPrefs
else
set the hilite of btn "Save to file" of cd 4 of stack gChatRevShortName to false
end if
if (char 1 of menuItem 5 of btn "Smile Server" of cd 4 of stack gChatRevShortName is "(") and ¬
(the label of btn "Smile Server" of cd 4 of stack gChatRevShortName is "Local") then
set the label of btn "Smile Server" of cd 4 of stack gChatRevShortName to line 1 of btn "Smile Server" of cd 4 of stack gChatRevShortName
end if
put (line (lineoffset(the label of btn "Smile Server" of cd 4,btn "Smile Server" of cd 4)) of the cServers of cd btn "Smile Server" of cd 4) into mySmileServer
if char 1 to 8 of mySmileServer is "binfile:" then delete char 1 to 8 of mySmileServer
set the fileName of image "Default Smile" of cd 2 to mySmileServer & "smile.gif"
get the result
set the icon of btn "Insert Smile" of cd 2 to the short id of image "Default Smile" of cd 2
set the fileName of image "Smiley" of cd 4 to mySmileServer & "smile.gif"
put item 29 of myPrefs into gLogViewerApp
if item 30 of myPrefs is not empty then
set the thumbposition of scrollbar "sound level" of cd 4 to item 30 of myPrefs
else
set the thumbposition of scrollbar "sound level" of cd 4 to 50
end if
if item 31 of myPrefs is in "true,false" then
set the hilite of btn "Enable Speech" of cd 4 to item 31 of myPrefs
else
set the hilite of btn "Enable Speech" of cd 4 to false
end if
if item 32 of myPrefs is a point then
put the loc of window "Colour Palette" into item 32 of myPrefs
end if
set the textSize of fld "Chat" of cd "Chat" of stack gChatRevShortName to item 33 of myPrefs
set the textFont of fld "Chat" of cd "Chat" of stack gChatRevShortName to item 34 of myPrefs
if item 35 of myPrefs is a point then
set the cCustomLoc of stack "Colour Palette" to item 35 of myPrefs
else
set the cCustomLoc of stack "Colour Palette" to empty
end if
if item 36 of myPrefs is a point then
set the cCustomLoc of stack "Smileys" to item 36 of myPrefs
else
set the cCustomLoc of stack "Smileys" to empty
end if
end readPrefs
function smileURL theSmiley
put smileyServer() into mySmileServer
implementedSmileys smiley
put mySmileysList() into mySmileys
repeat with x = 1 to number of lines of mySmileys
if smiley[x] is theSmiley then
return mySmileServer & line x of mySmileys
end if
end repeat
end smileURL
function stackToFilename theFile
set the itemDelimiter to "/"
if the platform is "MacOS" then
put macSysVersion() into myMacSysVersion
else
put 0 into myMacSysVersion
end if
if myMacSysVersion < 10 then
-- Mac Classic, Linux, Windows
put item 1 to -2 of value(word 2 of the long name of stack (the mainStack of this stack)) into myPath
-- put item 1 to -2 of value(word 2 of long name of stack (the mainStack of this stack)) into myPath
else if myMacSysVersion >= 10 then
-- Mac OS X
put item 1 to -5 of value(word 2 of the long name of stack (the mainStack of this stack)) into myPath
--put item 1 to -5 of value(word 2 of long name of stack (the mainStack of this stack)) into myPath
end if
if char 1 of theFile is not "/" then put "/" after myPath
return myPath & theFile
end stackToFilename
function macSysVersion
put the itemDelimiter into myOldDel
set the itemdelimiter to "."
put item 1 of the systemVersion into myOSVersion
set itemDelimiter to myOldDel
return myOSVersion
end macSysVersion
on commandKeyDown k
switch k
case "S"
if the environment is "development" then
save this stack
readPrefs
end if
break
case (k is in "'?/")
send ("commandKeyDown" && quote & "/" & quote) to this cd
break
default
pass commandKeyDown
beak
end switch
end commandKeyDown
function allSmileServers
return "http://home.wanadoo.nl/mark.sch/smile/" & return & ¬
"http://www.ihug.org/ehug/smile/" & return & ¬
"http://www.ihug.org/ehug/smile2/" & return & ¬
"http://homepage.mac.com/bvg/smilies/" & return & ¬
"binfile:" & stackToFilename("User Data/Smileys/")
end allSmileServers
function removeFinalEmptyLines theHtmlData
repeat until (char -7 to -1 of last word of theHtmlData) is not "<p></p>"
delete char -7 to -1 of last word of theHtmlData
if last char of theMessage is space then delete last char of theHtmlData
end repeat
return theHtmlData
end removeFinalEmptyLines
on setFieldBackColor
global gChatRevShortName
put "237,243,254" into myBackColor
if the platForm is "MacOS" then
if macSysversion() < 10 then put "232,232,232" into myBackColor
end if
set the backgroundColor of fld "Members" of cd 2 of stack gChatRevShortName to myBackColor
end setFieldBackColor
-- this function uses above AppleScript to
-- retrieve the song information
function iTunesTrack
-- the stackToFilename function puts the path to the script
-- into the variable myScriptFile. This lines needs
-- adjustment if you implement this in your own stack
put stackToFilename("User Data/iTunes track.scpt") into myScriptFile
if there is a file myScriptFile then
if the platForm is "MacOS" then
if macSysVersion() <= 9 then
put ("run script" && quote & revMacFromUnixPath(myScriptFile) & quote) into myScript
wait 1
else
put ("run script" && quote & myScriptFile & quote) into myScript
end if
do myScript as AppleScript
return the result
end if
end if
return empty
end iTunesTrack
-- gets info from above function and
-- updates tooltip
on setTooltip2iTunes
global gChatRevShortName
set the itemDelimiter to tab
if the hilite of btn "iTunes" of cd 4 of stack gChatRevShortName is true then
put fld "Members" of cd 2 of stack gChatRevShortName into myMemberList
put field "Name" of cd 1 of stack gChatRevShortName into myUserName
put 1 into myNumber
repeat until ((item 1 of line myNumber of myMemberList is myUserName) or (item 1 of line myNumber of myMemberList is empty))
put lineOffset(myUserName,myMemberList) into myNumber
end repeat
if (myNumber > 0) and (myNumber <= number of lines of myMemberList) then
put iTunesTrack() into myTrack
if myTrack is not "execution error" then
put char 2 to -2 of myTrack into myTrack
else
put empty into myTrack
end if
if item 2 of line myNumber of myMemberList is not myTrack then
write "setMouse" & return & myTrack & return to socket field "IP" of card 1
end if
end if
send setTooltip2iTunes to me in 5 seconds
end if
end setTooltip2iTunes
on savetofile theLines
if field "message sound" of card "settings" = "beep" then
beep
else if field "message sound" of card "settings" = "" then
--do nothing here
else
set the currentTime of player "message sound" of card "chat" to 1
start player "message sound" of card "chat"
end if
lock screen
--set the textstyle of line -1 of field "chat" of card "chat" to empty
if line -1 of field "chat" of card "chat" contains "http://" then
put word wordoffset("http://",line -1 of field "chat" of card "chat") of line -1 of field "chat" of card "chat" into theURL
set the linktext of word wordoffset("http://",line -1 of field "chat" of card "chat") of line -1 of field "chat" of card "chat" to theURL
set the textstyle of word wordoffset("http://",line -1 of field "chat" of card "chat") of line -1 of field "chat" of card "chat" to "Link"
else if line -1 of field "chat" of card "chat" contains " www." then
put "http://" & word wordoffset("www.",line -1 of field "chat" of card "chat") of line -1 of field "chat" of card "chat" into theURL
set the linktext of word wordoffset("www.",line -1 of field "chat" of card "chat") of line -1 of field "chat" of card "chat" to theURL
set the textstyle of word wordoffset("www.",line -1 of field "chat" of card "chat") of line -1 of field "chat" of card "chat" to "Link"
else if line -1 of field "chat" of card "chat" contains " ftp." then
put "ftp://" & word wordoffset("ftp.",line -1 of field "chat" of card "chat") of line -1 of field "chat" of card "chat" into theURL
set the linktext of word wordoffset("ftp.",line -1 of field "chat" of card "chat") of line -1 of field "chat" of card "chat" to theURL
set the textstyle of word wordoffset("ftp.",line -1 of field "chat" of card "chat") of line -1 of field "chat" of card "chat" to "Link"
else if line -theLines to -1 of field "chat" of card "chat" contains "ftp://" then
put word wordoffset("ftp://",line -1 of field "chat" of card "chat") of line -1 of field "chat" of card "chat" into theURL
set the linktext of word wordoffset("ftp://",line -1 of field "chat" of card "chat") of line -1 of field "chat" of card "chat" to theURL
set the textstyle of word wordoffset("ftp://",line -1 of field "chat" of card "chat") of line -1 of field "chat" of card "chat" to "Link"
else if line -theLines to -1 of field "chat" of card "chat" contains "@" then
put offset("@",line -theLines to -1 of field "chat" of card "chat") into c
if charToNum(char (c-1) of line -theLines to -1 of field "chat" of card "chat") > 32 and charToNum(char (c-1) of line -theLines to -1 of field "chat" of card "chat") < 122 and charToNum(char (c+1) of line -theLines to -1 of field "chat" of card "chat") > 32 and charToNum(char (c+1) of line -theLines to -1 of field "chat" of card "chat") < 123 then
put word wordoffset("@",line -theLines to -1 of field "chat" of card "chat") of line -theLines to -1 of field "chat" of card "chat" into theURL
set the linktext of word wordoffset("@",line -theLines to -1 of field "chat" of card "chat") of line -theLines to -1 of field "chat" of card "chat" to theURL
set the textstyle of word wordoffset("@",line -theLines to -1 of field "chat" of card "chat") of line -theLines to -1 of field "chat" of card "chat" to "Link"
end if
else if line -1 of field "chat" of cd "Chat" contains "bug " then
put wordoffset("bug",line -1 of field "Chat" of card "Chat") into w
if word (w+1) of line -1 of field "Chat" of card "Chat" is a number then
put word w to (w+1) of line -1 of field "Chat" of card "Chat" into theURL
set the linktext of word w to (w+1) of line -1 of field "chat" of card "chat" to theURL
set the textstyle of word w to (w+1) of line -1 of field "chat" of card "chat" to "Link"
end if
end if
if the textstyle of char -1 of field "chat" of card "chat" contains "link" then
put " " after line -1 of field "chat" of card "chat"
set the textstyle of char -1 field "chat" of card "chat" to "plain"
end if
if the hilite of button "save to file" of card "settings" = true then
if field "path" of card "settings" <> "" then
put field "path" of card "settings" into thepath
open file thePath for append
write return & line -thelines of field "chat" of card "chat" to file thePath
close file thePath
--put return & line -thelines of field "chat" of card "chat" after url ("file:" & the path of button "save to file" of card "chat")
end if
end if
end savetofile
on handleThisLink theUrl
if the optionKey is down then
saveURL theURL
else if char -4 to -1 of theurl = ".rev" or char -3 to -1 of theUrl = ".mc" then
if the environment is "development" then
put "Revolution" into myApp
else
put "ChatRev" into myApp
end if
answer question "Do you want to open this stack in" && myApp && "or save it to disk?" with "Open" or "Save" or "Cancel"
if it is "Open" then
if char 1 to 4 of theURL is "ftp." then put "ftp://" before theURL
go stack url theurl
else if it is "Save" then
saveURL theURL
end if
else if ("@" is not in theUrl) and (word 1 of theURL is not "bug") then
if (char -4 to -1 of theURL is not ".htm") and (char -5 to -1 of theURL is not ".html") ¬
and ("." is in char -5 to -1 of theURL) and (last char of theURL is not "/") then
answer "Open this file in your browser or save to disk?" with "Open" or "Save"
if it is "Save" then
saveURL theURL
else
if char 1 to 4 of theUrl is "ftp." then put "ftp://" before theUrl
revgoURL theUrl
end if
else
if char 1 to 4 of theURL is "ftp." then put "ftp://" before theURL
revgoURL theURL
end if
else if (theURL contains "@") and ("http://" is not in theURL) and ("ftp://" is not in theURL) and (word 1 of theURL is not "bug") then
put offset("@",theURL) into c
if charToNum(char (c-1) of theURL) > 32 and charToNum(char (c-1) of theURL) < 122 and charToNum(char (c+1) of theURL) > 32 and charToNum(char (c+1) of theURL) < 123 then
if char 1 to 7 of theURL is not "mailto:" then
revGoURL "mailto:" & theURL
else
revGoURL theURL
end if
end if
else if (word 1 of theURL is "bug") and (word 2 of theURL is a number) then
revGoURL ("http://support.runrev.com/bugdatabase/show_bug.cgi?id=" & word 2 of theURL)
else
-- this last option is probably no longer necessary
if char 1 to 4 of theURL is "ftp." then put "ftp://" before theURL
revgoURL theURL
end if
end handleThisLink
on saveURL theURL
if char 1 to 4 of theURL is "ftp." then put "ftp://" before theURL
set the itemDelimiter to "/"
put last item of theURL into myFileName
ask file "Save file as..." with myFileName
if it is not empty then
put it into myNewFile
put the fileType into myOldFileType
set the fileType to "????????"
put url theURL into url ("binfile:" & myNewFile)
set the fileType to myOldFileType
end if
end saveURL
on makeLinks theField
if (" www." is in fld theField) or (" ftp." is in fld theField) or ("http://" is in fld theField) or (" ftp://" is in fld theField) or ("@" is in fld theField) then
repeat with x = 1 to number of words in fld theField
put "www.,ftp.,http://,ftp://,@" into myList
repeat for each item y in myList
if y is in word x of fld theField then
switch y
case "www."
set the linkText of word x of fld theField to ("http://" & word x of fld theField)
set the textStyle of word x of fld theField to "link"
break
case "ftp."
if char 1 to 4 of word x of fld theField is "ftp." then set the linkText of word x of fld theField to ("ftp://" & word x of fld theField)
set the textStyle of word x of fld theField to "link"
break
case "http://"
set the linkText of word x of fld theField to (word x of fld theField)
set the textStyle of word x of fld theField to "link"
break
case "ftp://"
set the linkText of word x of fld theField to (word x of fld theField)
set the textStyle of word x of fld theField to "link"
break
case "@"
put offset("@",word x of fld theField) into c
if not ((char (c-1) of word x of fld theField is in (return & space)) or (char (c+1) of word x of fld theField is in (return & space))) then
if char 1 to 7 of word x of fld theField is not "mailto:" then
set the linkText of word x of fld theField to ("mailto:" & word x of fld theField)
else
set the linkText of word x of fld theField to (word x of fld theField)
end if
set the textStyle of word x of fld theField to "link"
end if
break
end switch
end if
end repeat
end repeat
end if
end makeLinks
function validIP theIP
put false into rslt
set the itemDelimiter to "."
if the number of items of theIP is 4 then
repeat for each item x in theIP
if x is an integer then
put true into rslt
else
put false into rslt
exit repeat
end if
end repeat
end if
return rslt
end validIP
on setAbout
ask "Pease enter a new text about yourself..."
if it is not empty then
lock screen
put "/setAbout" && it into fld "Enter"
send "returnInField" to fld "Enter"
end if
end setAbout
on setEmail
ask "Pease enter your e-mail address..."
if it is not empty then
lock screen
put "/setmail" && it into fld "Enter"
send "returnInField" to fld "Enter"
end if
end setEmail
on setLabel
ask "Pease enter a new label (tooltip text)"
if it is not empty then
lock screen
put "/l" && it into fld "Enter"
send "returnInField" to fld "Enter"
end if
end setLabel
function noPendingTransfers
if ("sendFile" is in the pendingMessages) or ("getFile" is in the pendingMessages) then
return false
end if
return true
end noPendingTransfers
login P on preOpenCard revupdategeometry select text of fld "Name" end preOpenCard on commandKeyDown k if k = "/" then go cd 1 of stack "Help" as modeless else pass commandKeyDown end commandKeyDown # cREVGeneral scriptChecksum ryRQm bookmarks handlerList preOpenCard commandKeyDownscriptSelection char 113 to 112prevHandler preOpenCardtempScript scripton preOpenCard
revupdategeometry
select text of fld "Name"
end preOpenCard
on commandKeyDown k
if