home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2006 October
/
PCWorld_2006-10_cd.bin
/
komunikace
/
icqstatus
/
icqstatp107b.exe
/
DATA
/
136
< prev
next >
Wrap
Text File
|
2006-09-05
|
8KB
|
230 lines
// Global veriables --------------------------------------------------------------------------------------------
var gl_row_id = 0;
var gl_num_of_icons = 31
var gl_icons_in_row = 6;
var gl_num_of_text_rows = 5;
var browser = navigator.userAgent.toLowerCase();
if(browser.indexOf("msie 6")!=-1 || browser.indexOf("msie 7")!=-1 || browser.indexOf("msie 8")!=-1) ie6=1; // IE6 Sniffer
else ie6=0;
function init()
{
var xmlLineData = loadFromClient();
if(xmlLineData)
setToForm(xmlLineData);
document.getElementById('preloader').style.display = "none";
mainDiv.style.display = "block";
disableApplyButton(true);
}
function wait(on)
{
apply_btn.disabled = on
ok_btn.disabled = on
if(on) document.body.style.cursor = "wait";
else document.body.style.cursor = "auto";
}
// Get the name of the gif icon from the full path---------------------------------------------------------
function getNameFromPath(path){
var endPoint = path.indexOf(".gif");
var startPoint = 0;
for(j = endPoint; j>0 ; j--){
if(path.charAt(j) == '/') {
startPoint = j + 1;
return path.substring(startPoint,endPoint);
}
}
}
// Load data from the Client to a temp XML -----------------------------------------------------------------
function loadFromClient()
{
var req = "<Q><PluginID>Client</PluginID><SrvID>CASXtraRetrieveData</SrvID><UserID>"+ top.icqConnector.GetIMOwnerData('SCREEN_NAME') +"</UserID></Q>";
var quer = "<Root><CASXtraRetrieveData></CASXtraRetrieveData></Root>"
var xmlLineData = false
try {xmlLineData = top.icqConnector.NotifyPlugin(req,quer);} // indicates that it was operated befor
catch(e){;trace(e,"CASXtraRetrieveData");}
var xmlDoc = new ActiveXObject("Msxml.DOMDocument");
xmlDoc.async = false;
var res = xmlDoc.loadXML(xmlLineData);
if(!res) return false
try{
res = xmlDoc.loadXML(xmlDoc.selectSingleNode("//RES").text);
}
catch(e){
//top.trace(e,"loadFromClient")
return false
}
return xmlDoc
}
// inserting data from temp XML to the form --------------------------------------
function setToForm(xmlDoc)
{
var xmlLineData = xmlDoc.getElementsByTagName("Row");
for(var i=0 ; i<xmlLineData.length ; i++)
{
try{
var lineNum = eval(xmlLineData[i].selectSingleNode("LineNumber").text) -1;
var iconIndex = eval(xmlLineData[i].selectSingleNode("iconIndex").text) -1;
document.frm["c" + lineNum].disabled = false
if(eval(xmlLineData[i].selectSingleNode("On").text))
document.frm["c" + lineNum].checked = true;
document.frm["i" + lineNum].src = "icons/" + iconIndex + ".gif";
document.frm["n" + lineNum].value = unescape(xmlLineData[i].selectSingleNode("Name").text);
document.frm["t" + lineNum].value = unescape(xmlLineData[i].selectSingleNode("Description").text);
}
catch(e){
top.trace(e,"setToForm")
}
}
}
// Main (parent) save data function -------------------------------------------------------------------------------------
function save(saveType)
{
var lineData = collectCurrentData(); // Collecting the data from the form elements
setCurrentStatus(lineData); // Changing the current state of the status indicator on contact list
if(saveType == "ok") top.icqConnector.ClosePluginUISite();
}
// Collecting the data from the form elements----------------------------------------------------------------
function collectCurrentData(){
var formElements = new Object(document.frm)
var results = new Array;
var row = 0 ;
for ( i = 0; i< formElements.length; i++ ) {// All the inputs in the form
if(formElements[i].type=="checkbox") {// if an input is a checkbox then it's a strat of a row
results[row] = new Array;
results[row]["on"] = formElements[i].checked; //checked ?
results[row]["index"] = row+1; // row number
results[row]["iconIndex"] = getNameFromPath(document.getElementById('i'+row).src); // image number
results[row]["name"] = formElements[i+1].value; // Name
results[row]["text"] = formElements[i+2].value; // Away text
row = row + 1;
}
}
return results;
}
function addElement(root,tagName,value)
{
var lXml = top.getXml(false)
newElemet = lXml.createElement(tagName);
if(!top.isEmpty(value))
newElemet.text = value;
root.appendChild(newElemet);
return newElemet
}
// Changing the current state of the status indicator on contact list -------------------------------------
function setCurrentStatus(data)
{
var req = "<Q><PluginID>Client</PluginID><SrvID>CASXtraPrefsSet</SrvID><UserID>"+ top.icqConnector.GetIMOwnerData('SCREEN_NAME') +"</UserID></Q>";
var quer ="<Root><CASXtraPrefsSet></CASXtraPrefsSet>";
var xmlDoc = top.getXml(false)
var root = xmlDoc.createElement("Root");
for(var i=0;i<data.length;i++)
{
var ind = isNaN(data[i]['iconIndex'])? -1:(parseInt(data[i]['iconIndex']) + 1);
if (ind > -1)
{
var on = (data[i]['on'])? "true":"false";
var Row = addElement(root,"Row");
addElement(Row,"iconIndex", ind)
addElement(Row,"Name", data[i]['name'] )
addElement(Row,"Description", data[i]['text'] )
addElement(Row,"On", on )
addElement(Row,"LineNumber", data[i]['index'] )
}
}
try{
top.icqConnector.NotifyPlugin(req,root.xml)
}
catch(e){
trace(e,"setCurrentStatus Error")
}
// Disabling the apply button
disableApplyButton(true);
}
// Showing the table of icons --------------------------------------------------------------------
function showMatix(id){
gl_row_id = id;
var rows =new Array();
rows = collectCurrentData();
for(i=0 ; i<=gl_num_of_icons ; i++){
document.getElementById('m'+i).style.filter = "";
document.getElementById('m'+i).style.cursor = "hand";
document.getElementById('m'+i).active = "true";
}
for(i=0 ; i<=gl_num_of_icons ; i++){
for(j=0 ; j<rows.length ; j++){
if(rows[j]["iconIndex"]== i) {
if(ie6) {
document.getElementById('m'+i).style.filter = "progid:DXImageTransform.Microsoft.BasicImage( Rotation=0,Mirror=0,Invert=0,XRay=0,Grayscale=1,Opacity=0.40)";
document.getElementById('m'+i).style.cursor = "arrow";
}
else
document.getElementById('m'+i).style.filter = "gray()";
document.getElementById('m'+i).active = "false";
}
}
}
if(event.clientY<225){
document.getElementById('matrix').style.top = event.clientY + document.body.scrollTop;
document.getElementById('m-shadow').style.top = event.clientY + document.body.scrollTop + 3;
}
else {// if cursor is too close to the bottom of the page
document.getElementById('matrix').style.top = event.clientY + document.body.scrollTop - 100;
document.getElementById('m-shadow').style.top = event.clientY + document.body.scrollTop + 3 -100;
}
document.getElementById('matrix').style.left = event.clientX + document.body.scrollLeft;
document.getElementById('m-shadow').style.left = event.clientX + document.body.scrollLeft + 3;
}
// hiding the table of icons -------------------------------------------------
function hideMatrix(){
document.getElementById('matrix').style.top = "700px";
document.getElementById('m-shadow').style.top = "700px";
}
// Inserting the selected icon to the proper row ------------------------
function switchIcon(iconId){
if(document.getElementById('m'+iconId).active == "true")
{
document.frm["c" + gl_row_id.substr(1)].disabled = false
document.getElementById(gl_row_id).src= "icons/" + iconId + ".gif";
hideMatrix();
disableApplyButton(false);
}
}
// Texterea character limit
function textCounter(obj, maxlimit) {
if (obj.value.length > maxlimit) obj.value = obj.value.substring(0, maxlimit);
disableApplyButton(false);
}
// Apply button change state
function disableApplyButton(mode){
document.getElementById('apply_btn').disabled = mode;
}
function hndlClick()
{
if(event.srcElement.type != "text" && event.srcElement.type != "textarea" )
return false;
}
document.oncontextmenu = hndlClick