locked
problem with my contacts RRS feed

  • Question

  • hi, i have a web page with my own user image and my online contacts and their images.

    when the contact is logged in trough my web page their is no problem,but when my contact(s) are logged in with live messenger itself i have a problem.

    i use this function to display my contacts picture,  onUserPresenceChangedCallback.now the problem is every time this function is called and one of my contacts is logged in trough live messenger then the image of that contact is starting on a new line instead of the (div) where the picture is.

    So how can i get this function to update my div instead of putting it on a newline.

    when the contact is logged trough my web page there is no problem in updating the div.

    any suggestions.

    grt robert

    Tuesday, July 12, 2011 10:17 AM

All replies

  • let me explain a little bit,

    i use this function to retrieve all my contacts with their picture:

    function onContactPresenceChangedCallback(cid, name, value) {
    //$get('Output').innerHTML += "<table><tr><td style=\"position:float;top:290px;left:200px;display: inline;\">";
      // names and values are  Microsoft.Live.Messenger.ContactPresence properties
        displayValue = value;
        onlineContacts[i] = messengerContext.findContact(cid).get_cid();
        if (typeof (value) == "number")
        {
            displayValue = Microsoft.Live.Messenger.PresenceStatus.toString(value);
        w = displayValue;
       if(w == 'appearOffline')
        {
          document.getElementById('Output').style.border = '4px solid #ffffff';
        }
       if(w == "online")
        {
          document.getElementById('Output').style.border = '4px solid #66ff00';
        }
       if(w === 'busy')
        {
          document.getElementById('Output').style.border =  '4px solid #ff0000';
        }
       if(w == "away")
        {
          document.getElementById('Output').style.border = '4px solid #ffff00';
        }
    }
     
        if (name === "DisplayPictureUrl"){
           

     

     

         document.getElementById('Output').innerHTML += "<div id='" + onlineContacts[i] + "'><img  name='" + onlineContacts[i] + "' src='" + displayValue + "' onclick='reply_click(this.name)' height='55px' width='55px'/></div><br/><br/><br/>";// + Microsoft.Live.Messenger.PresenceStatus.toString(value) + '.';
    $get('Output').innerHTML += onlineContacts[i];

       // $get('Output').innerHTML += displayValue;
          //namecid = this.name;
         //alert(namecid);
         
          displayValue = new displayValue;
         //name = messengerContext.findContact(cid).get_firstName();
            //   
        }
        else
        {
           // $get('Output').innerHTML += nme + ": <img src='" + displayValue + "' alt='thumbnail' width='25px'/><br/>" + displayValue + "<br/>";
        }
            $get('Output').innerHTML += "";

        if(i == "1")
        $get('Output').innerHTML += "1e   keer   ";
         if(i == "2")
        $get('Output').innerHTML += "2e   keer   ";
      
        i++;

    $get('Output').innerHTML += "</td></tr></table>";

    }

    now the thing i don't understand is this when a contact change his status the border color of his picture changes to another color,now this is working the way it suppose to, it stay at one place on the screen but the picture is showing on a new position under my contact picture.

    so the border stay at the same place but the picture is duplicated.

    so after a couple of minutes i have lets say 4 images of the same contact under eachother.

    so how can i change it so my picture stay at the same place.

    the code at the end of the function is for debugging purpose.

    grt robert

     

    Monday, July 18, 2011 7:32 AM
  • no one with an answer?

     

    i tried it now with making dynamic div's for each picture.

    the div's are made but i cant get it to work like i want to.

    can i use the onContactPresenceChangedCallback function to retrieve all off my contacts with their pictures, put them in a array and call a function to put all of my contacts pictures in the dynamically made div's.

    what i understand is that this function is called every time a contact change their status and the function itself checks the state of the contacts

    after a certain amount of time elapsed( is that correct?).

    i hope this is simpler to answer.

    grt rob

    Thursday, July 21, 2011 4:33 PM
  • this is why i hate msdn forum and code explanation.

    you have to wait weeks for getting an answer if you even got one and the code tutorial laks.

    pffffffffffffffffffff.

     

    Sunday, July 24, 2011 12:50 PM
  • ok i solved it myself , so for anyone who needs it.

    any suggestions are welcome:

    function onContactPresenceChangedCallback(cid, name, value) {
    
    // object(pointer) voor de switch
    
    var cidd = messengerContext.findContact(cid);
    
    // cid nummers voor de te creeeren cid's
    
    contact = cid;
    
    // variabel(object) voor de styletags van de te creeeren div 
    
    var divTag = document.createElement("div"); 
    
    displayValue = value;
    
    if (name === "DisplayPictureUrl"){
         
    // kijk of de array al gemaakt is zoja doe niks.
    
    if(document.getElementById('div'+cid)) 
    {
    
    }
    else // array is niet gemaakt dus maak het aan.
    {
    
    // zet de image van elke contact in de array contactarray (onclick heeft geen functie meer).
    
    contactarray[i] = "<img name='" + i + "' src='" + displayValue + "' onclick='reply_click(this.name)' height='55px' width='55px'/>";// + Microsoft.Live.Messenger.PresenceStatus.toString(value) + '.';
       	 
    // maak voor elk contact een nieuwe div aan met de attributen die hieronder staan.
    
       	 divTag.id = "div"+contact;											// contact bevat het cid nummer van de contactpersoon.
        //divTag.setAttribute("align","center");
       	 //divTag.style.position = "absolute";        
       	 divTag.style.margin = "0px auto";        
       	 //divTag.style.top = r;// + "100px";
       	 divTag.style.width = "55px";
       	 divTag.style.height = "55px";
       	 divTag.style.border = "4px solid #88cc00";
       	 divTag.className ="dynamicDiv";        
       	 divTag.innerHTML = contactarray[i] + divTag.id;  // zet de foto als inhoud van de aan te maken div.
    // maak div.
    
    		 document.body.appendChild(divTag);		  
    
    // deze switch zorgt ervoor dat de status van elk contact bekeken en weergegeven wordt bij het aanmelden.
    
    switch (cidd.get_presence().get_status()) {
            case Microsoft.Live.Messenger.PresenceStatus.offline:
              document.getElementById('div'+contact).style.border = '4px solid #ffffff';
              break;
            case Microsoft.Live.Messenger.PresenceStatus.online:
              document.getElementById('div'+contact).style.border = '4px solid #66ff00';
    
              break;
            case Microsoft.Live.Messenger.PresenceStatus.away:
              document.getElementById('div'+contact).style.border = '4px solid #ffff00';
    
              break;
            case Microsoft.Live.Messenger.PresenceStatus.busy:
              document.getElementById('div'+contact).style.border = '4px solid #ff0000';
    
              break;
             
            default:
              
              break;
          }
      }
     
    }  
    // deze zorgt ervoor dat als de status veranderd van een contact dit ook wordt weergegeven. 
      
    if (typeof (value) == "number") 
      {
        displayValue = Microsoft.Live.Messenger.PresenceStatus.toString(value);
     			w = displayValue;
    			if(w === "offline" || w === "Offline" || w === "appearOffLine")
    				{  	 
    			$get('div'+cid).style.border = '4px solid #ffffff';
    			document.getElementById('Output').innerHTML = "offline";
    				} else {
    			if(w === 'online')
    				{
    						$get('div'+cid).style.border = '4px solid #66ff00';
    			document.getElementById('Output').innerHTML = "online";
    				} else {
    			if(w === "busy")
    				{
    						$get('div'+cid).style.border = '4px solid #ff0000';
    			document.getElementById('Output').innerHTML = "bezig";
    				} else {
    			if(w === "away")
    				{
    						$get('div'+cid).style.border = '4px solid #ffff00';
    			document.getElementById('Output').innerHTML = "afwezig";
    				}
    			} // einde 3e else
    			} // einde 2e else			 
    			} // einde 1e else
    	}
    	
    	
      if(i == "1")
      $get('Output').innerHTML = "1e  keer  ";
       if(i == "2")
      $get('Output').innerHTML = "2e  keer  ";
     
     
      i++; 
    
    }
    

     

    Wednesday, July 27, 2011 9:29 AM