问:
when uncheck all the childs parent check box also should be unchecked using jquery
I have nested checkbox list items. In my case, if I select parent, all the child's checkboxes checked fine.

If I uncheck parent-child checkboxes unchecking fine and all the child checkboxes check parent checkbox is checking fine.

But my problem is, if I uncheck all the child checkboxes parent checkbox is still checked state only.

I'm new to jQuery and javascript.where to change my code.Any help would be appreciated.Thanks in Advance.

$(function() {
  $('li :checkbox').on('click', function() {
    var $chk = $(this),
      $li = $chk.closest('li'),
      $ul, $parent;
    if ($li.has('ul')) {
      $li.find(':checkbox').not(this).prop('checked', this.checked)
    }
    do {
      $ul = $li.parent();
      $parent = $ul.siblings(':checkbox');
      if ($chk.is(':checked')) {
        $parent.prop('checked', $ul.has(':checkbox:not(:checked)').length == 0)
      } else {
        $parent.prop('checked', true)
      }
      $chk = $parent;
      $li = $chk.closest('li');
    } while ($ul.is(':not(.someclass)'));
  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<div id="1" class="tab-pane fade in active">
  <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='5'>A1
    <ul>
      <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='26'>a2
        <ul>
          <li class='chkbox' ;>
            <input type='checkbox' class='myCheckbox' name='names[]' value='29'>a3
            <li class='chkbox' ;>
              <input type='checkbox' class='myCheckbox' name='names[]' value='30'>a4
        </ul>
        <li class='chkbox'>
          <input type='checkbox' class='myCheckbox' name='names[]' value='25'>a1
          <ul>
            <li class='chkbox' ;><input type='checkbox' class='myCheckbox' name='names[]' value='27'>aaaaaa
              <li class='chkbox' ;><input type='checkbox' class='myCheckbox' name='names[]' value='28'>abbbbbb
          </ul>
    </ul>
    <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='6'>A2
      <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='7'>A3
        <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='8'>A4
          <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='9'>A5
            <div style="clear:both">
            </div>
</div>
<div id="2" class="tab-pane fade">
  <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='10'> B1
    <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='11'>B2
      <div style="clear:both">
      </div>
</div>
<div id="3" class="tab-pane fade">
  <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='12'>C1
    <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='13'>C2
      <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='14'>C3
        <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='17'>A6
          <ul>
            <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='19'>A8
              <ul>
                <li class='chkbox' ;><input type='checkbox' class='myCheckbox' name='names[]' value='21'>A10
                  <ul>
                    <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='23'>A13
                      <ul>
                        <li class='chkbox' ;><input type='checkbox' name='names[]' value='31'>jjj
                          <li class='chkbox' ;><input type='checkbox' name='names[]' value='32'>kkk
                      </ul>
                      <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='24'>A14
                        <ul>
                        </ul>
                  </ul>
                  <li class='chkbox' ;><input type='checkbox' class='myCheckbox' name='names[]' value='22'>A11
              </ul>
              <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='20'>A9
          </ul>
          <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='18'>A7
            <div style="clear:both"></div>
</div>
<div id="4" class="tab-pane fade">
  <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='15'>D1
    <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='16'>D2
      <div style="clear:both"></div></code>```

答:
If I understand you correctly, you need to run on 2 directions - up and down (in the hierarchy tree).

For up, you can use parents and do the check for each parent.

For down, you just need to find the sibling ul and find within it all the :checkboxs.

Also, I changed the event from click to change - the event which meant to handle changes in the state of the checkbox.

Let me know if something is not clear.

$(':checkbox').on('change', function() {
  var $this = $(this),
      checked = $this.is(':checked');

  toggleParents($this, checked);
  //toggleChildren($this, checked);
});

function toggleParents(checkbox, checked) {
  checkbox.parents('li').each(function() {
    var $parent = $(this);
    $parent.children(':checkbox').prop('checked', checked);
  });
}

function toggleChildren(checkbox, checked) {
  checkbox.siblings('ul').find(':checkbox').each(function() {
    $(this).prop('checked', checked);
  });
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<div id="1" class="tab-pane fade in active">
  <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='5'>A1
    <ul>
      <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='26'>a2
        <ul>
          <li class='chkbox' ;>
            <input type='checkbox' class='myCheckbox' name='names[]' value='29'>a3
            <li class='chkbox' ;>
              <input type='checkbox' class='myCheckbox' name='names[]' value='30'>a4
        </ul>
        <li class='chkbox'>
          <input type='checkbox' class='myCheckbox' name='names[]' value='25'>a1
          <ul>
            <li class='chkbox' ;><input type='checkbox' class='myCheckbox' name='names[]' value='27'>aaaaaa
              <li class='chkbox' ;><input type='checkbox' class='myCheckbox' name='names[]' value='28'>abbbbbb
          </ul>
    </ul>
    <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='6'>A2
      <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='7'>A3
        <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='8'>A4
          <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='9'>A5
            <div style="clear:both">
            </div>
</div>
<div id="2" class="tab-pane fade">
  <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='10'> B1
    <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='11'>B2
      <div style="clear:both">
      </div>
</div>
<div id="3" class="tab-pane fade">
  <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='12'>C1
    <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='13'>C2
      <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='14'>C3
        <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='17'>A6
          <ul>
            <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='19'>A8
              <ul>
                <li class='chkbox' ;><input type='checkbox' class='myCheckbox' name='names[]' value='21'>A10
                  <ul>
                    <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='23'>A13
                      <ul>
                        <li class='chkbox' ;><input type='checkbox' name='names[]' value='31'>jjj
                          <li class='chkbox' ;><input type='checkbox' name='names[]' value='32'>kkk
                      </ul>
                      <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='24'>A14
                        <ul>
                        </ul>
                  </ul>
                  <li class='chkbox' ;><input type='checkbox' class='myCheckbox' name='names[]' value='22'>A11
              </ul>
              <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='20'>A9
          </ul>
          <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='18'>A7
            <div style="clear:both"></div>
</div>
<div id="4" class="tab-pane fade">
  <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='15'>D1
    <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='16'>D2
      <div style="clear:both"></div></code>```

Body:
I have nested checkbox list items. In my case, if I select parent, all the child's checkboxes checked fine.

If I uncheck parent-child checkboxes unchecking fine and all the child checkboxes check parent checkbox is checking fine.

But my problem is, if I uncheck all the child checkboxes parent checkbox is still checked state only.

I'm new to jQuery and javascript.where to change my code.Any help would be appreciated.Thanks in Advance.

$(function() {
  $('li :checkbox').on('click', function() {
    var $chk = $(this),
      $li = $chk.closest('li'),
      $ul, $parent;
    if ($li.has('ul')) {
      $li.find(':checkbox').not(this).prop('checked', this.checked)
    }
    do {
      $ul = $li.parent();
      $parent = $ul.siblings(':checkbox');
      if ($chk.is(':checked')) {
        $parent.prop('checked', $ul.has(':checkbox:not(:checked)').length == 0)
      } else {
        $parent.prop('checked', true)
      }
      $chk = $parent;
      $li = $chk.closest('li');
    } while ($ul.is(':not(.someclass)'));
  });
});

<input type='checkbox' class='myCheckbox' name='names[]' value='5'>A1

<input type='checkbox' class='myCheckbox' name='names[]' value='26'>a2

            <input type='checkbox' class='myCheckbox' name='names[]' value='29'>a3

              <input type='checkbox' class='myCheckbox' name='names[]' value='30'>a4

          <input type='checkbox' class='myCheckbox' name='names[]' value='25'>a1

<input type='checkbox' class='myCheckbox' name='names[]' value='27'>aaaaaa

<input type='checkbox' class='myCheckbox' name='names[]' value='28'>abbbbbb

<input type='checkbox' class='myCheckbox' name='names[]' value='6'>A2

<input type='checkbox' class='myCheckbox' name='names[]' value='7'>A3

<input type='checkbox' class='myCheckbox' name='names[]' value='8'>A4

<input type='checkbox' class='myCheckbox' name='names[]' value='9'>A5

<input type='checkbox' class='myCheckbox' name='names[]' value='10'> B1

<input type='checkbox' class='myCheckbox' name='names[]' value='11'>B2

<input type='checkbox' class='myCheckbox' name='names[]' value='12'>C1

<input type='checkbox' class='myCheckbox' name='names[]' value='13'>C2

<input type='checkbox' class='myCheckbox' name='names[]' value='14'>C3

<input type='checkbox' class='myCheckbox' name='names[]' value='17'>A6

<input type='checkbox' class='myCheckbox' name='names[]' value='19'>A8

<input type='checkbox' class='myCheckbox' name='names[]' value='21'>A10

<input type='checkbox' class='myCheckbox' name='names[]' value='23'>A13

<input type='checkbox' name='names[]' value='31'>jjj

<input type='checkbox' name='names[]' value='32'>kkk

<input type='checkbox' class='myCheckbox' name='names[]' value='24'>A14

<input type='checkbox' class='myCheckbox' name='names[]' value='22'>A11

<input type='checkbox' class='myCheckbox' name='names[]' value='20'>A9

<input type='checkbox' class='myCheckbox' name='names[]' value='18'>A7

<input type='checkbox' class='myCheckbox' name='names[]' value='15'>D1

<input type='checkbox' class='myCheckbox' name='names[]' value='16'>D2

Body:
If I understand you correctly, you need to run on 2 directions - up and down (in the hierarchy tree).

For up, you can use parents and do the check for each parent.

For down, you just need to find the sibling ul and find within it all the :checkboxs.

Also, I changed the event from click to change - the event which meant to handle changes in the state of the checkbox.

Let me know if something is not clear.

$(':checkbox').on('change', function() {
  var $this = $(this),
      checked = $this.is(':checked');

  toggleParents($this, checked);
  //toggleChildren($this, checked);
});

function toggleParents(checkbox, checked) {
  checkbox.parents('li').each(function() {
    var $parent = $(this);
    $parent.children(':checkbox').prop('checked', checked);
  });
}

function toggleChildren(checkbox, checked) {
  checkbox.siblings('ul').find(':checkbox').each(function() {
    $(this).prop('checked', checked);
  });
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<div id="1" class="tab-pane fade in active">
  <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='5'>A1
    <ul>
      <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='26'>a2
        <ul>
          <li class='chkbox' ;>
            <input type='checkbox' class='myCheckbox' name='names[]' value='29'>a3
            <li class='chkbox' ;>
              <input type='checkbox' class='myCheckbox' name='names[]' value='30'>a4
        </ul>
        <li class='chkbox'>
          <input type='checkbox' class='myCheckbox' name='names[]' value='25'>a1
          <ul>
            <li class='chkbox' ;><input type='checkbox' class='myCheckbox' name='names[]' value='27'>aaaaaa
              <li class='chkbox' ;><input type='checkbox' class='myCheckbox' name='names[]' value='28'>abbbbbb
          </ul>
    </ul>
    <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='6'>A2
      <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='7'>A3
        <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='8'>A4
          <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='9'>A5
            <div style="clear:both">
            </div>
</div>
<div id="2" class="tab-pane fade">
  <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='10'> B1
    <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='11'>B2
      <div style="clear:both">
      </div>
</div>
<div id="3" class="tab-pane fade">
  <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='12'>C1
    <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='13'>C2
      <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='14'>C3
        <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='17'>A6
          <ul>
            <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='19'>A8
              <ul>
                <li class='chkbox' ;><input type='checkbox' class='myCheckbox' name='names[]' value='21'>A10
                  <ul>
                    <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='23'>A13
                      <ul>
                        <li class='chkbox' ;><input type='checkbox' name='names[]' value='31'>jjj
                          <li class='chkbox' ;><input type='checkbox' name='names[]' value='32'>kkk
                      </ul>
                      <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='24'>A14
                        <ul>
                        </ul>
                  </ul>
                  <li class='chkbox' ;><input type='checkbox' class='myCheckbox' name='names[]' value='22'>A11
              </ul>
              <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='20'>A9
          </ul>
          <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='18'>A7
            <div style="clear:both"></div>
</div>
<div id="4" class="tab-pane fade">
  <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='15'>D1
    <li class='chkbox'><input type='checkbox' class='myCheckbox' name='names[]' value='16'>D2
      <div style="clear:both"></div>


来源: stackexchange

问:
ng-hide and ng-show for current row
I have one table.In than am doing row hide and show using angular for edit and save purpose.
It's working fine.

```<code>$scope.init=function(){
    $scope.editable=true;
}
</code>```

Now when I click on edit button in  table row ,edit button will be hided and save button will be shown.

```<code>$scope.editRow = function(id){
    console.log(id);\\row id will be displayed here
    $scope.editable=false;
}
</code>```

Here am facing one problem ,if I click edit on second row ,only second row should be editable.
I know we can do this easily using row id in jquery.But here I don't know how to do this in angular for ng-hide and ng-show.

Any Help?Thanks!!

code:

```<code><table>
<thead>
<tr>
    <th>Qualification</th>
    <th>Course</th>
    <th>Grade Attained</th>
    <th>Action</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="detail in educationDetails">
    <td>
        <span ng-show="editable">{{detail.qualification}}</span>
        <input type="text" ng-model="detail.qualification" ng-hide="editable"/>
    </td>
    <td>
        <span ng-show="editable">{{detail.education_type}}</span>
        <input type="text" ng-model="detail.education_type" ng-hide="editable"/>
    </td>
    <td>
        <span ng-show="editable">{{detail.grade}}</span>
        <input type="text" ng-model="detail.grade" ng-hide="editable"/>
    </td>
    <td>
        <div ng-show="editable">
            <span><i class='fa fa-trash-o' ng-click="deleteEducationDetail(detail)"></i></span>
            <span><i class='fa fa-pencil' ng-click="editEducationDetail(detail)"></i></span>
        </div>
        <div ng-hide="editable">
            <span><i class='fa fa-floppy-o' ng-click="updateEducationDetail(detail)"></i></span>
            <span><i class='fa fa-times' ng-click="cancelEducationDetail(detail)"></i></span>
        </div>
    </td>
</tr>

</tbody>
</table>

$scope.init = function () {
$scope.editable = true;
}
$scope.editEducationDetail = function (detail) {
detail.editable = false;
}
</code>```

答:
In order to achieve that you need show/hide properties for each row. You can initialise a property in ng-init and use it to show/hide rows. You can also do all of the show/hide logic in your html with the below code.</p>

```<code><tr ng-repeat="detail in educationDetails" ng-init="detail.editable = false">
    <td>
        <span ng-show="!detail.editable">{{detail.qualification}}</span>
        <input type="text" ng-model="detail.qualification" ng-show="detail.editable" />
    </td>
    <td>
        <span ng-show="!detail.editable">{{detail.education_type}}</span>
        <input type="text" ng-model="detail.education_type" ng-show="detail.editable" />
    </td>
    <td>
        <span ng-show="!detail.editable">{{detail.grade}}</span>
        <input type="text" ng-model="detail.grade" ng-show="detail.editable" />
    </td>
    <td>
        <div ng-show="editable">
            <span><i class='fa fa-trash-o' ng-click="deleteEducationDetail(detail)"></i></span>
            <span><i class='fa fa-pencil' ng-click="detail.editable = true"></i></span>
        </div>
        <div ng-hide="editable">
            <span><i class='fa fa-floppy-o' ng-click="updateEducationDetail(detail)"></i></span>
            <span><i class='fa fa-times' ng-click="detail.editable = false"></i></span>
        </div>
    </td>
</tr>
</code>```

ContentLicense: CC BY-SA 3.0

Title: ng-hide and ng-show for current row

Body:
I have one table.In than am doing row hide and show using angular for edit and save purpose.
It's working fine.

$scope.init=function(){
    $scope.editable=true;
}

Now when I click on edit button in  table row ,edit button will be hided and save button will be shown.

$scope.editRow = function(id){
    console.log(id);\\row id will be displayed here
    $scope.editable=false;
}

Here am facing one problem ,if I click edit on second row ,only second row should be editable.
I know we can do this easily using row id in jquery.But here I don't know how to do this in angular for ng-hide and ng-show.

Any Help?Thanks!!

code:

    Qualification
    Course
    Grade Attained
    Action

        {{detail.qualification}}
        <input type="text" ng-model="detail.qualification" ng-hide="editable"/>

        {{detail.education_type}}
        <input type="text" ng-model="detail.education_type" ng-hide="editable"/>

        {{detail.grade}}
        <input type="text" ng-model="detail.grade" ng-hide="editable"/>

$scope.init = function () {
$scope.editable = true;
}
$scope.editEducationDetail = function (detail) {
detail.editable = false;
}

Body:
In order to achieve that you need show/hide properties for each row. You can initialise a property in ng-init and use it to show/hide rows. You can also do all of the show/hide logic in your html with the below code.

<tr ng-repeat="detail in educationDetails" ng-init="detail.editable = false">
    <td>
        <span ng-show="!detail.editable">{{detail.qualification}}</span>
        <input type="text" ng-model="detail.qualification" ng-show="detail.editable" />
    </td>
    <td>
        <span ng-show="!detail.editable">{{detail.education_type}}</span>
        <input type="text" ng-model="detail.education_type" ng-show="detail.editable" />
    </td>
    <td>
        <span ng-show="!detail.editable">{{detail.grade}}</span>
        <input type="text" ng-model="detail.grade" ng-show="detail.editable" />
    </td>
    <td>
        <div ng-show="editable">
            <span><i class='fa fa-trash-o' ng-click="deleteEducationDetail(detail)"></i></span>
            <span><i class='fa fa-pencil' ng-click="detail.editable = true"></i></span>
        </div>
        <div ng-hide="editable">
            <span><i class='fa fa-floppy-o' ng-click="updateEducationDetail(detail)"></i></span>
            <span><i class='fa fa-times' ng-click="detail.editable = false"></i></span>
        </div>
    </td>
</tr>


问:
Iphone: UIWebview and double taps
I would like to trap a double tap event in a UIWebView. I have derived a class from UIWebController. When I double tap it seams that the UIWebController itself is responding to my double taps instead of my class. The weird thing is that when I change the inheritance to inherit from UIView everything works just fine.

Below are snippets from my code which is supposed to invoke a pop-up when double tapped.

In the init function:

```<code>//Setup action for double tap
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
    tap.numberOfTapsRequired = 2;
    [super addGestureRecognizer:tap];
    [tap release];
</code>```

And Also:

```<code>- (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer
{
    UIAlertView *someError = [[UIAlertView alloc] initWithTitle: @"Network error" message: @"Hello" delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil];
    [someError show];
    [someError release];

    //[[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_FLIP_TO_PAGE_VIEW object:nil];
}
</code>```

答:
I can't speak to the behavior of UITapGestureRecognizer. I do know that you can get very granular control if you override the touch event methods of the UIWebView.

Check out "Responding to Events" here.

ContentLicense: CC BY-SA 2.5

Title: Iphone: UIWebview and double taps

Body:
I would like to trap a double tap event in a UIWebView. I have derived a class from UIWebController. When I double tap it seams that the UIWebController itself is responding to my double taps instead of my class. The weird thing is that when I change the inheritance to inherit from UIView everything works just fine.

Below are snippets from my code which is supposed to invoke a pop-up when double tapped.

In the init function:

//Setup action for double tap
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
    tap.numberOfTapsRequired = 2;
    [super addGestureRecognizer:tap];
    [tap release];

And Also:

- (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer
{
    UIAlertView *someError = [[UIAlertView alloc] initWithTitle: @"Network error" message: @"Hello" delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil];
    [someError show];
    [someError release];

    //[[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_FLIP_TO_PAGE_VIEW object:nil];
}


问:
Extracting initials from a single string
I am looking to extract initials from a single textbox using Left, mid and other similar functions. The user enters their first, middle initial and last name; assuming spaces and a period after the middle initial. I need to ensure the initials extracted are uppercase, even if the text is entered in lowercase. Any assistance in a code that can accomplish this in VBA for Access would be appreciated. I am able to use the functions individually but am new to coding and am unsure how to string them together correctly.

```<code>Private Sub cmdGreeting_Click()
strOutput = Left(txtInput.Value, 1) & Mid(txtinput.value, 1) & Right(txtinput.value, 1)
lblOutput.Caption = strOutput
End Sub
</code>```

This is as far as I have gotten and I know it's incorrect because I have no idea how to account for the 3 separate names.

答:
Here's a function based on regex. I'm sure someone will chip in to improve it, my VBA regex is rusty. It's based on the regex here where you can see examples of it matching. If you're not familiar with regex at all, they're frightening initially and it's beyond the scope of an answer to explain them.

However, it works by breaking any input into 5 strings:

Initial character of first name

remainder of name

Initial and . if present

Initial letter of last name

remainder of last name

Then, with some simple UCase and LCase, you can compile the require, formatted name. You may want to change the logic - you did imply there would be a middle initial but this assumes it won't always be there, and the dot after the initial may or may not be there.

Note: you need to enable regex in Excel - instructions

```<code>Sub normalise()
    Debug.Print (proper("Reginald D. Hunter"))
    Debug.Print (proper("reginald D. hunter"))
    Debug.Print (proper("rEGINALD d. Hunter"))
    Debug.Print (proper("Reginald D Hunter"))
    Debug.Print (proper("Reginald Hunter"))
    Debug.Print (proper("Reginald      D.      Hunter"))
End Sub

Function proper(text) As String

    Dim regexMatch As Object
    Dim matches As Object

    With New RegExp
        .Global = False
        .MultiLine = False
        .IgnoreCase = False
        .Pattern = "([a-zA-Z])([^ ]*)\s*([a-zA-Z]?[. ])?\s*([a-zA-Z])([^ ]*)"
        If .test(text) Then
            For Each regexMatch In .Execute(text)
                Set matches = regexMatch.SubMatches
            Next
        End If
    End With
    proper = UCase(matches(0)) + LCase(matches(1))
    If Trim(matches(2)) <> "" Then
        If InStr(matches(2), ".") Then
            proper = proper + " " + Trim(UCase(matches(2))) + " "
        Else
            proper = proper + " " + Trim(UCase(matches(2))) + ". "
        End If
    Else
        proper = proper + " "
    End If
    proper = proper + UCase(matches(3)) + LCase(matches(4))
End Function
</code>```

Results in

Reginald D. Hunter

Reginald D. Hunter

Reginald D. Hunter

Reginald D. Hunter

Reginald Hunter

Reginald D. Hunter

Edit: I misread the question and if you just want initials then replace the last part of the function like so:

```<code>proper = UCase(matches(0))
If Trim(matches(2)) <> "" Then
    If InStr(matches(2), ".") Then
        proper = proper + Replace(Trim(UCase(matches(2))), ".", "")
    Else
        proper = proper + Trim(UCase(matches(2)))
    End If
End If
proper = proper + UCase(matches(3))
</code>```

gives:

RDH

RDH

RDH

RDH

RH

RDH

Body:
I am looking to extract initials from a single textbox using Left, mid and other similar functions. The user enters their first, middle initial and last name; assuming spaces and a period after the middle initial. I need to ensure the initials extracted are uppercase, even if the text is entered in lowercase. Any assistance in a code that can accomplish this in VBA for Access would be appreciated. I am able to use the functions individually but am new to coding and am unsure how to string them together correctly.

Private Sub cmdGreeting_Click()
strOutput = Left(txtInput.Value, 1) & Mid(txtinput.value, 1) & Right(txtinput.value, 1)
lblOutput.Caption = strOutput
End Sub

This is as far as I have gotten and I know it's incorrect because I have no idea how to account for the 3 separate names.

Body:
Here's a function based on regex. I'm sure someone will chip in to improve it, my VBA regex is rusty. It's based on the regex here where you can see examples of it matching. If you're not familiar with regex at all, they're frightening initially and it's beyond the scope of an answer to explain them.

However, it works by breaking any input into 5 strings:

Initial character of first name

remainder of name

Initial and . if present

Initial letter of last name

remainder of last name

Then, with some simple UCase and LCase, you can compile the require, formatted name. You may want to change the logic - you did imply there would be a middle initial but this assumes it won't always be there, and the dot after the initial may or may not be there.

Note: you need to enable regex in Excel - instructions

Sub normalise()
    Debug.Print (proper("Reginald D. Hunter"))
    Debug.Print (proper("reginald D. hunter"))
    Debug.Print (proper("rEGINALD d. Hunter"))
    Debug.Print (proper("Reginald D Hunter"))
    Debug.Print (proper("Reginald Hunter"))
    Debug.Print (proper("Reginald      D.      Hunter"))
End Sub

Function proper(text) As String

    Dim regexMatch As Object
    Dim matches As Object

    With New RegExp
        .Global = False
        .MultiLine = False
        .IgnoreCase = False
        .Pattern = "([a-zA-Z])([^ ]*)\s*([a-zA-Z]?[. ])?\s*([a-zA-Z])([^ ]*)"
        If .test(text) Then
            For Each regexMatch In .Execute(text)
                Set matches = regexMatch.SubMatches
            Next
        End If
    End With
    proper = UCase(matches(0)) + LCase(matches(1))
    If Trim(matches(2)) <> "" Then
        If InStr(matches(2), ".") Then
            proper = proper + " " + Trim(UCase(matches(2))) + " "
        Else
            proper = proper + " " + Trim(UCase(matches(2))) + ". "
        End If
    Else
        proper = proper + " "
    End If
    proper = proper + UCase(matches(3)) + LCase(matches(4))
End Function

Results in

Reginald D. Hunter

Reginald D. Hunter

Reginald D. Hunter

Reginald D. Hunter

Reginald Hunter

Reginald D. Hunter

Edit: I misread the question and if you just want initials then replace the last part of the function like so:

proper = UCase(matches(0))
If Trim(matches(2)) <> "" Then
    If InStr(matches(2), ".") Then
        proper = proper + Replace(Trim(UCase(matches(2))), ".", "")
    Else
        proper = proper + Trim(UCase(matches(2)))
    End If
End If
proper = proper + UCase(matches(3))

gives:

RDH

RDH

RDH

RDH

RH

RDH


问:
Gerrit ref-update hook is not getting invoked
Installed Gerrit (version 2.13.1) by following the steps in the following link:

https://gerrit-review.googlesource.com/Documentation/install-quick.html
in Ubuntu 16.04 environment.

Created a hooks folder in '$site_path'/hooks and added a ref-update hook file which just exits with return code 1.

Provided executable permissions to this file.

After Gerrit server restart, it is allowing me to do a push operation.

答:
I'm using Gerrit 2.14. This works for me:

Behavior change in ref-update hook

Instead of being invoked on every commit received, the ref-update hook is now invoked before the ref update operation is finalized. The previous behavior of the ref-update hook is moved into a new hook named commit-received.

Sites using the ref-update hook should rename the hook file to commit-received.

https://www.gerritcodereview.com/releases/2.14.md#Behavior-change-in-ref_update-hook


问:
Idempiere: 'External POS Integration' option not showing up in Menu
I am trying to setup Unicenta POS on my Windows 10 64 bit machine.

My configuration:

Idempiere server v5.1 (http://127.0.0.1:8080/)

ActiveMQ v5.15.2
(http://127.0.0.1:8161/)

POS Integration plugin (Available
here)

I followed instructions given Here. ActiveMQ is running fine, Unicenta can also send request to ActiveMQ, I can see that in Queues. Idempiere server is also running fine.

I installed POS integration plugin through Felix Web Console. It shows up in the list and It is active. But, that plugin doesn't show up in Idempiere Menu option. Either that plugin has some problems or I am missing something.

I also performed Role Access Update on GardenWorld Client Admin but that didn't change anything. Menu option is still missing.

Please help.

答:
The real issue was that 2Pack did not Pack in into the Database. I had install 2Pack manually and Pack In in my SystemAdmin. After that I logged out and logged in with SuperUser credentials and with GardenAdmin role. And then menu item appeared!

2Pack zip file location - Download

How to Pack In:


问:
How to display my TextBlock of ListBox HORIZONTALLY in RSS Feed WPF code
I know it's simple but I spent a lot of time to display my the list horizontally. I even put the make StackPanel orientation "Horizontal" but all in vain. Can anyone help with this? I would really appreciate that.

```<code><Window x:Class="RssFeed_Wpf.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:RssFeed_Wpf"
    mc:Ignorable="d"
    Title="MainWindow" Height="350" Width="525">
<Window.Resources>
    <XmlDataProvider x:Key="DataRss" XPath="//item" Source="http://www.abc.net.au/news/feed/52278/rss.xmlhttp://www.abc.net.au/news/feed/45910/rss.xml">
    </XmlDataProvider>
</Window.Resources>
    <ListBox ItemsSource="{Binding Source = {StaticResource DataRss}}" Background="Black" HorizontalContentAlignment="Left" BorderBrush="Transparent">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding XPath=title}" FontWeight="Bold" Name="txtScrolling" FontFamily="calibri"  Foreground="#f4b042" Height="20pt">
                    </TextBlock>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
 </Window>
</code>```

You can see here, The list is shown vertically but I want this horizontally:

答:
Because your StackPanel is in the DataTemplate there is a StackPanel created for every item in the ListBox.  To change the container for the ListBox you need to sets it ItemsPanel

```<code><ListBox >
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel Orientation="Horizontal"/>
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
</ListBox>
</code>```

Body:
I know it's simple but I spent a lot of time to display my the list horizontally. I even put the make StackPanel orientation "Horizontal" but all in vain. Can anyone help with this? I would really appreciate that.

<Window x:Class="RssFeed_Wpf.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:RssFeed_Wpf"
    mc:Ignorable="d"
    Title="MainWindow" Height="350" Width="525">
<Window.Resources>
    <XmlDataProvider x:Key="DataRss" XPath="//item" Source="http://www.abc.net.au/news/feed/52278/rss.xmlhttp://www.abc.net.au/news/feed/45910/rss.xml">
    </XmlDataProvider>
</Window.Resources>
    <ListBox ItemsSource="{Binding Source = {StaticResource DataRss}}" Background="Black" HorizontalContentAlignment="Left" BorderBrush="Transparent">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding XPath=title}" FontWeight="Bold" Name="txtScrolling" FontFamily="calibri"  Foreground="#f4b042" Height="20pt">
                    </TextBlock>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
 </Window>

You can see here, The list is shown vertically but I want this horizontally:

Body:
Because your StackPanel is in the DataTemplate there is a StackPanel created for every item in the ListBox.  To change the container for the ListBox you need to sets it ItemsPanel

<ListBox >
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel Orientation="Horizontal"/>
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
</ListBox>


问:
Tapi3lib.ITAddress does not return all devices
In an effort to automate some phone calling processes and integrate TAPI3 with another application, I am using to following code that was found as a sample;

```<code>tapi = new TAPI3Lib.TAPIClass();
tapi.Initialize();
foreach (TAPI3Lib.ITAddress ad in (tapi.Addresses as TAPI3Lib.ITCollection))
        cbLines.Items.Add(ad.AddressName);
</code>```

This code fills the devices in a dropdown and the dropdown only contains one device and it only shows from my computer. I tried installing the PIMphony_6.8_bld3200_XX_Alcatel on other computers where i add the IP address of the PBX device and a phone number (ex: 106) but it does not even show in the list the one device that i can see on my computer. I whatsoever have no idea what and how i managed to be able to see the device on my computer when i run this code. Obviously i am missing something. The devices we are using are Alcatel and the phone can be controlled by this app only on my computer. (i can provide the zip file containing PIMphony_6.8_bld3200_XX_Alcatel if needed). So the ultimate goal is to be able to see telephone lines on all computers so we can control them from the computer.

What am i missing Tapi3 experts? is it a missing installation on the other pc's ? and why only my device shows up?

答:
You need a 3rd party TAPI driver installed, it might be on a DVD with the PBXor on some support website, but some manufacturers charge extra for it. This PIMphony looks like a phone control tool but that does not guarantee it is using TAPI  under the hood, it may be using some propitiatory protocol.

I don't know TAPI3 but if you use TAPI correctly you should see 3 to 4 standard windows builtin devices (like WAN miniports) even if you have no drivers installed.

You need a decent test tool to compare results with, I would recommend phone.exe, it is kind of the standard test tool in the TAPI business. But it's getting harder to find online these days, here is a link to a slighly extended variant that google got me quickly: https://helpdesk.estos.de/Knowledgebase/Article/View/82/3/howto-ephoneexe--tapi-test-tool

Body:
In an effort to automate some phone calling processes and integrate TAPI3 with another application, I am using to following code that was found as a sample;

tapi = new TAPI3Lib.TAPIClass();
tapi.Initialize();
foreach (TAPI3Lib.ITAddress ad in (tapi.Addresses as TAPI3Lib.ITCollection))
        cbLines.Items.Add(ad.AddressName);

This code fills the devices in a dropdown and the dropdown only contains one device and it only shows from my computer. I tried installing the PIMphony_6.8_bld3200_XX_Alcatel on other computers where i add the IP address of the PBX device and a phone number (ex: 106) but it does not even show in the list the one device that i can see on my computer. I whatsoever have no idea what and how i managed to be able to see the device on my computer when i run this code. Obviously i am missing something. The devices we are using are Alcatel and the phone can be controlled by this app only on my computer. (i can provide the zip file containing PIMphony_6.8_bld3200_XX_Alcatel if needed). So the ultimate goal is to be able to see telephone lines on all computers so we can control them from the computer.

What am i missing Tapi3 experts? is it a missing installation on the other pc's ? and why only my device shows up?


问:
How to solve 'does not name a type' during opencv compiling using mingw32-make?
I'm trying to compile opencv with extra modules for java (ximgproc). After generating files with Cmake, I tried to use "mingw32-make" command with cmd to generate .jar and .dll, but I got the error below.

I'm following this guide: https://zami0xzami.wordpress.com/2016/03/16/building-java-wrapper-for-opencv/

How can I resolve it?

```<code> C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:175:14: error: 'thread' in namespace 'std' does not name a type
         std::thread second_workthread;
              ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:176:14: error: 'mutex' in namespace 'std' does not name a type
         std::mutex mtx;
              ^~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:177:14: error: 'condition_variable' in namespace 'std' does not name a type
         std::condition_variable objectDetectorRun;
              ^~~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:178:14: error: 'condition_variable' in namespace 'std' does not name a type
         std::condition_variable objectDetectorThreadStartStop;
              ^~~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::setParameters(const cv::DetectionBasedTracker::Parameters&)':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:143:30: error: 'mutex' is not a member of 'std'
             std::unique_lock<std::mutex> mtx_lock(mtx);
                              ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:143:30: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:143:40: error: template argument 1 is invalid
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                        ^
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:143:51: error: 'mtx' was not declared in this scope
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                                   ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:143:42: warning: unused variable 'mtx_lock' [-Wunused-variable]
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                          ^~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::init()':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:156:30: error: 'mutex' is not a member of 'std'
             std::unique_lock<std::mutex> mtx_lock(mtx);
                              ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:156:30: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:156:40: error: template argument 1 is invalid
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                        ^
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:156:51: error: 'mtx' was not declared in this scope
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                                   ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:164:13: error: 'objectDetectorThreadStartStop' was not declared in this scope
             objectDetectorThreadStartStop.notify_one();
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:156:42: warning: unused variable 'mtx_lock' [-Wunused-variable]
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                          ^~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In destructor 'virtual cv::DetectionBasedTracker::SeparateDetectionWork::~SeparateDetectionWork()':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:254:5: error: 'second_workthread' was not declared in this scope
     second_workthread.join();
     ^~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'bool cv::DetectionBasedTracker::SeparateDetectionWork::run()':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:261:22: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                      ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:261:22: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:261:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:261:43: error: 'mtx' was not declared in this scope
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                           ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:275:5: error: 'second_workthread' was not declared in this scope
     second_workthread = std::thread(workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes?
     ^~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:275:25: error: 'thread' is not a member of 'std'
     second_workthread = std::thread(workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes?
                         ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:276:5: error: 'objectDetectorThreadStartStop' was not declared in this scope
     objectDetectorThreadStartStop.wait(mtx_lock);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector()':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:317:22: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                      ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:317:22: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:317:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:317:43: error: 'mtx' was not declared in this scope
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                           ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:323:9: error: 'objectDetectorThreadStartStop' was not declared in this scope
         objectDetectorThreadStartStop.notify_one();
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:330:9: error: 'objectDetectorRun' was not declared in this scope
         objectDetectorRun.wait(mtx_lock);
         ^~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:340:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
     mtx_lock.unlock();
              ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:357:22: error: request for member 'lock' in 'mtx_lock', which is of non-class type 'int'
             mtx_lock.lock();
                      ^~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:364:26: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
                 mtx_lock.unlock();
                          ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:372:13: error: 'objectDetectorRun' was not declared in this scope
             objectDetectorRun.wait(mtx_lock);
             ^~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:380:22: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
             mtx_lock.unlock();
                      ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:431:18: error: request for member 'lock' in 'mtx_lock', which is of non-class type 'int'
         mtx_lock.lock();
                  ^~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:447:18: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
         mtx_lock.unlock();
                  ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::stop()':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:462:20: error: 'mutex' is not a member of 'std'
   std::unique_lock<std::mutex> mtx_lock(mtx);
                    ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:462:20: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:462:30: error: template argument 1 is invalid
   std::unique_lock<std::mutex> mtx_lock(mtx);
                              ^
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:462:41: error: 'mtx' was not declared in this scope
   std::unique_lock<std::mutex> mtx_lock(mtx);
                                         ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:468:18: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
         mtx_lock.unlock();
                  ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:479:5: error: 'objectDetectorRun' was not declared in this scope
     objectDetectorRun.notify_one();
     ^~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:480:5: error: 'objectDetectorThreadStartStop' was not declared in this scope
     objectDetectorThreadStartStop.wait(mtx_lock);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:482:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
     mtx_lock.unlock();
              ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::resetTracking()':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:495:22: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                      ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:495:22: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:495:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:495:43: error: 'mtx' was not declared in this scope
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                           ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:512:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
     mtx_lock.unlock();
              ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread(const cv::Mat&, std::vector<cv::Rect_<int> >&)':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:533:22: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                      ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:533:22: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:533:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:533:43: error: 'mtx' was not declared in this scope
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                           ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:566:9: error: 'objectDetectorRun' was not declared in this scope
         objectDetectorRun.notify_one();
         ^~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:573:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
     mtx_lock.unlock();
              ^~~~~~
modules\objdetect\CMakeFiles\opencv_objdetect.dir\build.make:121: recipe for target 'modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/detection_based_tracker.cpp.obj' failed
mingw32-make[2]: *** [modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/detection_based_tracker.cpp.obj] Error 1
CMakeFiles\Makefile2:3724: recipe for target 'modules/objdetect/CMakeFiles/opencv_objdetect.dir/all' failed
mingw32-make[1]: *** [modules/objdetect/CMakeFiles/opencv_objdetect.dir/all] Error 2
Makefile:161: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
</code>```

答:
The used compiler is not configured to compile with C++11.

If activating it like in RCYR's answer is not feasible for you, you can switch C++11 features off in the build by setting the option ENABLE_CXX11 to OFF (if you set it in the command line: -DENABLE_CXX11=OFF.

See the main CMakeLists.txt of OpenCV:

OCV_OPTION(ENABLE_CXX11 "Enable C++11 compilation mode" "${OPENCV_CXX11}")

Body:
I'm trying to compile opencv with extra modules for java (ximgproc). After generating files with Cmake, I tried to use "mingw32-make" command with cmd to generate .jar and .dll, but I got the error below.

I'm following this guide: https://zami0xzami.wordpress.com/2016/03/16/building-java-wrapper-for-opencv/

How can I resolve it?

 C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:175:14: error: 'thread' in namespace 'std' does not name a type
         std::thread second_workthread;
              ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:176:14: error: 'mutex' in namespace 'std' does not name a type
         std::mutex mtx;
              ^~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:177:14: error: 'condition_variable' in namespace 'std' does not name a type
         std::condition_variable objectDetectorRun;
              ^~~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:178:14: error: 'condition_variable' in namespace 'std' does not name a type
         std::condition_variable objectDetectorThreadStartStop;
              ^~~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::setParameters(const cv::DetectionBasedTracker::Parameters&)':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:143:30: error: 'mutex' is not a member of 'std'
             std::unique_lock<std::mutex> mtx_lock(mtx);
                              ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:143:30: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:143:40: error: template argument 1 is invalid
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                        ^
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:143:51: error: 'mtx' was not declared in this scope
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                                   ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:143:42: warning: unused variable 'mtx_lock' [-Wunused-variable]
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                          ^~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::init()':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:156:30: error: 'mutex' is not a member of 'std'
             std::unique_lock<std::mutex> mtx_lock(mtx);
                              ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:156:30: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:156:40: error: template argument 1 is invalid
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                        ^
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:156:51: error: 'mtx' was not declared in this scope
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                                   ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:164:13: error: 'objectDetectorThreadStartStop' was not declared in this scope
             objectDetectorThreadStartStop.notify_one();
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:156:42: warning: unused variable 'mtx_lock' [-Wunused-variable]
             std::unique_lock<std::mutex> mtx_lock(mtx);
                                          ^~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In destructor 'virtual cv::DetectionBasedTracker::SeparateDetectionWork::~SeparateDetectionWork()':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:254:5: error: 'second_workthread' was not declared in this scope
     second_workthread.join();
     ^~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'bool cv::DetectionBasedTracker::SeparateDetectionWork::run()':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:261:22: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                      ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:261:22: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:261:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:261:43: error: 'mtx' was not declared in this scope
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                           ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:275:5: error: 'second_workthread' was not declared in this scope
     second_workthread = std::thread(workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes?
     ^~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:275:25: error: 'thread' is not a member of 'std'
     second_workthread = std::thread(workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes?
                         ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:276:5: error: 'objectDetectorThreadStartStop' was not declared in this scope
     objectDetectorThreadStartStop.wait(mtx_lock);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector()':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:317:22: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                      ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:317:22: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:317:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:317:43: error: 'mtx' was not declared in this scope
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                           ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:323:9: error: 'objectDetectorThreadStartStop' was not declared in this scope
         objectDetectorThreadStartStop.notify_one();
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:330:9: error: 'objectDetectorRun' was not declared in this scope
         objectDetectorRun.wait(mtx_lock);
         ^~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:340:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
     mtx_lock.unlock();
              ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:357:22: error: request for member 'lock' in 'mtx_lock', which is of non-class type 'int'
             mtx_lock.lock();
                      ^~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:364:26: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
                 mtx_lock.unlock();
                          ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:372:13: error: 'objectDetectorRun' was not declared in this scope
             objectDetectorRun.wait(mtx_lock);
             ^~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:380:22: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
             mtx_lock.unlock();
                      ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:431:18: error: request for member 'lock' in 'mtx_lock', which is of non-class type 'int'
         mtx_lock.lock();
                  ^~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:447:18: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
         mtx_lock.unlock();
                  ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::stop()':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:462:20: error: 'mutex' is not a member of 'std'
   std::unique_lock<std::mutex> mtx_lock(mtx);
                    ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:462:20: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:462:30: error: template argument 1 is invalid
   std::unique_lock<std::mutex> mtx_lock(mtx);
                              ^
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:462:41: error: 'mtx' was not declared in this scope
   std::unique_lock<std::mutex> mtx_lock(mtx);
                                         ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:468:18: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
         mtx_lock.unlock();
                  ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:479:5: error: 'objectDetectorRun' was not declared in this scope
     objectDetectorRun.notify_one();
     ^~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:480:5: error: 'objectDetectorThreadStartStop' was not declared in this scope
     objectDetectorThreadStartStop.wait(mtx_lock);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:482:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
     mtx_lock.unlock();
              ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'void cv::DetectionBasedTracker::SeparateDetectionWork::resetTracking()':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:495:22: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                      ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:495:22: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:495:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:495:43: error: 'mtx' was not declared in this scope
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                           ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:512:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
     mtx_lock.unlock();
              ^~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp: In member function 'bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread(const cv::Mat&, std::vector<cv::Rect_<int> >&)':
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:533:22: error: 'mutex' is not a member of 'std'
     std::unique_lock<std::mutex> mtx_lock(mtx);
                      ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:533:22: error: 'mutex' is not a member of 'std'
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:533:32: error: template argument 1 is invalid
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                ^
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:533:43: error: 'mtx' was not declared in this scope
     std::unique_lock<std::mutex> mtx_lock(mtx);
                                           ^~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:566:9: error: 'objectDetectorRun' was not declared in this scope
         objectDetectorRun.notify_one();
         ^~~~~~~~~~~~~~~~~
C:\Users\Jt1995\Desktop\opencv-master\modules\objdetect\src\detection_based_tracker.cpp:573:14: error: request for member 'unlock' in 'mtx_lock', which is of non-class type 'int'
     mtx_lock.unlock();
              ^~~~~~
modules\objdetect\CMakeFiles\opencv_objdetect.dir\build.make:121: recipe for target 'modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/detection_based_tracker.cpp.obj' failed
mingw32-make[2]: *** [modules/objdetect/CMakeFiles/opencv_objdetect.dir/src/detection_based_tracker.cpp.obj] Error 1
CMakeFiles\Makefile2:3724: recipe for target 'modules/objdetect/CMakeFiles/opencv_objdetect.dir/all' failed
mingw32-make[1]: *** [modules/objdetect/CMakeFiles/opencv_objdetect.dir/all] Error 2
Makefile:161: recipe for target 'all' failed
mingw32-make: *** [all] Error 2


问:
How to use a tab navigator inside a tab navigator?
I am new to React-Native and trying to create a app in which i want to use 2 tab navigator ; outer tab and inner tab.

outer tab for tanks, alerts and settings...
inner tab inside tanks for mapview and listview...

```<code>export default class Home extends Component {
static navigationOptions = {
    header:null
};

constructor(props) {
    super(props);
    this.state = {
    }
}

render() {
    return (
        <MyApp/>
    );
}
}
export const MyApp = TabNavigator({

tanks: {
screen: TanksScreen
},
alerts: {
screen: AlertScreen
},
 Settings: {
    screen: SettingScreen
 },
},
</code>```

And this following code in TanksScreen

```<code>export default class TanksScreen extends Component {
static navigationOptions = {
header:null
};

constructor(props) {
  super(props);
  this.state = {
  }
}
render() {
  return (
      <MapsView/>
  );
}
}
export const MapsView = TabNavigator({

Map: {
 screen: MapsScreen,
},
List: {
 screen: ListScreen,
},
},
</code>```

By using the above code, i am able to get full functionality of outer tab navigator but when it comes to inner tab, the tab is neither not navigating to listview screen nor rendering any text or ui components in mapsview.

Am i doing anything wrong? or is there any way to accomplish this requirement. thanks in advance

答:
Since your TanksScreen component only returns the inner tabs, you can just plug them into the outer tab directly, which should solve the problem.

```<code>export const MyApp = TabNavigator({
  tanks: {
    screen: MapsView
  },
  alerts: {
    screen: AlertScreen
  },
  Settings: {
    screen: SettingScreen
  },
}
</code>```

Body:
I am new to React-Native and trying to create a app in which i want to use 2 tab navigator ; outer tab and inner tab.

outer tab for tanks, alerts and settings...
inner tab inside tanks for mapview and listview...

export default class Home extends Component {
static navigationOptions = {
    header:null
};

constructor(props) {
    super(props);
    this.state = {
    }
}

render() {
    return (
        <MyApp/>
    );
}
}
export const MyApp = TabNavigator({

tanks: {
screen: TanksScreen
},
alerts: {
screen: AlertScreen
},
 Settings: {
    screen: SettingScreen
 },
},

And this following code in TanksScreen

export default class TanksScreen extends Component {
static navigationOptions = {
header:null
};

constructor(props) {
  super(props);
  this.state = {
  }
}
render() {
  return (
      <MapsView/>
  );
}
}
export const MapsView = TabNavigator({

Map: {
 screen: MapsScreen,
},
List: {
 screen: ListScreen,
},
},

By using the above code, i am able to get full functionality of outer tab navigator but when it comes to inner tab, the tab is neither not navigating to listview screen nor rendering any text or ui components in mapsview.

Am i doing anything wrong? or is there any way to accomplish this requirement. thanks in advance

Body:
Since your TanksScreen component only returns the inner tabs, you can just plug them into the outer tab directly, which should solve the problem.

export const MyApp = TabNavigator({
  tanks: {
    screen: MapsView
  },
  alerts: {
    screen: AlertScreen
  },
  Settings: {
    screen: SettingScreen
  },
}


问:
Setting a property in another VC by using presentViewController method
I am trying to set a .text properties in another viewController class but it does not get set. how can I achieve this result without using a segue?

```<code>AccountTypeVC *vc = (AccountTypeVC *)[mainStoryboard instantiateViewControllerWithIdentifier:@"AccountTypeVC"];
AccountTypeVC.serviceTitle.text = [tableData objectAtIndex:indexPath.row];
[self presentViewController:vc animated:NO completion:nil];
</code>```

The .h of AccountTypeVC

@property (strong, nonatomic) IBOutlet UILabel *serviceTitle;

答:
It's not necessary that after instantiateViewControllerWithIdentifier all the UI elements are initialised. Recommended is to bind all the UI elements with data once the viewDidLoad of the view controller has been called.

Add another property in AccountTypeVC.

```<code>@property (strong, nonatomic) NSString *serviceTitleText;
</code>```

And set it to label in viewDidLoad method.

```<code>- (void)viewDidLoad {
    [super viewDidLoad];
    self.serviceTitle.text = self. serviceTitleText;
}
</code>```

And set serviceTitleText property instead of label before presenting the AccountTypeVC.

```<code>AccountTypeVC *vc = (AccountTypeVC *)[mainStoryboard instantiateViewControllerWithIdentifier:@"AccountTypeVC"];
vc.serviceTitleText = [tableData objectAtIndex:indexPath.row];
[self presentViewController:vc animated:NO completion:nil];
</code>```

Body:
I am trying to set a .text properties in another viewController class but it does not get set. how can I achieve this result without using a segue?

AccountTypeVC *vc = (AccountTypeVC *)[mainStoryboard instantiateViewControllerWithIdentifier:@"AccountTypeVC"];
AccountTypeVC.serviceTitle.text = [tableData objectAtIndex:indexPath.row];
[self presentViewController:vc animated:NO completion:nil];

The .h of AccountTypeVC

@property (strong, nonatomic) IBOutlet UILabel *serviceTitle;

Body:
It's not necessary that after instantiateViewControllerWithIdentifier all the UI elements are initialised. Recommended is to bind all the UI elements with data once the viewDidLoad of the view controller has been called.

Add another property in AccountTypeVC.

@property (strong, nonatomic) NSString *serviceTitleText;

And set it to label in viewDidLoad method.

- (void)viewDidLoad {
    [super viewDidLoad];
    self.serviceTitle.text = self. serviceTitleText;
}

And set serviceTitleText property instead of label before presenting the AccountTypeVC.

AccountTypeVC *vc = (AccountTypeVC *)[mainStoryboard instantiateViewControllerWithIdentifier:@"AccountTypeVC"];
vc.serviceTitleText = [tableData objectAtIndex:indexPath.row];
[self presentViewController:vc animated:NO completion:nil];


问:
Install npm package without dependencies
I am looking for best solution how to install npm package without it's dependencies described in it's package.json file.

The goal is to change dependencies versions before install package. I can do it manually for one package by downloading source, but if you have many nested dependencies it becomes a problem.

答:
Please check simialr quesition on stackexchange: https://unix.stackexchange.com/questions/168034/is-there-an-option-to-install-an-npm-package-without-dependencies

My solution was to rename package.json to package.bak before the install, then reverting rename afterwards:

```<code>RENAME package.json package.bak
npm install <package_name> --no-save
RENAME package.bak package.json
</code>```

Body:
Please check simialr quesition on stackexchange: https://unix.stackexchange.com/questions/168034/is-there-an-option-to-install-an-npm-package-without-dependencies

My solution was to rename package.json to package.bak before the install, then reverting rename afterwards:

RENAME package.json package.bak
npm install <package_name> --no-save
RENAME package.bak package.json


问:
insert a query to database table to prevent auto increment to skip numbers
If user registration has failed, ID (which is set to AUTO INCREMENT) skips a number. To prevent this, I came up with the code below. But rather inserting the word 'Registration error' to winningSegment under table tb_prizewon it only prints the message in die() function

```<code>if (!$success) {
    $query2   = "INSERT into tb_prizewon (winningSegment) VALUES('Registration error')";
    die("Number already registered! Please try again.");
}
</code>```

winningSegment is supposed to be the prize won by the user after spinning a wheel of fortune after a successful registration of his info. tb_prizewon table also have an AUTO_INCREMENT field for ID

答:
You have to be set default value  for other fields in your table, unless you define another field in your query. For example if you have 4 field in tb_prizewon you must have Something like this

```<code>$query2   = "INSERT into tb_prizewon (winningSegment,name,username,password) VALUES('Registration error','1\','','')";
</code>```

Body:
If user registration has failed, ID (which is set to AUTO INCREMENT) skips a number. To prevent this, I came up with the code below. But rather inserting the word 'Registration error' to winningSegment under table tb_prizewon it only prints the message in die() function

if (!$success) {
    $query2   = "INSERT into tb_prizewon (winningSegment) VALUES('Registration error')";
    die("Number already registered! Please try again.");
}

winningSegment is supposed to be the prize won by the user after spinning a wheel of fortune after a successful registration of his info. tb_prizewon table also have an AUTO_INCREMENT field for ID

Body:
You have to be set default value  for other fields in your table, unless you define another field in your query. For example if you have 4 field in tb_prizewon you must have Something like this

$query2   = "INSERT into tb_prizewon (winningSegment,name,username,password) VALUES('Registration error','1\','','')";


问:
count of $lookup result mongodb
Using mongodb with NodeJS driver

I have 2 collections. One for department and other for students.

Sample data for Deparmtent.

```<code>{
 "_id" : ObjectId("5a24d20590d3d12155f3094e"), "name" : "CSE", "hod" :
 "abc",
 "students" : [
  ObjectId("5a2129172c3e542acb78c1f5"),
  ObjectId("5a2129172c3e542acb78c1f7"),
  ObjectId("5a2129172c3e542acb78c1f9"),
  ObjectId("5a2129172c3e542acb78c1fb")
 ]
}

{
 "_id" : ObjectId("5a24d20590d3d12155f3094f"),
 "name" : "IT",
 "hod" : "xyz", ,
 "students" : [
  ObjectId("5a2129172c3e542acb78c1f6"),
  ObjectId("5a2129172c3e542acb78c1f8"),
  ObjectId("5a2129172c3e542acb78c1fa"),
  ObjectId("5a2129172c3e542acb78c1fc")
 ]
}
</code>```

and sample data for Students

```<code>{
    "_id" : ObjectId("5a2129172c3e542acb78c1f4"),
    "rollNumber" : 11,
    "name" : "Thor",
    "branch" : ObjectId("5a24d20590d3d12155f3094e"),
}
</code>```

Here is the query:

```<code>aggregate([
   {$lookup:
     { from: "students",
       localField: "_id",
       foreignField: "branch",
       as: "studentData"
     }
   }
])
</code>```

Output of the query

```<code>[
  { _id: 5a24d20590d3d12155f3094e,
    name: 'CSE',
    hod: 'abc',
    studentData: [ [Object], [Object], [Object], [Object], [Object] ]
  },
  { _id: 5a24d20590d3d12155f3094f,
    name: 'IT',
    hod: 'xyz',
    studentData: [ [Object], [Object], [Object], [Object] ] }
]
</code>```

I have two questions

How to print complete student data.

How to get the count of studentData for each Department

答:
To get complete student data you can do something like

```<code>db.student.aggregate(
        [
            {
            $lookup:
                {
                    from:"department",
                    localField:"branch",
                    foreignField:"_id",
                    as:"branch"
                }
            }
        ]
    )
</code>```

This will give you something like this:

```<code>{
    "_id" : 1.0,
    "rollNumber" : 110.0,
    "name" : "Thor",
    "branch" : [
        {
            "_id" : 1.0,
            "name" : "CSE",
            "hod" : "abc"
        }
    ]
}
</code>```

To get the count of studentData for each Department

```<code>db.getCollection('student').aggregate(
    [
        {
        $lookup:
            {
                from:"department",
                localField:"branch",
                foreignField:"_id",
                as:"branch"
            }
        },
        {
            $group:
            {
                _id:"$branch",
                "numOfStudent":{$sum:1},
                "listOfStudents":{$push:"$name"}
            }
        }
    ]
)
</code>```

This will give you something like this:

```<code>{
    "_id" : [
        {
            "_id" : 2.0,
            "name" : "IT",
            "hod" : "xyz"
        }
    ],
    "numOfStudent" : 1.0,
    "listOfStudents" : [
        "Ironman2"
    ]
}
{
    "_id" : [
        {
            "_id" : 1.0,
            "name" : "CSE",
            "hod" : "abc"
        }
    ],
    "numOfStudent" : 3.0,
    "listOfStudents" : [
        "Thor",
        "Ironman",
        "Ironman3"
    ]
}
</code>```

You can change $push:$name to $push:$_id If you want to store the Ids of students and not their names.

EDIT
Get similar result using "Departments" collection:

```<code>db.department.aggregate([
{
    $lookup:
                {
                    from:"student",
                    localField:"students",
                    foreignField:"_id",
                    as:"studentsDetails"
                }
},
{
    $project:{
            _id:0,
            name:"$name",
            hod:"$hod",
            numOfStudents:{$size:"$studentsDetails"},
            students:"$studentsDetails"
        }
}
])
</code>```

This will give you something like this:

```<code>{
    "name" : "CSE",
    "hod" : "abc",
    "numOfStudents" : 2,
    "students" : [
        {
            "_id" : 1.0,
            "rollNumber" : 110.0,
            "name" : "Thor",
            "branch" : 1.0
        },
        {
            "_id" : 3.0,
            "rollNumber" : 111.0,
            "name" : "Ironman2",
            "branch" : 2.0
        }
    ]
}
</code>```

ContentLicense: CC BY-SA 4.0

Title: count of $lookup result mongodb

Body:
Using mongodb with NodeJS driver

I have 2 collections. One for department and other for students.

Sample data for Deparmtent.

{
 "_id" : ObjectId("5a24d20590d3d12155f3094e"), "name" : "CSE", "hod" :
 "abc",
 "students" : [
  ObjectId("5a2129172c3e542acb78c1f5"),
  ObjectId("5a2129172c3e542acb78c1f7"),
  ObjectId("5a2129172c3e542acb78c1f9"),
  ObjectId("5a2129172c3e542acb78c1fb")
 ]
}

{
 "_id" : ObjectId("5a24d20590d3d12155f3094f"),
 "name" : "IT",
 "hod" : "xyz", ,
 "students" : [
  ObjectId("5a2129172c3e542acb78c1f6"),
  ObjectId("5a2129172c3e542acb78c1f8"),
  ObjectId("5a2129172c3e542acb78c1fa"),
  ObjectId("5a2129172c3e542acb78c1fc")
 ]
}

and sample data for Students

{
    "_id" : ObjectId("5a2129172c3e542acb78c1f4"),
    "rollNumber" : 11,
    "name" : "Thor",
    "branch" : ObjectId("5a24d20590d3d12155f3094e"),
}

Here is the query:

aggregate([
   {$lookup:
     { from: "students",
       localField: "_id",
       foreignField: "branch",
       as: "studentData"
     }
   }
])

Output of the query

[
  { _id: 5a24d20590d3d12155f3094e,
    name: 'CSE',
    hod: 'abc',
    studentData: [ [Object], [Object], [Object], [Object], [Object] ]
  },
  { _id: 5a24d20590d3d12155f3094f,
    name: 'IT',
    hod: 'xyz',
    studentData: [ [Object], [Object], [Object], [Object] ] }
]

I have two questions

How to print complete student data.

How to get the count of studentData for each Department

Body:
To get complete student data you can do something like

db.student.aggregate(
        [
            {
            $lookup:
                {
                    from:"department",
                    localField:"branch",
                    foreignField:"_id",
                    as:"branch"
                }
            }
        ]
    )

This will give you something like this:

{
    "_id" : 1.0,
    "rollNumber" : 110.0,
    "name" : "Thor",
    "branch" : [
        {
            "_id" : 1.0,
            "name" : "CSE",
            "hod" : "abc"
        }
    ]
}

To get the count of studentData for each Department

db.getCollection('student').aggregate(
    [
        {
        $lookup:
            {
                from:"department",
                localField:"branch",
                foreignField:"_id",
                as:"branch"
            }
        },
        {
            $group:
            {
                _id:"$branch",
                "numOfStudent":{$sum:1},
                "listOfStudents":{$push:"$name"}
            }
        }
    ]
)

This will give you something like this:

{
    "_id" : [
        {
            "_id" : 2.0,
            "name" : "IT",
            "hod" : "xyz"
        }
    ],
    "numOfStudent" : 1.0,
    "listOfStudents" : [
        "Ironman2"
    ]
}
{
    "_id" : [
        {
            "_id" : 1.0,
            "name" : "CSE",
            "hod" : "abc"
        }
    ],
    "numOfStudent" : 3.0,
    "listOfStudents" : [
        "Thor",
        "Ironman",
        "Ironman3"
    ]
}

You can change $push:$name to $push:$_id If you want to store the Ids of students and not their names.

EDIT
Get similar result using "Departments" collection:

db.department.aggregate([
{
    $lookup:
                {
                    from:"student",
                    localField:"students",
                    foreignField:"_id",
                    as:"studentsDetails"
                }
},
{
    $project:{
            _id:0,
            name:"$name",
            hod:"$hod",
            numOfStudents:{$size:"$studentsDetails"},
            students:"$studentsDetails"
        }
}
])

This will give you something like this:

{
    "name" : "CSE",
    "hod" : "abc",
    "numOfStudents" : 2,
    "students" : [
        {
            "_id" : 1.0,
            "rollNumber" : 110.0,
            "name" : "Thor",
            "branch" : 1.0
        },
        {
            "_id" : 3.0,
            "rollNumber" : 111.0,
            "name" : "Ironman2",
            "branch" : 2.0
        }
    ]
}


问:
Disable Button on click if the app doesn't install
I have two buttons on splash screen and I want check if app install or not and give result if app install the button start is work and users can click to go main activity and the other button is disabled click and if the app doesn't install the button start disable and button install and download is working.. how do this?  </p>

```<code>  final Button down_install = (Button) findViewById(R.id.bt_down_install);
        final Button start = (Button) findViewById(R.id.bt_start);
        start.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                    boolean isAppInstalled = appInstalledOrNot("com.facebook.android");
                    if (isAppInstalled) {
                        Intent Start_screen = new Intent(SplashScreen.this, MainActivity.class);
                        startActivity(Start_screen);

                    } else {

                        start.setEnabled(false);

                }

            }

            private boolean appInstalledOrNot(String uri) {
                PackageManager pm = getPackageManager();
                try {
                    pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
                    return true;
                } catch (PackageManager.NameNotFoundException e) {
                }

                return false;

            }
        });
</code>```

答:
```<code> if (isAppInstalled) {
    Intent Start_screen = new Intent(SplashScreen.this, MainActivity.class);
    startActivity(Start_screen);
 } else {
    //start.setEnabled(false);
    start.setOnClickListener(null);
 }
</code>```

Body:
I have two buttons on splash screen and I want check if app install or not and give result if app install the button start is work and users can click to go main activity and the other button is disabled click and if the app doesn't install the button start disable and button install and download is working.. how do this?

  final Button down_install = (Button) findViewById(R.id.bt_down_install);
        final Button start = (Button) findViewById(R.id.bt_start);
        start.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                    boolean isAppInstalled = appInstalledOrNot("com.facebook.android");
                    if (isAppInstalled) {
                        Intent Start_screen = new Intent(SplashScreen.this, MainActivity.class);
                        startActivity(Start_screen);

                    } else {

                        start.setEnabled(false);

                }

            }

            private boolean appInstalledOrNot(String uri) {
                PackageManager pm = getPackageManager();
                try {
                    pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
                    return true;
                } catch (PackageManager.NameNotFoundException e) {
                }

                return false;

            }
        });


问:
Add new column to the whole database table
I have a database (aca) which I need to add a new column to all tables in using one sql query.

I used this approach, but it gives me error when applying the sql query.

```<code>SELECT CONCAT('ALTER TABLE ',
table_schema,
'.',
table_name,
' ADD COLUMN parent default 0;') AS ddl
INTO OUTFILE '/tmp/alter_table.sql'
FROM information_schema.tables
WHERE table_schema = 'aca'
AND table_type = 'base table';

\. /tmp/alter_table.sql
</code>```

this error:

1 - Can't create/write to file '\tmp\alter_table.sql' (Errcode: 2 - No
  such file or directory)

Please, any ideas?

答:
Remove The Input File And Run Below Query</p>

```<code>SELECT CONCAT('ALTER TABLE ',
table_schema,
'.',
table_name,
' ADD COLUMN parent default 0;') AS ddl

FROM information_schema.tables
WHERE table_schema = 'aca'
AND table_type = 'base table';
</code>```

Body:
I have a database (aca) which I need to add a new column to all tables in using one sql query.

I used this approach, but it gives me error when applying the sql query.

SELECT CONCAT('ALTER TABLE ',
table_schema,
'.',
table_name,
' ADD COLUMN parent default 0;') AS ddl
INTO OUTFILE '/tmp/alter_table.sql'
FROM information_schema.tables
WHERE table_schema = 'aca'
AND table_type = 'base table';

\. /tmp/alter_table.sql

this error:

1 - Can't create/write to file '\tmp\alter_table.sql' (Errcode: 2 - No
  such file or directory)

Please, any ideas?

Body:
Remove The Input File And Run Below Query

SELECT CONCAT('ALTER TABLE ',
table_schema,
'.',
table_name,
' ADD COLUMN parent default 0;') AS ddl

FROM information_schema.tables
WHERE table_schema = 'aca'
AND table_type = 'base table';


问:
Using Javascript in CSS
Is it possible to use Javascript inside CSS?

If it is, can you give a simple example?

答: Not in any conventional sense of the phrase "inside CSS."</p>

OwnerDisplayName: HelpMe

Title: Using Javascript in CSS

OwnerDisplayName: Hank Gay


问:
HP LoadRunner - Difference between 2 dates in Days
How does one Calculate the number of Days between 2 dates in HP LoadRunner.

I have limited experience with C language coding.

答:
If you are feeling adventurous you can do this:</p>

```<code>web_js_run(
    "Code=days_between=function(firstDate,secondDate) {return Math.floor((Date.parse(secondDate)-Date.parse(firstDate))/1000/60/60/24);}",
    LAST);

lr_save_string("11/20/2017 23:41:20","D1");
lr_save_string("12/01/2017 02:56:32","D2");

web_js_run(
    "Code=days_between(LR.getParam('D1'),LR.getParam('D2'));",
    "ResultParam=days_between",
    LAST);
</code>```

Body:
If you are feeling adventurous you can do this:

web_js_run(
    "Code=days_between=function(firstDate,secondDate) {return Math.floor((Date.parse(secondDate)-Date.parse(firstDate))/1000/60/60/24);}",
    LAST);

lr_save_string("11/20/2017 23:41:20","D1");
lr_save_string("12/01/2017 02:56:32","D2");

web_js_run(
    "Code=days_between(LR.getParam('D1'),LR.getParam('D2'));",
    "ResultParam=days_between",
    LAST);


问:
why adding a new id column with monotonically increasing id break after 352
I am using pyspark 2.2.0. To add a new column of incrementing value.  I have used following code:

```<code>new_df = df.withColumn('Id', monotonically_increasing_id())
</code>```

But it breaks after row number 352 like this:

Any option to fix this ?

答:
According to the docs the values generated by the function don't have to be consecutive.

The generated ID is guaranteed to be monotonically increasing and unique, but not consecutive

Body:
I am using pyspark 2.2.0. To add a new column of incrementing value.  I have used following code:

new_df = df.withColumn('Id', monotonically_increasing_id())

But it breaks after row number 352 like this:

Any option to fix this ?


问:
how to send details to mail in javascript code
I want to send all input data which filled in the contact form.

contact form in javascript

```<code>function sendMail() {
    $.ajax({
      type: 'POST',
      url: 'https://mandrillapp.com/api/1.0/messages/send.json',
      data: {
        'key': 'YOUR API KEY HERE',
        'message': {
          'from_email': 'YOUR@EMAIL.HERE',
          'to': [
              {
                'email': 'RECIPIENT@EMAIL.HERE',
                'name': 'RECIPIENT NAME (OPTIONAL)',
                'type': 'to'
              }
            ],
          'autotext': 'true',
          'subject': 'YOUR SUBJECT HERE!',
          'html': 'YOUR EMAIL CONTENT HERE! YOU CAN USE HTML!'
        }
      }
     }).done(function(response) {
       console.log(response); // if you're into that sorta thing
     });
}
</code>```

答:
Replace your key/value pairs with values from textboxes like below

```<code>{
  ...
  'subject': $('#txtSubject').val(),
  ...
}
</code>```

Here, txtSubject is id of subject's textbox. Like this you can replace all the fields you want to send to API.

Body:
I want to send all input data which filled in the contact form.

contact form in javascript

function sendMail() {
    $.ajax({
      type: 'POST',
      url: 'https://mandrillapp.com/api/1.0/messages/send.json',
      data: {
        'key': 'YOUR API KEY HERE',
        'message': {
          'from_email': 'YOUR@EMAIL.HERE',
          'to': [
              {
                'email': 'RECIPIENT@EMAIL.HERE',
                'name': 'RECIPIENT NAME (OPTIONAL)',
                'type': 'to'
              }
            ],
          'autotext': 'true',
          'subject': 'YOUR SUBJECT HERE!',
          'html': 'YOUR EMAIL CONTENT HERE! YOU CAN USE HTML!'
        }
      }
     }).done(function(response) {
       console.log(response); // if you're into that sorta thing
     });
}

Body:
Replace your key/value pairs with values from textboxes like below

{
  ...
  'subject': $('#txtSubject').val(),
  ...
}

Here, txtSubject is id of subject's textbox. Like this you can replace all the fields you want to send to API.