Main and secondary gadget code
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
    <ModulePrefs     title="&#1506;&#1499;&#1489;&#1512; &#1492;&#1506;&#1497;&#1512;: &#1488;&#1497;&#1512;&#1493;&#1506;&#1497; &#1492;&#1497;&#1493;&#1501;" 
                    title_url="http://www.mouse.co.il/"
                    height="160" 
                    author="Gal&#x26;Yuval" 
                    author_email="galyuval@gmail.com" > 
            <Require feature="dynamic-height" />
    </ModulePrefs>
    <UserPref     name="test000" 
                display_name="&#1489;&#1495;&#1512; &#1488;&#1494;&#1493;&#1512;" 
                default_value="&#1514;&#1500; &#1488;&#1489;&#1497;&#1489;" 
                datatype="enum" 
                publish="true" >
        <EnumValue value="1" display_value="&#1514;&#1500; &#1488;&#1489;&#1497;&#1489;" />
        <EnumValue value="2" display_value="&#1488;&#1494;&#1493;&#1512; &#1492;&#1502;&#1512;&#1499;&#1494;" />
        <EnumValue value="3" display_value="&#1495;&#1497;&#1508;&#1492; &#1493;&#1492;&#1510;&#1508;&#1493;&#1503;" />
        <EnumValue value="4" display_value="&#1488;&#1494;&#1493;&#1512; &#1492;&#1491;&#1512;&#1493;&#1501;" />
        <EnumValue value="5" display_value="&#1497;&#1512;&#1493;&#1513;&#1500;&#1497;&#1501; &#1493;&#1492;&#1505;&#1489;&#1497;&#1489;&#1492;" />
    </UserPref> 
    <UserPref name="selectedTab" datatype="hidden"/>
    <Content type="html"> <![CDATA[ 
        <div id="main_tab">
            <div id="content_div1" style="font-size:10pt; padding:5px; direction:rtl; background-color: #FFFFBF" >
                <b>&#1489;&#1495;&#1512; &#1488;&#1494;&#1493;&#1512;:</b>
                    <table>
                        <tr> 
                            <td>
                                <select id="area" name="area" >
                                    <option value ="1">&#1514;&#1500; &#1488;&#1489;&#1497;&#1489;</option>
                                    <option value ="2">&#1488;&#1494;&#1493;&#1512; &#1492;&#1502;&#1512;&#1499;&#1494;</option>
                                    <option value ="3">&#1495;&#1497;&#1508;&#1492; &#1493;&#1492;&#1510;&#1508;&#1493;&#1503;</option>
                                    <option value ="4">&#1488;&#1494;&#1493;&#1512; &#1492;&#1491;&#1512;&#1493;&#1501;</option>
                                    <option value ="5">&#1497;&#1512;&#1493;&#1513;&#1500;&#1497;&#1501; &#1493;&#1492;&#1505;&#1489;&#1497;&#1489;&#1492;</option>
                                </select>
                            </td>
                        <td>
                            <input type="button" name="butUpdate" name="butUpdate" value="&#1506;&#1491;&#1499;&#1503;" onclick="updateValue()">
                        </td>
                    </tr>
                </table>
                <table>
                    <tr>
                        <td style="font-size:10pt; direction: rtl; width: 90px"> 
                            &#1488;&#1497;&#1512;&#1493;&#1506;&#1497;&#1501; &#1502;&#1497;&#1493;&#1495;&#1491;&#1497;&#1501;
                        </td>
                        <td>
                            <div id="eventCount1" style="font-size:10pt; direction:rtl">0</div>
                        </td>
                        <td style="width: 40px"/>
                        <td style="font-size:10pt; direction: rtl; width: 85px"> 
                            &#1492;&#1510;&#1490;&#1493;&#1514; &#1514;&#1497;&#1488;&#1496;&#1512;&#1493;&#1503;
                        </td>
                        <td>
                            <div id="eventCount2" style="font-size:10pt; direction:rtl">0</div>
                        </td>
                    </tr>
                    <tr>
                        <td style="font-size:10pt; direction: rtl; width: 90px"> 
                            &#1502;&#1493;&#1508;&#1506;&#1497; &#1497;&#1500;&#1491;&#1497;&#1501;
                        </td>
                        <td>
                            <div id="eventCount3" style="font-size:10pt; direction:rtl">0</div>
                        </td>
                        <td style="width: 40px"/>
                        <td style="font-size:10pt; direction: rtl; width: 85px"> 
                            &#1514;&#1506;&#1512;&#1493;&#1499;&#1493;&#1514;
                        </td>
                        <td>
                            <div id="eventCount4" style="font-size:10pt; direction:rtl">0</div>
                        </td>
                    </tr>
                    <tr>
                        <td style="font-size:10pt; direction: rtl; width: 90px"> 
                            &#1502;&#1505;&#1497;&#1489;&#1493;&#1514;
                        </td>
                        <td>
                            <div id="eventCount5" style="font-size:10pt; direction:rtl">0</div>
                        </td>
                        <td style="width: 40px"/>
                        <td style="font-size:10pt; direction: rtl; width: 85px"> 
                            &#1505;&#1512;&#1496;&#1497;&#1501;
                        </td>
                        <td>
                            <div id="eventCount6" style="font-size:10pt; direction:rtl">0</div>
                        </td>
                    </tr> 
                    <tr>
                        <td style="font-size:10pt; direction: rtl; width: 85px"> 
                            &#1502;&#1493;&#1508;&#1506;&#1497; &#1502;&#1493;&#1494;&#1497;&#1511;&#1492;
                        </td>
                        <td>
                            <div id="eventCount7" style="font-size:10pt; direction:rtl">0</div>
                        </td>
                    </tr>
                </table>
            </div> 
        </div>
        <div id="search_tab" style="display: none">
        <div id="content_div3" style="font-size:10pt; padding:5px; direction:rtl; background-color: #FFFFBF" >
            <b>&#1500;&#1489;&#1497;&#1510;&#1493;&#1506; &#1492;&#1495;&#1497;&#1508;&#1493;&#1513; &#1489;&#1495;&#1512; &#1488;&#1494;&#1493;&#1512;, &#1514;&#1495;&#1493;&#1501; &#1488;&#1497;&#1512;&#1493;&#1506; &#1493;&#1496;&#1493;&#1493;&#1495; &#1513;&#1506;&#1493;&#1514; &#1502;&#1489;&#1493;&#1511;&#1513;:</b>
                <table>
                    <tr> 
                        <td>
                            <select id="area1" name="area1" >
                                <option value ="0">&#1489;&#1495;&#1512; &#1488;&#1494;&#1493;&#1512;</option>
                                <option value ="1">&#1514;&#1500; &#1488;&#1489;&#1497;&#1489;</option>
                                <option value ="2">&#1488;&#1494;&#1493;&#1512; &#1492;&#1502;&#1512;&#1499;&#1494;</option>
                                <option value ="3">&#1495;&#1497;&#1508;&#1492; &#1493;&#1492;&#1510;&#1508;&#1493;&#1503;</option>
                                <option value ="4">&#1488;&#1494;&#1493;&#1512; &#1492;&#1491;&#1512;&#1493;&#1501;</option>
                                <option value ="5">&#1497;&#1512;&#1493;&#1513;&#1500;&#1497;&#1501; &#1493;&#1492;&#1505;&#1489;&#1497;&#1489;&#1492;</option>
                            </select>
                        </td> 
                        <td>
                            <select id="field" name="field" >
                                <option value ="0">&#1489;&#1495;&#1512; &#1514;&#1495;&#1493;&#1501;</option>
                                <option value ="1">&#1488;&#1497;&#1512;&#1493;&#1506;&#1497;&#1501; &#1502;&#1497;&#1493;&#1495;&#1491;&#1497;&#1501;</option>
                                <option value ="2">&#1492;&#1510;&#1490;&#1493;&#1514; &#1514;&#1497;&#1488;&#1496;&#1512;&#1493;&#1503;</option>
                                <option value ="3">&#1502;&#1493;&#1508;&#1506;&#1497; &#1497;&#1500;&#1491;&#1497;&#1501;</option>
                                <option value ="4">&#1514;&#1506;&#1512;&#1493;&#1499;&#1493;&#1514;</option>
                                <option value ="5">&#1502;&#1505;&#1497;&#1489;&#1493;&#1514;</option>
                                <option value ="6">&#1505;&#1512;&#1496;&#1497;&#1501;</option>
                            </select>
                        </td>
                        <td>
                            <select id="hour" name="hour" >
                                <option value ="1">&#1499;&#1500; &#1492;&#1497;&#1493;&#1501;</option>
                                <option value ="2">&#1489;&#1493;&#1511;&#1512;</option>
                                <option value ="3">&#1510;&#1492;&#1512;&#1497;&#1497;&#1501;</option>
                                <option value ="4">&#1488;&#1495;&#1492;"&#1510;</option>
                                <option value ="5">&#1506;&#1512;&#1489;</option>
                                <option value ="6">&#1500;&#1497;&#1500;&#1492;</option>
                            </select>
                        </td>
                        <td>
                            <input type="button" name="butSearch" name="butSearch" value="&#1495;&#1497;&#1508;&#1493;&#1513;" onclick="updateSearch()">
                        </td>
                    </tr>
                </table>
            </div>
            <div id="content_div4" style="color: blue; font-size:11pt; padding:5px; direction:rtl" >
            </div>
        </div>
 
<script type="text/javascript">
    var tabs = new _IG_Tabs(__MODULE_ID__, "&#1512;&#1488;&#1513;&#1497;");
    tabs.alignTabs("right", 10);
    var prefs = new _IG_Prefs(__MODULE_ID__);
    var myareaPref = prefs.getString("test000"); 
    var areaEnName = "";
    var searchEnArea;
    var searchEnField;
    var searchEnHour1;
    var searchEnHour2;
    var searchEnHour3;
    var searchEnHour4;
    var searchEnHour5;
    updateName();
    // Gets and displays the publisher gadget's local test000 userpref. New userpref value is not published
    // unless user invokes updateMsg() by clicking button.
    var str = prefs.getString("test000");
    _gel("area").value = str;
    _IG_RegisterOnloadHandler(init);
 
//updates the name of the area chosen in english
function updateName(){
    if (myareaPref == "1") 
    {
        areaEnName = "telAviv";
    }
    else if (myareaPref == "2") 
    {
        areaEnName = "merkaz";
    }
    else if (myareaPref == "3")
    {
        areaEnName = "haifaNorth";
    }
    else if (myareaPref == "4") 
    { 
        areaEnName = "south";
    }
    else if (myareaPref == "5") 
    {
        areaEnName = "jerusalem";
    }
 }
 
//fetches the number of events at the chosen field where area is the one chosen from the combobox
 function fetchData(field, id){
    var dbName = "http://www.cs.tau.ac.il/~yuvalda/" + areaEnName + field + "Count.txt"; 
    _IG_FetchContent(dbName, function (responseText) {
        if (responseText.length < 200)
        {
            _gel(id).innerHTML = responseText.substr(0,3); 
        }
        else 
        { 
            _gel(id).innerHTML = "0"; 
        }
    }); 
 } 
 
 //clears the data that was displayed on search tab
function resetData() {
    _gel('content_div4').innerHTML = "";
    _IG_AdjustIFrameHeight(160);
 }
 
//a callback function for the search tab - adjust the height on initial selection of this tab
function updateHeight() {
    _IG_AdjustIFrameHeight(160);
}
 
 // This publisher gadget updates the value for the test000 
 // userpref when users click the "Update Message" button.
 function updateValue() { 
    var newMsg = _gel("area").value;
    prefs.set("test000", newMsg); 
    myareaPref = prefs.getString("test000"); 
    updateName();
    fetchData("SpecialEvents", "eventCount1");
    fetchData("Stage", "eventCount2");
    fetchData("Children", "eventCount3");
    fetchData("Exhibition", "eventCount4");
    fetchData("Parties", "eventCount5");
    fetchData("Movies", "eventCount6"); 
    fetchData("Music", "eventCount7");
    _IG_AdjustIFrameHeight();
} 
 
 //the initialization function called first when gadget uploads
 function init() {
    tabs.addTab("&#1495;&#1497;&#1508;&#1493;&#1513;", "search_tab", updateHeight);
    tabs.addTab("&#1512;&#1488;&#1513;&#1497;", "main_tab", updateValue);
    tabs.setSelectedTab(1);
 }
 
//the search tab search function
function searchData(){
    if (searchEnArea == null | searchEnField == null) // if one of the comboboxes isn't chosen - reset the data shown
    {        
        resetData();
    }
    else
    {
        var dbName = "http://www.cs.tau.ac.il/~yuvalda/"+searchEnArea+searchEnField+"Table.txt";
        if (searchEnField == "Movies")
        {
            _IG_FetchContent(dbName, function (responseText) {      
                // Set CSS for div.    
                var html = "<div style='padding: 5px; text-align:right;font-size:80%'>"; 
                html += "<table><tr>";
                html += "<td style='text-align:right; font-size:10pt; font-weight:bold; text-decoration: underline; width: 180px'>&#1513;&#1501; &#1492;&#1505;&#1512;&#1496;</td>"; 
                html += "</tr><tr>";
                var html2 = "";
                // Use the split function to extract substrings separated by comma 
                // delimiters.
                var contacts = responseText.split("$^$");
                if (contacts[0].length > 200)
                {
                    html2 += "<tr><td style='text-align:right; font-size:10pt; color: red; font-weight:bold; width: 180px'>&#1488;&#1497;&#1503; &#1505;&#1512;&#1496;&#1497;&#1501;</td ></tr>";
                }
                else
                { 
                // Process array of extracted substrings.
                    for (var i = 0; i < contacts.length ; i++) 
                    {
                        // Append substrings to html.
                        if ((i%2) == 0)
                        {
                            html2 += "<td style='text-align:right; font-size:10pt; width: 180px'><a href=" + contacts[i+1] + " target='_blank' style='text-decoration: none;'>" + contacts[i]+"</a>"; 
                            html2 += "</td></tr><tr>";
                        }
                    }        
                }
                // Output html in div.
                if (html2 == "")
                {
                    html2 = "ìà ðîöàå ñøèéí";
                }
                html += html2;
                _gel('content_div4').innerHTML = html; 
                _IG_AdjustIFrameHeight();
            }); 
        } 
        else
        {
            _IG_FetchContent(dbName, function (responseText) { 
                // Set CSS for div. 
                var html = "<div style='padding: 5px; text-align:right;font-size:80%'>"; 
                html += "<table><tr>";
                html += "<td style='text-align:right; font-size:10pt; font-weight:bold; text-decoration: underline; width: 50px'>&#1513;&#1506;&#1492;</td>";
                html += "<td style='text-align:right; font-size:10pt; font-weight:bold; text-decoration: underline; width: 180px'>&#1513;&#1501; &#1492;&#1502;&#1493;&#1508;&#1506;</td>"; 
                html += "<td style='text-align:right; font-size:10pt; font-weight:bold; text-decoration: underline; width: 180px'>&#1502;&#1511;&#1493;&#1501; &#1492;&#1502;&#1493;&#1508;&#1506;</td ></tr><tr>";
                var html2 = "";
                // Use the split function to extract substrings separated by comma 
                // delimiters.
                var contacts = responseText.split("$^$");
                if (contacts[0].length > 200)
                {
                    html2 += "</table></div><div><table><tr><td style='text-align:right; font-size:10pt; color: red; font-weight:bold'>ìà ðîöàå àéøåòéí áúçåí åáàæåø äîáå÷ùéí</td></tr>";
                }
                else if (searchEnHour1 != "all")
                { 
                    // Process array of extracted substrings.
                    for (var i = 0; i < contacts.length ; i++) 
                    {
                        // Append substrings to html.
                        if ((i%6) == 0 & contacts[i].substr(0,2) != searchEnHour1 &
                                        contacts[i].substr(0,2) != searchEnHour2 &
                                        contacts[i].substr(0,2) != searchEnHour3 &
                                        contacts[i].substr(0,2) != searchEnHour4 &
                                        contacts[i].substr(0,2) != searchEnHour5) 
                        {
                            i +=5;
                            continue;
                        }
                        else if ((i%6) == 0)
                        {
                            html2 += "<td style='text-align:right; font-size:10pt; width: 50px'>" + contacts[i] + "</td>";
                        }
                        else if ((i%2) == 0)
                        {
                            html2 += "<td style='text-align:right; font-size:10pt; width: 180px'><a href=" + contacts[i+1] + " target='_blank' style='text-decoration: none;'>" + contacts[i]+"</a>"; 
                            html2 += "</td>";
                        } 
                        else if((i+1)%6 ==0) 
                        { 
                            html2 += "</tr><tr>";
                        }
                    }
                    html2 += "</table></div>";
                }
                else
                {
                    // Process array of extracted substrings.
                    for (var i = 0; i < contacts.length ; i++) 
                    {
                        // Append substrings to html.
                        if ((i%6) == 0)
                        {
                            html2 += "<td style='text-align:right; font-size:10pt; width: 50px'>" + contacts[i] + "</td>";
                        }
                        else if ((i%2) == 0){
                            html2 += "<td style='text-align:right; font-size:10pt; width: 180px'><a href=" + contacts[i+1] + " target='_blank' style='text-decoration: none;'>" + contacts[i]+"</a>";
                            html2 += "</td>";
                        }
                        else if((i+1)%6 ==0) 
                        {
                            html2 += "</tr><tr>";
                        }
                    }
                    html2 += "</table></div>";
                }
                if (html2 == "</table></div>")
                {
                    html2 += "</table></div><table><tr><td style='text-align:right; font-size:10pt; color: red; font-weight:bold'>ìà ðîöàå àéøåòéí áùòåú äîáå÷ùåú</td></tr></table>"
                }
                html += html2;
 
                // Output html in div.
                _gel('content_div4').innerHTML = html; 
                _IG_AdjustIFrameHeight();             
            }); 
        } 
    }
 }
 
//sets the parameters for the search
function updateSearch(){ 
    var searchArea = document.getElementById('area1').value;
    var searchField = document.getElementById('field').value;
    var searchHour = document.getElementById('hour').value;
 
    if (searchArea == "0") 
    {
        searchEnArea = null;
    }
    else if (searchArea == "1") 
    {
        searchEnArea = "telAviv";
    }
    else if (searchArea == "2") 
    {
        searchEnArea = "merkaz";
    }
    else if (searchArea == "3") 
    {
        searchEnArea = "haifaNorth";
    }
    else if (searchArea == "4") 
    { 
        searchEnArea = "south";
    }
    else if (searchArea == "5") 
    {
        searchEnArea = "jerusalem";
    }
 
    if (searchField == "0") 
    {
        searchEnField = null;
    }
    else if (searchField== "1") 
    {
        searchEnField = "SpecialEvents";
    }
    else if (searchField== "2") 
    {
        searchEnField = "Stage";
    }
    else if (searchField== "3") 
    {     
        searchEnField = "Children";
    }
    else if (searchField== "4") 
    { 
        searchEnField = "Exhibition";
    }
    else if (searchField== "5") 
    {
        searchEnField = "Parties";
    }
    else if (searchField== "6") 
    {
        searchEnField = "Movies";
    }
 
    if (searchHour== "1") 
    {
        searchEnHour1 = "all";
        searchEnHour2 = "all";
        searchEnHour3 = "all";
        searchEnHour4 = "all";
        searchEnHour5 = "all";
    }
    if (searchHour== "2") 
    {
        searchEnHour1 = "07";
        searchEnHour2 = "08";
        searchEnHour3 = "09";
        searchEnHour4 = "10";
        searchEnHour5 = "11";
    }
    else if (searchHour== "3") 
    {
        searchEnHour1 = "11";
        searchEnHour2 = "12";
        searchEnHour3 = "13";
        searchEnHour4 = "14";
        searchEnHour5 = "15";
    }
    else if (searchHour== "4")
    {
        searchEnHour1 = "15";
        searchEnHour2 = "16";
        searchEnHour3 = "17";
        searchEnHour4 = "18";
        searchEnHour5 = "19";
    }
    else if (searchHour== "5") 
    {    
        searchEnHour1 = "19";
        searchEnHour2 = "20";
        searchEnHour3 = "21";
        searchEnHour4 = "22";
        searchEnHour5 = "23";
    }
    else if (searchHour== "6") 
    {
        searchEnHour1 = "22";
        searchEnHour2 = "23";
        searchEnHour3 = "00";
        searchEnHour4 = "01";
        searchEnHour5 = "02";
    } 
    searchData();
} 
 
</script>
</div> 
 ]]> 
</Content>
</Module>

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License