Click here to Skip to main content
15,894,460 members
Articles / Programming Languages / C#

Events Manager: A Vista Gadget

Rate me:
Please Sign up or sign in to vote.
4.35/5 (28 votes)
2 Feb 20076 min read 91.9K   2.6K   55  
An events manager gadget for Windows Vista
// JScript File
// Load events and display them
function LoadEvents()
{    
    ClearEventsList();
    for(i = 0, j=0; j<EventsNumber; i++)
    {
        if(System.Gadget.Settings.read("Event"+i+"Id")==i)
        {
            j++;
            AddLineToEventsList(i);
        }
    }
}
function AddLineToEventsList(eventId)
{
    var eventsList = document.getElementById("EventsList"); 
    var divTag = document.createElement("div");
    var anchorTag = document.createElement("a");
    var radical = "Event" + eventId;
    var eventName = System.Gadget.Settings.read(radical + "Name");
        
    // arguments are used when user is searching
    // (see SearchEngine.js for more details
    var highlight = arguments[1];
    var start = arguments[2];
    var end = arguments[3];
    
    // CheckEvent set event's notification info
    // return false if the event is too old and should not be displayed    
    if(!CheckEvent(eventId)) return;
    
    anchorTag.setAttribute("href", "javascript:DisplayEventInfo(" + eventId + ");");
    anchorTag.setAttribute("title", eventName);
    // highlight text in search-mode only
    if(highlight)
    {
        anchorTag.innerHTML = eventName.substring(0, start) + 
                                 "<span class=\"selected\">" + eventName.substring(start, end) + "</span>" +
                                    eventName.substring(end);
                                
    }
    else anchorTag.innerHTML = eventName;

    // depending of the event's state, set the correct class name
    switch(System.Gadget.Settings.read(radical + "State"))
    {
        case "Hot" :
        // to notify user
            divTag.className = "hotEvent";
            // play sound only if EnableSound == true
            if(EnableSound) System.Sound.playSound("../sound/toutoune.wav");
            break;
        case "Old" :
            anchorTag.className = "oldEvent";
            break;
    }
    // appendChild
    divTag.appendChild(anchorTag);
    eventsList.insertBefore(divTag, eventsList.firstChild);
}
function ClearEventsList()
{
    // clear events list
    document.getElementById("EventsList").innerHTML = "";
}

// Called by AddEvent in AddEvent.js
function AddEvent()
{   
    EventsNumber++;
    CurrentEventId++;
    SaveSettings();
    
    LoadEvents();
    SetSlider();
    UpdateSliderInput();
}
function RemoveEvent(eventId)
{
    EventsNumber--;
    System.Gadget.Settings.write("Event"+eventId+"Id", -1);
    HideEventInfo();
    SaveSettings();
    
    LoadEvents();
    UpdateSliderInput();
    SetSlider();
}


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions