/*
* -----
* Screenshot Sender - functions.js
* -----
* Common functions for Screenshot Sender
* -----
*/
/*
Name: CheckVersion
Purpose: Compare the parameter to the Messenger Plus! Live version
Parameters: _version - Version to compare to Messenger Plus! Live
Return: True if Plus! version is Greater or Equal to the Parameter / False if it isn't
*/
function CheckVersion(_version) {
_debug.getfuncname(arguments);
var ret = MsgPlus.Version >= _version;
if (ret === false)
_win32.MessageBoxW(0, _lang.text['MsgBoxPlusVersionError'], _lang.text['MsgBoxError_Title'], 32);
return ret;
}
/*
Name: GetDirectoryStructure
Purpose: Create a list of all the files from a given location on the disc
Parameters: sPath - Path to get all the files from
includePath - If true, will include the full path to the filename, if false will only display the filename
Return: An array of the files from the path
*/
function GetDirectoryStructure(sPath, sPattern, IncludePath) {
_debug.getfuncname(arguments);
var aFileNames = [];
var Win32_Find_Data = Interop.Allocate(592);
var hSearch = Interop.Call('kernel32', 'FindFirstFileW', '\\\\?\\' + sPath + sPattern, Win32_Find_Data);
var hResult;
while (hResult !== 0) {
if (!(Win32_Find_Data.ReadDWORD(0) & 0x10 /* FILE_ATTRIBUTE_DIRECTORY */ & 0x4 /* FILE_ATTRIBUTE_SYSTEM */) &&
Win32_Find_Data.ReadString(44).charAt(0) !== '.') {
aFileNames.push((IncludePath ? sPath : '') + Win32_Find_Data.ReadString(44));
}
hResult = Interop.Call('kernel32', 'FindNextFileW', hSearch, Win32_Find_Data)
}
Interop.Call('kernel32', 'FindClose', hSearch);
return aFileNames;
}
/*
Name: ClearListView
Purpose: Clears a specified listview of all it's contents
Parameters: hWnd - The handle of the listview
Return: None
*/
function ClearListView(hWnd) {
_debug.getfuncname(arguments);
_win32.SendMessageW(hWnd, _win32._const._LVM_DELETEALLITEMS, 0, 0);
}
/*
Name: CheckForOldVersion
Purpose: Check if Screenshot Sender 4 is installed and enabled
Parameters: None
Return: True if SS4 is enabled / False if it isn't
*/
function CheckForOldVersion() {
_debug.getfuncname(arguments);
if (Registry_GetKeyValue(HKCU, 'Software\\Patchou\\Messenger Plus! Live\\GlobalSettings\\Scripts\\Screenshot Sender 4', 'Enabled')) {
if (_win32.MessageBoxW(0, _lang.text['MsgBoxPreviousVersion'], _lang.text['MsgBoxPreviousVersion_Title'], _win32._const._MB_ICONEXCLAMATION | _win32._const._MB_YESNO) === 6) {
Registry_SetKeyValue(HKCU, 'Software\\Patchou\\Messenger Plus! Live\\GlobalSettings\\Scripts\\Screenshot Sender 4', 'Enabled', 0, REG_DWORD);
_win32.ShellExecuteW(0, 'open', Registry_GetKeyValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\\Patchou\\Messenger Plus! Live', 'AppDir') + '\\MPTools.exe', '/restartmessenger', '', _win32._const._SW_HIDE);
}
}
return false;
}
/*
Name: ContactSelector
Purpose: Launch the contact selector to choose the contact(s) to send the screenshot to
Parameters: oEnum - Enumerator object(ex: Messenger.MyContacts)
Return: PlusWnd of the Contact Selector window
*/
function ContactSelector(oEnum) {
_debug.getfuncname(arguments);
var Wnd = OpenWindow('ContactSelector', 0, true), nIndex = 0, o;
for (var e = new Enumerator(oEnum); !e.atEnd(); e.moveNext()) {
var o = e.item();
if (o.Status > 2 && o.Blocked == false && o.Network === 1 && o.Email.indexOf(':') === -1) {
nIndex = Wnd.LstView_AddItem('LvContacts', RemovePlusCodes(e.item().Name));
Wnd.LstView_SetItemText('LvContacts', nIndex, 1, e.item().Email);
Wnd.LstView_SetItemIcon('LvContacts', nIndex, oStatus[e.item().Status], true);
}
}
return Wnd;
}
/*
Name: Preview
Purpose: Launches the preview window for screenshots
Parameters: oChatWnd - [OBJ] Chat window object
sImage - [STR] Location of image to be sent
bSave - [BOOL] If the image is to be saved or not
bViewer - [BOOL] If the screenshot viewer window is the "parent"
Return: None
*/
function Preview(oChatWnd, sImage, bSave, bViewer) {
_debug.getfuncname(arguments);
if (typeof bSave === TYPE_UNDEFINED) bSave = false;
if (typeof bViewer === TYPE_UNDEFINED) bViewer = false;
var PreviewWnd = OpenWindow('Preview', 1, true);
objChatWnds[PreviewWnd.Handle] = {};
objChatWnds[PreviewWnd.Handle].ChatWnd = oChatWnd;
objChatWnds[PreviewWnd.Handle].Image = sImage;
objChatWnds[PreviewWnd.Handle].IsViewer = bViewer;
if (bSave === true) {
_win32.ShowWindow(objWindows['Preview'].GetControlHandle('lnkSaveImage'), _win32._const._SW_SHOW);
_win32.ShowWindow(objWindows['Preview'].GetControlHandle('lnkSendImage'), _win32._const._SW_HIDE);
}
var oGdip = new Gdip();
oGdip.Initialize();
PreviewWnd.SetControlText('lblImageName', SessionImages.GetFilename(sImage));
PreviewWnd.SetControlText('lblImageSize', _lang.text['ScreenshotViewer_Size'] + ' ' + oGdip.FormatFileSize(oGdip.GetImageSizeInBytes(sImage)));
PreviewWnd.SetControlText('lblImageDimensions', _lang.text['ScreenshotViewer_Dimensions'] + ' ' + oGdip.GetImageDimensions(sImage));
PreviewWnd.SetControlText('lblImageCreated', _lang.text['ScreenshotViewer_DateCreated'] + ' ' + oGdip.GetDateCreated(sImage));
oGdip.Uninitialize();
if (typeof objPictures[SessionImages.GetFilename(sImage)] === TYPE_OBJECT) {
if (SessionImages.GetExtension(sImage).toLowerCase() === 'jpg') {
_win32.EnableWindow(PreviewWnd.GetControlHandle('sldrQuality'), true);
PreviewWnd.SendControlMessage('sldrQuality', _win32._const._TBM_SETPOS, true, objPictures[SessionImages.GetFilename(sImage)].Quality);
} else {
_win32.EnableWindow(PreviewWnd.GetControlHandle('sldrQuality'), false);
_win32.EnableWindow(PreviewWnd.GetControlHandle('lblJpgQuality'), false);
PreviewWnd.ImageElmt_SetImageFile('ImgJpg', '\\' + MsgPlus.ScriptFilesPath + '\\Images\\jpg_disabled.png');
}
} else {
_win32.EnableWindow(PreviewWnd.GetControlHandle('sldrQuality'), false);
_win32.EnableWindow(PreviewWnd.GetControlHandle('lblJpgQuality'), false);
PreviewWnd.ImageElmt_SetImageFile('ImgJpg', '\\' + MsgPlus.ScriptFilesPath + '\\Images\\jpg_disabled.png');
}
var nHooks = [
_win32._const._WM_PARENTNOTIFY,
_win32._const._WM_NOTIFY
];
if (IsWinVista() === false)
nHooks.push(_win32._const._WM_SIZE);
RegisterWindowHooks( PreviewWnd, nHooks );
PreviewWnd.ImageElmt_SetImageFile('ImgPreview', '\\' + sImage);
_win32.ShowWindow(objWindows['Preview'].Handle, _win32._const._SW_SHOW);
}
/*
Name: SetTransparency
Purpose: Set transparency level of a window
Parameters: hWnd - Handle to the window to set the transparency
lLevel - Level of opacity
bSelect - True if the window is for the select area function
Return: None
*/
function SetTransparency(hWnd, lLevel, bSelect, nRemoveStyle) {
_debug.getfuncname(arguments);
if (typeof bSelect === TYPE_UNDEFINED) var bSelect = false;
if (typeof nRemoveStyle === TYPE_UNDEFINED) nRemoveStyle = 0;
var nMsg = _win32.GetWindowLongW(hWnd, _win32._const._GWL_EXSTYLE) & ~nRemoveStyle;
nMsg = nMsg | _win32._const._WS_EX_LAYERED | (bSelect ? 0 : _win32._const._WS_EX_TRANSPARENT);
_win32.SetWindowLongW(hWnd, _win32._const._GWL_EXSTYLE, nMsg);
_win32.SetLayeredWindowAttributes(hWnd, 0, lLevel, _win32._const._LWA_ALPHA);
}
/*
Name: ChooseColor
Purpose: Opens the color picker dialog
Parameters: hWnd - Handle to the window to set the transparency
clrColor - Currently selected color
Return: The newly selected color
*/
function ChooseColor(hWnd, clrColor) {
_debug.getfuncname(arguments);
var CHOOSECOLOR = Interop.Allocate(36);
var CustColors = Interop.Allocate(64);
for (var i = 0; i < 16; ++i) CustColors.WriteDWORD(i * 4, 0x00ffffff); //Set all custom colors to white
with (CHOOSECOLOR) {
WriteDWORD(0, Size);
WriteDWORD(4, hWnd);
WriteDWORD(12, clrColor);
WriteDWORD(16, CustColors.DataPtr);
WriteDWORD(20, _win32._const._CC_FULLOPEN | _win32._const._CC_RGBINIT);
}
//Open the dialog box
if (_win32.ChooseColorW(CHOOSECOLOR) === 0) {
CHOOSECOLOR.Size = 0;
CustColors.Size = 0;
return false;
}
clrColor = CHOOSECOLOR.ReadDWORD(12);
CHOOSECOLOR.Size = 0;
CustColors.Size = 0;
return clrColor;
}
/*
Name: LaunchScreenshotViewer
Purpose: Opens the Screenshot Viewer Window
Parameters: None
Return: None
*/
function LaunchScreenshotViewer() {
_debug.getfuncname(arguments);
OpenWindow('ScreenshotViewer', 0, true);
_win32.EnableWindow(objWindows['ScreenshotViewer'].GetControlHandle('lnkSendImage'), false);
_win32.EnableWindow(objWindows['ScreenshotViewer'].GetControlHandle('lnkUploadImage'), false);
_win32.EnableWindow(objWindows['ScreenshotViewer'].GetControlHandle('lnkConvertImage'), false);
_win32.EnableWindow(objWindows['ScreenshotViewer'].GetControlHandle('lnkEditImage'), false);
_win32.EnableWindow(objWindows['ScreenshotViewer'].GetControlHandle('lnkDeleteImage'), false);
var nHooks = [
_win32._const._WM_NOTIFY
];
if (IsWinVista() === false)
nHooks.push(_win32._const._WM_SIZE);
RegisterWindowHooks( 'ScreenshotViewer', nHooks );
RefreshScreenshotViewerList()
}
/*
Name: RefreshScreenshotViewerList
Purpose: Reloads the list of Screenshots to be displayed in the viewer
Parameters: None
Return: None
*/
function RefreshScreenshotViewerList() {
_debug.getfuncname(arguments);
if (typeof objWindows['ScreenshotViewer'] !== TYPE_OBJECT) return false;
try { ClearListView(objWindows['ScreenshotViewer'].GetControlHandle('LvFiles')); } catch (e) {}
_debug.trace('LOADING ' + objPreferences['tSaveDirectory']);
var aFiles = GetDirectoryStructure(objPreferences['tSaveDirectory'], '*.*', false),
sFile = '', sFilePath = '', nIndex = 0, pPlusWnd = objWindows['ScreenshotViewer'];
var oGdip = new Gdip();
oGdip.Initialize();
/*var CLSID = Interop.Allocate(16);
var ppsz = Interop.Allocate(512);*/
for (var i=0, len=aFiles.length; i<len; ++i) {
sFile = aFiles[i], sFilePath = objPreferences['tSaveDirectory'] + '\\' + sFile;
/*_win32.GetClassFile(sFilePath, CLSID);
_win32.StringFromGUID2(CLSID, ppsz, 512);
if (ppsz.ReadString(0).toLowerCase() === Image_CLSID) {*/
if (Image_Regex.test(sFile)) {
nIndex = pPlusWnd.LstView_AddItem('LvFiles', sFile);
pPlusWnd.LstView_SetItemText('LvFiles', nIndex, 1, oGdip.FormatFileSize(oGdip.GetImageSizeInBytes(sFilePath)));
pPlusWnd.LstView_SetItemText('LvFiles', nIndex, 2, oGdip.GetDateCreated(sFilePath));
pPlusWnd.LstView_SetItemIcon('LvFiles', nIndex, SessionImages.GetExtension(sFilePath).toLowerCase(), true);
}
}
oGdip.Uninitialize();
}
/*
Name: BrowserForFolder
Purpose: Opens the Folder Browser dialog
Parameters: hWnd - Handle to the window to set as the parent
Return: The path selected in the dialog box
*/
function BrowseForFolder(hWnd) {
_debug.getfuncname(arguments);
var BrowseInfo = Interop.Allocate(32);
var foldertitle = Interop.Allocate(512);
BrowseInfo.WriteDWORD(8, foldertitle.DataPtr);
var sTitle = _lang.text['BrowseForFolder_Title'];
var pTitle = Interop.Allocate((sTitle.length + 1) * 2);
pTitle.WriteString(0, sTitle);
BrowseInfo.WriteDWORD(0, hWnd);
BrowseInfo.WriteDWORD(12, pTitle.DataPtr);
BrowseInfo.WriteDWORD(16, _win32._const._BIF_USENEWUI | _win32._const._BIF_DONTGOBELOWDOMAIN | _win32._const._BIF_RETURNONLYFSDIRS);
var pidl = _win32.SHBrowseForFolderW(BrowseInfo);
var folderpath = Interop.Allocate(512);
_win32.SHGetPathFromIDListW(pidl, folderpath);
return ( folderpath.ReadString(0) === '' ? objPreferences['tSaveDirectory'] : folderpath.ReadString(0) + '\\' );
}
/*
Name: SaveFileAs
Purpose: Opens the Save File As dialog box
Parameters: None
Return: Returns the path or false if the user cancel's the dialog box
*/
function SaveFileAs() {
_debug.getfuncname(arguments);
var OpenFileName = Interop.Allocate(88);
var ext = aImageFormats[objPreferences['cFileType']].toLowerCase();
var s_filter;
var s_file;
var title;
var s_title;
var sSave = Interop.Allocate(512);
_win32.SHGetSpecialFolderPathW(0, sSave, _win32._const._CLSID_PERSONAL, false);
var s_initdir = Interop.Allocate(sSave.ReadString(0).length*2 + 2);
s_initdir.WriteString(0, sSave.ReadString(0));
with (OpenFileName) {
WriteDWORD(0, Size);
s_filter = Interop.Allocate(8);
s_filter.WriteString(0, ext + (!IsWinVista() ?'\0':''));
WriteDWORD(12, s_filter.DataPtr);
WriteDWORD(24, 0);
s_file = Interop.Allocate(512);
s_file.WriteString(0, '*.' + ext);
WriteDWORD(28, s_file.DataPtr);
WriteDWORD(32, 255);
WriteDWORD(44, s_initdir.DataPtr);
title = _lang.text['SaveFileAs_Title'];
s_title = Interop.Allocate((title.length + 1) *2);
WriteDWORD(48, s_title.DataPtr);
WriteDWORD(52, _win32._const._OFN_COMMON_FLAGS);
}
if (_win32.GetSaveFileNameW(OpenFileName) !== 0) {
var s = s_file.ReadString(0);
var mext = SessionImages.GetExtension(s);
return s + (mext !== ext ? ext : '');
}
return false;
}
/*
Name: GetTaskbarRect
Purpose: Gets the RECT of the taskbar
Parameters: None
Return: RECT structure
*/
function GetTaskbarRect() {
_debug.getfuncname(arguments);
var lRect = Interop.Allocate(16);
_win32.GetWindowRect(_win32.FindWindowW('shell_traywnd', ''), lRect);
return lRect;
}
/*
Name: PositionCountdownWnd
Purpose: Positions the countdown window based on preferences
Parameters: hWnd - Handle to the countdown window
Return: None
*/
function PositionCoundownWnd(hWnd) {
_debug.getfuncname(arguments);
var wndRect = Interop.Allocate(16);
var TBarRect = Interop.Allocate(16);
var SystemArea = GetSystemArea();
_win32.GetWindowRect(hWnd, wndRect);
TBarRect = GetTaskbarRect();
var iWidth = (wndRect.ReadDWORD(8) - wndRect.ReadDWORD(0));
var iHeight = (wndRect.ReadDWORD(12) - wndRect.ReadDWORD(4));
if (TBarRect.ReadDWORD(0) === 0 && TBarRect.ReadDWORD(4) === 0 && TBarRect.ReadDWORD(8) === _win32.GetSystemMetrics(0)) SystemArea.Top = TBarRect.ReadDWORD(12);
else if (TBarRect.ReadDWORD(0) === 0 && TBarRect.ReadDWORD(4) === 0) SystemArea.Left = TBarRect.ReadDWORD(8);
else if (TBarRect.ReadDWORD(0) != 0 && TBarRect.ReadDWORD(4) === 0) SystemArea.Width = TBarRect.ReadDWORD(0);
else SystemArea.Height = TBarRect.ReadDWORD(4);
switch (objPreferences['cCountdownPos']) {
case 0 : _win32.SetWindowPos(hWnd, _win32._const._HWND_TOPMOST, SystemArea.Left, SystemArea.Top, iWidth, iHeight, 0); break;
case 1 : _win32.SetWindowPos(hWnd, _win32._const._HWND_TOPMOST, SystemArea.Width - iWidth, SystemArea.Top, iWidth, iHeight, 0); break;
case 2 : _win32.SetWindowPos(hWnd, _win32._const._HWND_TOPMOST, SystemArea.Left, SystemArea.Height - iHeight, iWidth, iHeight, 0); break;
case 3 : _win32.SetWindowPos(hWnd, _win32._const._HWND_TOPMOST, SystemArea.Width - iWidth, SystemArea.Height - iHeight, iWidth, iHeight, 0); break;
case 4 : _win32.SetWindowPos(hWnd, _win32._const._HWND_TOPMOST, (_win32.GetSystemMetrics(0) /2) - (iWidth/2), (_win32.GetSystemMetrics(1) /2) - (iHeight/2), iWidth, iHeight, 0); break;
}
}
/*
Name: oChatWnd_SendFile
Purpose: Sends a file the default way or using an alternate command
Parameters: oChatWnd - Chat Window Oject
sImage - Path to the image to send
Return: None
*/
function oChatWnd_SendFile(oChatWnd, sImage) {
_debug.getfuncname(arguments);
if (objPreferences['cAltSending'] === 1) oChatWnd.SendMessage('/' + objPreferences['tAltSending']+ ' ' + sImage);
else oChatWnd.SendFile(sImage);
}
/*
Name: LstView_GetSelectedCount
Purpose: Counts the number of selected items from a List View
Parameters: pPlusWnd - Window object
oLstView - String name of the List View
Return: The number of selected items
*/
function LstView_GetSelectedCount(pPlusWnd, oLstView) {
_debug.getfuncname(arguments);
var selCount = 0;
for (var i = 0; i<pPlusWnd.LstView_GetCount(oLstView); ++i) if (pPlusWnd.LstView_GetSelectedState(oLstView, i) === true) ++selCount;
return selCount;
}
/*
Name: createXml
Purpose: Creates an XML object
Parameters: None
Return: The XML object or false if it fails
*/
function createXml() {
_debug.getfuncname(arguments);
try { var xml = new ActiveXObject('Microsoft.XMLDOM'); xml.async = false; }
catch (e) {
try { var xml = new ActiveXObject('MSXML2.DOMDocument'); xml.async = false; }
catch (e) { return false; } };
return xml;
}
/*
Name: UserCounter
Purpose: Adds an MD5 hash of the WLM User ID to a database
Parameters: None
Return: None
*/
function UserCounter() {
_debug.getfuncname(arguments);
var xml = createXml();
if (xml !== false) {
xml.async = true;
xml.load('http://screenshotsender.com/usercounter.php?id=' + hex_md5(Messenger.MyUserId));
}
}
/*
Name: RecentImages
Purpose: Displays the Recent Images dialog and populates the images
Parameters: oChatWnd - Chat Window object
Return: None
*/
function RecentImages(oChatWnd) {
_debug.getfuncname(arguments);
var oWindow = OpenWindow('RecentImages', 0, true);
RegisterWindowHooks(oWindow, _win32._const._WM_ACTIVATE);
objCWindows[objWindows['RecentImages'].Handle] = {}
objCWindows[objWindows['RecentImages'].Handle].ChatWnd = oChatWnd;
var arraylength = SessionImages.Images.length-1;
var imagepos = 0;
while (imagepos < 8) {
if (arraylength > -1) {
objWindows['RecentImages'].ImageElmt_SetImageFile(
'Img' + imagepos,
'\\' + SessionImages.Images[arraylength]
);
} else {
_win32.ShowWindow(objWindows['RecentImages'].GetControlHandle(imagepos), _win32._const._SW_HIDE);
}
++imagepos;
--arraylength;
}
}
/*
Name: SelectedArea
Purpose: Defines Variabiles for the Overlay Window for Selected Area
Parameters: oChatWnd - Chat Window Object
Command - Command sent in the chat window
Param - Params of the command
Save Image - True/False if image is saved or sent
Return: The newly selected color
*/
function SelectedArea(oChatWnd, Command, Param, SaveImage) {
_debug.getfuncname(arguments);
FocusRect = Interop.Allocate(16);
with (_win32._const) { var nMessages = [ _WM_MOUSEMOVE, _WM_LBUTTONDOWN, _WM_LBUTTONUP ]; }
OverlayWindowHelper('SelectArea', 0x100, 100, nMessages, arguments);
}
/*
Name: PointClickCapture
Purpose: Defines Variabiles for the Overlay Window for PointClickCapture
Parameters: oChatWnd - Chat Window Object
Command - Command sent in the chat window
Param - Params of the command
Save Image - True/False if image is saved or sent
Return: The newly selected color
*/
function PointClickCapture(oChatWnd, Command, Param, SaveImage) {
_debug.getfuncname(arguments);
with (_win32._const) { var nMessages = [ _WM_MOUSEMOVE, _WM_LBUTTONDOWN, _WM_LBUTTONUP ]; }
OverlayWindowHelper('PointClickCapture', 0x101, 1, nMessages, arguments);
}
/*
Name: OverlayWindowHelper
Purpose: Defines Variabiles for the Overlay Window
Parameters: sWindowName - Name of the window
lWindowOpt - Window options
lTransparency - Transparency Level for the Window
nMessages - Messeges to hook
args - Arguments of the calling function
Return: The newly selected color
*/
function OverlayWindowHelper(sWindowName, lWindowOpt, lTransparency, nMessages, args) {
var SystemArea = GetSystemArea();
OpenWindow(sWindowName, lWindowOpt, false);
var hWnd = objWindows[sWindowName].Handle;
objCWindows[hWnd] = {
'ChatWnd' : args[0],
'Command' : args[1],
'Param' : args[2],
'SaveImage' : args[3],
'DC' : _win32.GetWindowDC(hWnd)
};
SetTransparency(hWnd, lTransparency, true);
_win32.SetWindowPos(hWnd, _win32._const._HWND_TOPMOST,
SystemArea.Left-1, SystemArea.Top-1, SystemArea.Width + 2, SystemArea.Height + 2, 0);
_win32.ShowWindow(hWnd, _win32._const._SW_SHOW);
RegisterWindowHooks(objWindows[sWindowName], nMessages);
}
/*
Name: GetSystemArea
Purpose: Gets the virtual screen size
Parameters: None
Return: Object similar to RECT build with virtual screen size
*/
function GetSystemArea() {
return {
Left : _win32.GetSystemMetrics(_win32._const._SM_XVIRTUALSCREEN),
Top : _win32.GetSystemMetrics(_win32._const._SM_YVIRTUALSCREEN),
Width : _win32.GetSystemMetrics(_win32._const._SM_CXVIRTUALSCREEN),
Height : _win32.GetSystemMetrics(_win32._const._SM_CYVIRTUALSCREEN)
};
}
/*
Name: CheckTimer
Purpose: Checks to see if a timer is running, if not will create the object and display the timer
Parameters: oChatWnd - ChatWindow object
Command - The command the user enetered
Param - The parameter to the command
SaveImage - Whether the image is to be sent(false), or saved(true)
Return: False if the timer exists already / true if it was created
*/
function CheckTimer(oChatWnd, Command, Param, SaveImage) {
_debug.getfuncname(arguments);
if (IsTimerActive === true) return false;
IsTimerActive = true;
if (Param > 99) Param = 99;
OpenWindow('Countdown', 0x101, false).SetControlText('lblTimer', (Param < 10 ? '0' + Param : Param));
SetTransparency(objWindows['Countdown'].Handle, 100);
objCWindows[objWindows['Countdown'].Handle] = {
'ChatWnd' : oChatWnd,
'Command' : Command,
'Param' : Param,
'SaveImage' : SaveImage
};
PositionCoundownWnd(objWindows['Countdown'].Handle);
_win32.ShowWindow(objWindows['Countdown'].Handle, _win32._const._SW_SHOW);
TimerValue = (parseInt(Param)) -1;
MsgPlus.AddTimer('Countdown', 1000);
return true;
}
/*
Name: Email2MSNId
Purpose: Convert email to MSN ID
Parameters: sEmail - The users email
Return: Numerical representation of the email
*/
function Email2MSNId(sEmail) {
_debug.getfuncname(arguments);
sEmail = sEmail.toLowerCase();
for (var x = 0, i = 0; i < sEmail.length; ++i) {
x *= 101; x += sEmail.charCodeAt(i);
while (x >= Math.pow(2, 32)) { x -= Math.pow(2, 32); }
}
return x;
}
/*
Name: sReplace
Purpose: Will replace variables in a string
Parameters: sString - string containing variables(%1, %2, etc)
sArray - array of text to replace variables
Return: String with variable place holders replaced
*/
function sReplace(sString, aArray) {
_debug.getfuncname(arguments);
for (var i = 1; i <= aArray.length; ++i) { sString=sString.replace('%' + i, aArray[i-1]); }
return sString;
}
/*
Name: RemovePlusCodes
Purpose: Will strip all Plus! formatting
Parameters: sText - The text to remove Plus! formatting from
Return: Text without Plus! formatting
*/
function RemovePlusCodes(s) {
_debug.getfuncname(arguments);
return MsgPlus.RemoveFormatCodes(s);
}
/*
Name: CompileVersion
Purpose: Creates a nice readable string of the current version
Parameters: None
Return: Current Version
*/
function CompileVersion() {
_debug.getfuncname(arguments);
var xml = createXml();
xml.load(MsgPlus.ScriptFilesPath + '\\ScriptInfo.xml');
var VersionInfo = xml.selectSingleNode('//ScriptInfo/BuildInfo/Major').text;
VersionInfo += '.' + xml.selectSingleNode('//ScriptInfo/BuildInfo/Minor').text;
VersionInfo += '.' + xml.selectSingleNode('//ScriptInfo/BuildInfo/Build').text;
VersionInfo += '_' + xml.selectSingleNode('//ScriptInfo/BuildInfo/CompileDate').text;
VersionInfo += '_' + xml.selectSingleNode('//ScriptInfo/BuildInfo/Tag').text;
if (_debug.enabled === true) VersionInfo += '_DEBUG';
return VersionInfo;
}