Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select regex group #143

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions extension/devtools/views/SelectorEdit.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@
</div>
</div>

<div class="form-group feature feature-regexgroup">
<label for="regexgroup" class="col-lg-1 control-label">Regex group</label>

<div class="col-lg-10">
<input type="text" class="form-control" name="regexgroup" id="regexgroup" placeholder="regexgroup" value="{{selector.regexgroup}}">
</div>
</div>


<div class="form-group feature feature-extractAttribute">
<label for="extractAttribute" class="col-lg-1 control-label">Attribute name</label>

Expand Down
2 changes: 2 additions & 0 deletions extension/scripts/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ SitemapController.prototype = {
var downloadImage = $("#edit-selector [name=downloadImage]").is(":checked");
var clickPopup = $("#edit-selector [name=clickPopup]").is(":checked");
var regex = $("#edit-selector [name=regex]").val();
var regexgroup = $("#edit-selector [name=regexgroup]").val();
var delay = $("#edit-selector [name=delay]").val();
var extractAttribute = $("#edit-selector [name=extractAttribute]").val();
var parentSelectors = $("#edit-selector [name=parentSelectors]").val();
Expand Down Expand Up @@ -895,6 +896,7 @@ SitemapController.prototype = {
downloadImage: downloadImage,
clickPopup: clickPopup,
regex: regex,
regexgroup: regexgroup,
extractAttribute:extractAttribute,
parentSelectors: parentSelectors,
columns:columns,
Expand Down
10 changes: 8 additions & 2 deletions extension/scripts/Selector/SelectorText.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ var SelectorText = {
var text = $element_clone.text();
if (this.regex !== undefined && this.regex.length) {
var matches = text.match(new RegExp(this.regex));

regexgrp=0;
if (this.regexgroup !== undefined) {
regexgrp=this.regexgroup;
}

if (matches !== null) {
text = matches[0];
text = matches[regexgrp];
}
else {
text = null;
Expand All @@ -64,6 +70,6 @@ var SelectorText = {
},

getFeatures: function () {
return ['multiple', 'regex', 'delay']
return ['multiple', 'regex', 'delay', 'regexgroup']
}
};