简体   繁体   中英

Send data to flyout, windows Sidebar Gadget

im trying to develop a sidebar gadget for windows.

Everything is working fine except from the issue that i dont have much knowledge about gadgets. i tried searching Net and there is very less documentatins and they are not much clear also.

Problem right now i am facing i got data from server using Ajax. now i want to show the returned data in flyout. But the BIG question is how to send data to flyout, searched net and couldnt find anything useful. yes there are many examples out there but there is too much code in those examples that i cant figure out what is happening.

Here below is my gadget.html , the main html file some code from file:

        function init()
        {
            System.Gadget.settingsUI = "settings.html";
            System.Gadget.onSettingsClosed = settingsClosed;
            // Specify the Flyout root.
            System.Gadget.Flyout.file = "search.html";
            System.Gadget.onDock = DockedChanged;   //no longer support in win7
            System.Gadget.onUndock = UnDockedChanged;   //msdn.microsoft.com/en-us/library/dd370867(VS.85).aspx
            this.document.body.style.height = 100;
            var evenColorTR = document.getElementById('evenColorTR');
            var ColorRows = document.getElementById('data-Tables').getElementsByTagName('tr');
            for(var x = 0; x < ColorRows.length; x++) {
                ColorRows[x].className = (x % 2 == 0) ? 'even' : 'odd';
            }
        }

        function openSearch() 
        {
            var searchString = document.getElementById("searchBox").value;
            var location = "http://localhost/projects/pdoConnection.php";
//            var location = "http://www.w3schools.com/ajax/ajax_info.txt";

/*            var http = new XMLHttpRequest();
            var params = "lorem=ipsum&name=binny";*/
            System.Gadget.Flyout.show = true;
            var data={
                searchFilter:searchString
            };
/*            $('#testingbaba').text('im inside function');
            console.log('I am inside Function');*/
/*
            try{
           $.ajax({
                type:"POST",
                url:location,
                data:data,
                dataType:"json",
               cache:false,
               success:function(e){
                   console.log('im the success'+e);
                   $('#testingbaba').text('im the success'+e);
               },
               error:function(XMLHttpRequest, textStatus, errorThrown){
                   console.log('im the error' + e);
                   $('#testingbaba').text('im the error'+errorThrown);
               }
                });
            }
            catch(e) {
                $('#testingbaba').text('im the catch'+e);
            }
*/
            $.post( location, data).done(function( data ) {
                $('#testingbaba').text(data);

            });

/*            var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            xmlhttp.onreadystatechange=function(e) {
                if (xmlhttp.readyState==4) {
                    $('#testingbaba').text('Hello World');
                }

                xmlhttp.open("GET",location,true);
                xmlhttp.send();
            }*/

        }

i want when the flyout is opened ie when System.Gadget.Flyout.show = true; is set to true the data should be sent to the flyout.

problem solved, found the solution.

To send data from main html file to the flyout i did use this below procedure.

Added this below code

var somedata = 'some data or string or anything';
System.Gadget.Settings.write("data", someData);

and did read the data in flyout using this below code.

var dataFromMainFile = System.Gadget.Settings.read('data');

Worked like a charm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM