Project

General

Profile

Feature #763

Allow specification of element separator

Added by Luke Murphey over 10 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
-
Target version:
Start date:
07/09/2014
Due date:
% Done:

100%


Description

Allow users to define a separator that will be used to split-up elements. This is useful in case you want to match set of nodes and then need something to help you split up the content in a way that makes it easy to parse.

For example, if you wanted to pull down the list of ingredients from http://allrecipes.com/Recipe/Chunky-Cheesecake-Brownies/Detail.aspx?evt19=1 then you would likely want each ingredient separated by a semi-colon so that you could use a regular expression to pull out the ingredient and the quantity.

This separator would added between each node with text.

History

#1 Updated by Luke Murphey over 10 years ago

  • Target version changed from 0.7 to 0.9

#2 Updated by Luke Murphey over 10 years ago

  • Target version changed from 0.9 to 2.0

#3 Updated by Luke Murphey almost 9 years ago

  • Priority changed from Normal to Low

#4 Updated by Luke Murphey over 8 years ago

  • Target version changed from 2.0 to 2.1

#5 Updated by Luke Murphey over 8 years ago

  • Description updated (diff)

#6 Updated by Luke Murphey over 8 years ago

To make the input page simpler, I could add the following to be inserted before the legend tags on the page with logic that will show/hide the sections optionally:

<input type="checkbox" value="1" onclick="" style="float: left;" />

#7 Updated by Luke Murphey over 8 years ago

This adds the checkbox:

addCheckboxWidget = function(id){
    var name = $("#" + id + ' > fieldset > legend').text();
    $("#" + id + ' > fieldset > legend').html('<input type="checkbox" value="1" onclick="" style="float: left;" />' + name );
}

addCheckboxWidget('item-authFields')

#8 Updated by Luke Murphey over 8 years ago

Adding handler:

addCheckboxWidget = function(id){
    var name = $("#" + id + ' > fieldset > legend').text();
    $("#" + id + ' > fieldset > legend').html('<input type="checkbox" value="1" onclick="" style="float: left;" />' + name );

     $("#" + id + ' > fieldset > legend > input ').click( function() {
          alert("k");
      });
}

addCheckboxWidget('item-authFields')

#9 Updated by Luke Murphey over 8 years ago

Adding hiding/showing:

addCheckboxWidget = function(id){
    var name = $("#" + id + ' > fieldset > legend').text();
    $("#" + id + ' > fieldset > legend').html('<input type="checkbox" value="1" onclick="" style="float: left;" />' + name );

     $("#" + id + ' > fieldset > legend > input ').click( function() {
          if ($(this).is(':checked')) {
            $("#" + id + ' > fieldset > div').show();
         } else {
             $("#" + id + ' > fieldset > div').hide();
         }
      });
}

addCheckboxWidget('item-authFields')

#10 Updated by Luke Murphey over 8 years ago

Version that toggles fields based on a policy:

addCheckboxWidget = function(id, check_policy){
    var name = $("#" + id + ' > fieldset > legend').text();

    var checked=false;

    if(check_policy && check_policy()){
        checked = true;
    }
   var checked_val = "";

   if(checked){
        checked_val = "checked";
   }

    $("#" + id + ' > fieldset > legend').html('<input type="checkbox" "' + checked_val + '" style="float: left;" />' + name );

     $("#" + id + ' > fieldset > legend > input ').click( function() {
          if ($(this).is(':checked')) {
            $("#" + id + ' > fieldset > div').show();
         } else {
             $("#" + id + ' > fieldset > div').hide();
         }
      });

    if(!checked){
         $("#" + id + ' > fieldset > div').hide();
    }

}

policy = function(){
  return $('#username_id').val().length > 0 || $('#password_id').val().length > 0;
}

addCheckboxWidget('item-authFields', policy)

#11 Updated by Luke Murphey over 8 years ago

Need to have the group unchecked if no fields are filled in:

checked = false;
                    $("#item-authFields input:not(.optional_control)").each(function(index, element) {
                        if($(element).val().length > 0){
alert($(element).val());
                            checked = true;
                        }
                    });

alert(checked);

#12 Updated by Luke Murphey over 8 years ago

Here is the call-stack:

  • run()
  • scrape_page()
  • get_result_single()
  • get_text()

#13 Updated by Luke Murphey over 8 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF