Results 1 to 14 of 14
  1.    #1  
    Hi,

    I want to adapt a website so it be readable on my phone. But I can't find anywhere how to do so. I think the simplest way is to parse the informations from the website.
    All I want to do is select some information from the html code of the page (select the text between <div></div> or an image from <img> for example).
    I think I have to use HtmlContent but I can't get it working. I forgot I'm using enyo framework.

    Thanks for your help

    Frenchkid
  2. #2  
    Check out JQuery, it has some features that may help.
  3.    #3  
    @nyuepik : You think I can't do that natively with enyo ?
  4. #4  
    I have the same goal, and I am trying to use Sizzle, the css selector engine from jQuery, however I can't figure out how to get the response HTML into a DOMElement or DOMDocument so that Sizzle can parse it. jQuery would presumably have the same problem. Any ideas?
  5. #5  
    You can try regular expressions.

    -- Sent from my Palm Pre using Forums
    If you like my applications (SynoMusic, SynoDM, SynoFM) and want to donate for future upgrades and development
  6. #6  
    Why not just something like this?:
    Create a DOM node with the content of the website and just do DOM operations to parse what you want.
    Apps (they're all free now): Explorer for Dropbox – a Dropbox app for webOS that actually works (TP+phones), 3-panel-interface
    File Explorer – fast and simple file manager (root support on webOS 3)
    QuickChat for Facebook – real-time Facebook chat (broken)
    Archive Manager – extract and create archives (zip, rar, 7z, …)
    FTPit! – full-featured FTP client for webOS
    e-mail (contact, support) – if you like what I'm doing, feel free to (alternatively in USD)
  7. #7  
    You guys need to google or bing on the term "responsive design". You can use media queries to adapt your presentation layer to virtually any screen realestate.
  8. #8  
    Here is my proposal:

    1. You create a service that retrieves HTML code of the Web page (via its URL)

    {name: "callHtml", kind: "WebService", onSuccess: "gotHtml", onFailure: "gotHtmlFailure"},

    2. You call the new service with the URL you want (ie. variable "this.url")

    getHtml: function(inSender, inEvent) {
    this.$.callHtml.setUrl(this.url);
    this.$.callHtml.call();
    },

    3. If the service succeeds in retrieving the HTML source code

    gotHtml: function(inSender, inResponse) {
    //enyo.log("Got success from getHtml!");
    var parser = new DOMParser();
    var xmlTree = parser.parseFromString(inResponse, "text/html");
    // >>>>>>> Add your code here! <<<<<<<
    /*
    * variable xmlTree contains de DOM tree of the retrieved Web page
    */
    },

    gotFeedFailure: function(inSender, inResponse) {
    enyo.log("Got failure from getHtml!");
    },
  9. #9  
    Hi, I kind of followed your method , tried to parse a website using the Enyo framework, but it did not work. The purpose is to build an app with three panels from left to right, the left panel displays a discussion forum's boards, the middle one display the topics of one board, the right panel displays the content of the topic selected.

    The following is code:

    enyo.kind({
    name: "MultiPanel",
    kind: enyo.VFlexBox, onOpen: "getHtml",
    components: [
    {
    name: "getBBS",
    kind: "WebService",
    url: "http://www.awebite.com/website.php",
    onSuccess: "getBBS",
    onFailure: "getBBSFailed",
    accessBBS: function(inSender, inEvent){
    this.$.getBBS.call();
    },
    getBBS: function(inSender, inResponse) {
    enyo.log("Got success from getHtml!");
    var parser = new DOMParser();
    var xmlTree = parser.parseFromString(inResponse, "text/html");
    console.log(xmlTree);
    // >>>>>>> Add your code here! <<<<<<<
    /*
    * variable xmlTree contains de DOM tree of the retrieved Web page
    */
    },
    getBBSFailed: function(inSender, inResponse) {
    enyo.log("Got failure from getHtml!");
    }

    },

    {
    name: "slidingPane",
    kind: "SlidingPane",
    flex: 1,
    components:
    [{
    name: "left",
    width: "240px",
    kind:"SlidingView",
    components:
    [{
    kind: "Header",
    content:"Boards"
    },
    {
    kind: "Scroller",
    flex: 1,
    components:
    [{
    Name: "list",
    kind: "VirtualRepeater",
    onSetupRow: "getItem",
    components:
    [{
    kind: "Item",
    layoutKind: "HFlexLayout",
    components:
    [{
    name: "caption",
    flex: 1,
    getItem: function(inSender, inIndex) {
    if (inIndex < 10) {
    this.$.caption.setContent("Board Name Displayed Here" /*+ inIndex*/);
    return true;
    }
    }

    }
    ]}
    ]}
    ]}
    ]},
    {
    name: "middle",
    width: "320px",
    kind:"SlidingView",
    peekWidth: 50,
    components:
    [{
    kind: "Header",
    content:"Topics"
    },
    {
    kind: "Drawer",
    caption: "Topics Come Here",
    components:
    []
    },
    {
    kind: "Scroller",
    flex: 1,
    onclick: "getBBS",
    components: []
    },
    {
    kind: "Toolbar",
    components:
    [{
    kind: "GrabButton"
    }
    ]}
    ]},
    {
    name: "right",
    kind:"SlidingView",
    flex: 1, components:
    [{
    kind: "Header",
    content:"Posts"
    },
    {
    kind: "Scroller",
    flex: 1,
    components:
    []
    },
    {
    kind: "Toolbar",
    components:
    [{
    kind: "GrabButton"
    }
    ]}

    ]}
    ]}

    ],
    });
  10. #10  
    Code would work better if you put [ code ] block around it, assuming this forum supports that, i've never tried.

    Also, you don't really say what "didn't work".

    SynerGV 1 parses various elements via class name to figure out where everything is, without knowing the structure of what you're trying to get at pretty intimately, it will be a fun and entertaining challenge to get the information that you need out of it, if possible.

    Here's a snippet from SynerGV's message parsing system, this is the part that pulls out all of the messages from the HTML source .. which are all inside blocks that are classed with "gc-message-sms-row". The HTML is picked up using a WebService, then passed into this function, which returns a parsed representation of it.

    Code:
    function ParseMessages(html)
    {
        var ret = [ ];
        var tmp = document.createElement("DIV");
        
        html = html.replace(/src=\"/g, 'src="https://www.google.com');
        tmp.innerHTML = html;
        
        SMSMessageBlocks = tmp.getElementsByClassName("gc-message-sms-row");
        for(var x = 0; x < SMSMessageBlocks.length; x++)
        {
            ret[x] = [ ];
            ret[x].SentBy = enyo.string.trim(SMSMessageBlocks[x].getElementsByClassName("gc-message-sms-from")[0].textContent);
            ret[x].SentTime = SMSMessageBlocks[x].getElementsByClassName("gc-message-sms-time")[0].textContent;
            // non-webOS and webOS 1/2 have broken runTextIndexer
            if(typeof Platform !== "undefined" && Platform.isWebOS() && Platform.platformVersion >= 3)
                ret[x].SentMessage = enyo.string.runTextIndexer(SMSMessageBlocks[x].getElementsByClassName("gc-message-sms-text")[0].textContent, { emoticon: false });
            else
                ret[x].SentMessage = SMSMessageBlocks[x].getElementsByClassName("gc-message-sms-text")[0].textContent;
        }
     ....
    Author:
    Remove Messaging Beeps patch for webOS 3.0.5, Left/Right bezel gestures in LunaCE,
    Whazaa! Messenger and node-wa, SynerGV 1 and 2 - Google Voice integration, XO - Subsonic Commander media streamer, AB:S Launcher
    (1:39:33 PM) halfhalo: Android multitasking is like sticking your fingers into a blender
    GO OPEN WEBOS!
    People asked me for a donate link for my non-catalog work, so here you are:
  11. #11  
    Thanks for the reply.
    What I'm trying to do here is to pull the content from a website, a discussion foru type, and place it into a kind rss feed reader type, enyo style app.

    What it does not work is that it won't display the content into the repeater in the left panel of the app.

    In your sample code, where is the part webservice gets called and results gets back?

    Quote Originally Posted by eblade View Post
    Code would work better if you put [ code ] block around it, assuming this forum supports that, i've never tried.

    Also, you don't really say what "didn't work".

    SynerGV 1 parses various elements via class name to figure out where everything is, without knowing the structure of what you're trying to get at pretty intimately, it will be a fun and entertaining challenge to get the information that you need out of it, if possible.

    Here's a snippet from SynerGV's message parsing system, this is the part that pulls out all of the messages from the HTML source .. which are all inside blocks that are classed with "gc-message-sms-row". The HTML is picked up using a WebService, then passed into this function, which returns a parsed representation of it.

    Code:
    function ParseMessages(html)
    {
        var ret = [ ];
        var tmp = document.createElement("DIV");
        
        html = html.replace(/src=\"/g, 'src="https://www.google.com');
        tmp.innerHTML = html;
        
        SMSMessageBlocks = tmp.getElementsByClassName("gc-message-sms-row");
        for(var x = 0; x < SMSMessageBlocks.length; x++)
        {
            ret[x] = [ ];
            ret[x].SentBy = enyo.string.trim(SMSMessageBlocks[x].getElementsByClassName("gc-message-sms-from")[0].textContent);
            ret[x].SentTime = SMSMessageBlocks[x].getElementsByClassName("gc-message-sms-time")[0].textContent;
            // non-webOS and webOS 1/2 have broken runTextIndexer
            if(typeof Platform !== "undefined" && Platform.isWebOS() && Platform.platformVersion >= 3)
                ret[x].SentMessage = enyo.string.runTextIndexer(SMSMessageBlocks[x].getElementsByClassName("gc-message-sms-text")[0].textContent, { emoticon: false });
            else
                ret[x].SentMessage = SMSMessageBlocks[x].getElementsByClassName("gc-message-sms-text")[0].textContent;
        }
     ....
  12. #12  
    well, that's just the code that does the parsing. I can't really tell what you're actually doing in the code that was posted above, other than that it looks like you only call the function to retrieve the data when a scroller is clicked on, and you can't really click on a scroller that doesn't have anything in it, because there's no space to click on.

    Code:
    { name: "GetGoogle", kind: "WebService", url: "http://www.google.com/", onSuccess: "received" },
    create: function() {
        this.inherited(arguments);
        this.$.GetGoogle.call({ });
    },
    received: function(inSender, inResponse, inRequest) {
        this.log(inResponse);
    }
    will log whatever the webservice call returns
    Author:
    Remove Messaging Beeps patch for webOS 3.0.5, Left/Right bezel gestures in LunaCE,
    Whazaa! Messenger and node-wa, SynerGV 1 and 2 - Google Voice integration, XO - Subsonic Commander media streamer, AB:S Launcher
    (1:39:33 PM) halfhalo: Android multitasking is like sticking your fingers into a blender
    GO OPEN WEBOS!
    People asked me for a donate link for my non-catalog work, so here you are:
  13. #13  
    Thanks for the reply.

    All I wanted to do, as I have said was to pull some info from a website, parse it, then render into items in the enyo widget. A simple idea, but I feel pretty difficult to implement. I have tried this for over 6 months now. I have looked the RSS reader sample, both the simple one and the extended one; I have looked at the email app comes with TP, along with other TP apps. No clue. But I will keep going, until I figure it out.

    Quote Originally Posted by eblade View Post
    well, that's just the code that does the parsing. I can't really tell what you're actually doing in the code that was posted above, other than that it looks like you only call the function to retrieve the data when a scroller is clicked on, and you can't really click on a scroller that doesn't have anything in it, because there's no space to click on.

    Code:
    { name: "GetGoogle", kind: "WebService", url: "http://www.google.com/", onSuccess: "received" },
    create: function() {
        this.inherited(arguments);
        this.$.GetGoogle.call({ });
    },
    received: function(inSender, inResponse, inRequest) {
        this.log(inResponse);
    }
    will log whatever the webservice call returns
  14. #14  
    My question also includes how to write the parsed content to the Enyo widget coponents? Such as buttons, drawers, line items, etc.

    I have tried your code in my program, it seems not working. I have placed this webService kind in a MultiPanel as a component, so do the function to call it, and function to log its response.

    --------------------------------------------------------------------------My Code---------------------------------------------------------------------------
    enyo.kind({
    name: "MultiPanel",
    kind: enyo.VFlexBox,
    components: [
    {
    name: "getBBS",
    kind: "WebService",
    url: "http://www.BBSSite.com",
    onSuccess: "gotBBSSucceed"
    },
    create: function() {
    this.inherited(arguments);
    this.$.getBBS.call({});
    },
    gotBBSSucceed: function(inSender, inResponse, inRequest) {
    this.log(inResponse);
    },

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------
    I am using Eclipse as a editor, under Ubuntu. The painful thing about this is debugging and testing, there is simple no error messages, only a grey screen that I know it's not working.

    Quote Originally Posted by highrock2 View Post
    Thanks for the reply.

    All I wanted to do, as I have said was to pull some info from a website, parse it, then render into items in the enyo widget. A simple idea, but I feel pretty difficult to implement. I have tried this for over 6 months now. I have looked the RSS reader sample, both the simple one and the extended one; I have looked at the email app comes with TP, along with other TP apps. No clue. But I will keep going, until I figure it out.

Posting Permissions