-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from jdunkerley/htmlRegEx
Html reg ex
- Loading branch information
Showing
11 changed files
with
10,095 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
$ErrorActionPreference = "Stop" | ||
|
||
$root = Split-Path -Parent $PSCommandPath | ||
Push-Location $root | ||
|
||
gci . | Unblock-File | ||
|
||
Write-Host "Finding Alteryx Admin Install Location..." | ||
$reg = Get-ItemProperty HKLM:\SOFTWARE\WOW6432Node\SRC\Alteryx -ErrorAction SilentlyContinue | ||
if ($reg -ne $null) { | ||
$bin = $reg.InstallDir64 + '\HtmlPlugins\OmnibusRegex' | ||
$cmd = "/c mklink /J ""$bin"" ""$root""" | ||
Start-Process cmd -ArgumentList $cmd -verb RunAs -wait | ||
} | ||
|
||
Write-Host "Finding Alteryx User Install Location..." | ||
$reg = Get-ItemProperty HKCU:\SOFTWARE\SRC\Alteryx -ErrorAction SilentlyContinue | ||
if ($reg -ne $null) { | ||
$bin = $reg.InstallDir64 + '\HtmlPlugins\OmnibusRegex' | ||
New-Item -Path $bin -ItemType SymbolicLink -Value $root | ||
} | ||
|
||
Pop-Location |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
window.PlugInHelper = (() => { return { Create: (alteryx, manager, window) => { | ||
const metaInfo = manager.metaInfo | ||
const formulaConstants = [] | ||
|
||
const jsEvent = (obj) => alteryx.JsEvent(JSON.stringify(obj)) | ||
const openHelpPage = (url) => jsEvent({Event: 'OpenHelpPage', url}) | ||
|
||
let callbackId = 0; | ||
function makeCallback(callback) { | ||
const callbackName = `callback${callbackId++}` | ||
|
||
window[callbackName] = (o) => { | ||
delete window[callbackName] | ||
callback(o) | ||
} | ||
|
||
return callbackName | ||
} | ||
|
||
// Get Formula Constants | ||
let formulaConstantsCallback = () => {} | ||
jsEvent({Event: 'GetFormulaConstants', callback: makeCallback((obj) => { | ||
formulaConstants.push(...obj.formulaConstants.map((c) => { return { name: c.FullName, isNumeric: c.IsNumeric, value: c.Value } })) | ||
formulaConstants.push(...obj.questionConstants.map((c) => { return { name: c.FullName, isNumeric: c.IsNumeric, value: c.Value } })) | ||
formulaConstantsCallback() | ||
})}) | ||
|
||
// Get Connections | ||
const connectionNames = Array(metaInfo.Count).fill().map((_, i) => metaInfo.Get(i).ConnectionName) | ||
const connections = {} | ||
connectionNames.forEach((n, i) => { | ||
const fields = metaInfo.Get(i)._GetFields().map((f, j) => { return { name: f.strName, type: f.strType, size: f.nSize, scale: f.nScale, description: f.strDescription, index: j } }) | ||
connections[n] = fields | ||
}) | ||
|
||
// Read Input Data | ||
function getInputData(connection, rows, callback) { | ||
jsEvent({ | ||
Event: 'GetInputData', | ||
callback: makeCallback(callback), | ||
anchorIndex: 0, | ||
connectionName: connection, | ||
numRecs: rows, | ||
offset: 0}) | ||
} | ||
|
||
function getInputDataArray(connection, rows, callback) { | ||
const newCallback = (o) => { | ||
const newObj = o.data ? o.data.map((d) => { | ||
const output = {} | ||
d.forEach((v, i) => output[o.fields[i].strName] = v) | ||
return output | ||
}) : {} | ||
callback(newObj) | ||
} | ||
getInputData(connection, rows, newCallback) | ||
} | ||
|
||
// Test Expression | ||
function testExpression(expression, callback) { | ||
jsEvent({ | ||
Event: 'TestExpression', | ||
callback: makeCallback(callback), | ||
expression, | ||
customFields: [] | ||
}) | ||
} | ||
|
||
// Formula Preview | ||
function formulaPreview(connection, name, type, expression, callback) { | ||
const previewObject = [{name, type, expression}] | ||
|
||
jsEvent({ | ||
Event: 'FormulaPreview', | ||
connectionName: connection, | ||
anchorIndex: 0, | ||
callback: makeCallback(callback), | ||
expressions: previewObject | ||
}) | ||
|
||
} | ||
|
||
return { | ||
jsEvent, | ||
openHelpPage, | ||
formulaConstants, | ||
connectionNames, | ||
connections, | ||
getInputData, | ||
getInputDataArray, | ||
setFormulaConstantsCallback: (callback) => formulaConstantsCallback = callback, | ||
testExpression, | ||
formulaPreview | ||
} | ||
} } })() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>James HTML Play</title> | ||
|
||
<script type="text/javascript"> | ||
document.write(`<link rel="stylesheet" type="text/css" href="${window.Alteryx.LibDir}1/css/alteryx-config.css">`) | ||
document.write(`<link rel="stylesheet" type="text/css" href="${window.Alteryx.LibDir}1/lib/alteryx/gui/plugin-widgets/alteryx-desktop-widgets.css">`) | ||
document.write(`<link rel="stylesheet" type="text/css" href="${window.Alteryx.LibDir}1/lib/build/designerDesktop.css">`) | ||
document.write(`<script src="${window.Alteryx.LibDir}1/lib/build/designerDesktop.bundle.js">\x3c/script>`) | ||
</script> | ||
<script src="codemirror.js"></script> | ||
<script src="codemirror-regex.js"></script> | ||
<link rel="stylesheet" href="codemirror.css"> | ||
<link rel="stylesheet" href="codemirror-regex.css"> | ||
</head> | ||
<body> | ||
<form> | ||
<fieldset> | ||
<legend class='blueTitle'>Output Method</legend> | ||
<div> | ||
<label for="regexType">Mode</label> | ||
<alteryx-pluginwidget type="DropDown" id="method" dataName="Method"></alteryx-pluginwidget> | ||
</div> | ||
</fieldset> | ||
<fieldset> | ||
<legend class='blueTitle'>Input Field</legend> | ||
<div> | ||
<label for="fieldSelector">Name</label> | ||
<alteryx-pluginwidget type="DropDown" dataType="FieldSelector" id="fieldSelector" dataName="Field" connectionNumber="0" inputNumber="0" fieldType="StringOrDate"></alteryx-pluginwidget> | ||
</div> | ||
<div> | ||
<alteryx-pluginwidget type="CheckBox" id="showPreview" showAsToggle="true" text="Show Preview" dataName="showPreview"></alteryx-pluginwidget> | ||
<pre id="preview" style="background-color: #f7f7f7"> </pre> | ||
</div> | ||
</fieldset> | ||
<fieldset> | ||
<legend class='blueTitle'>Regular Expression</legend> | ||
<div> | ||
<!--DataName RegExExpression--> | ||
<label for="regularExpression">Expression</label> | ||
<textarea id="regularExpression" style="height: 1.5em"></textarea> | ||
</div> | ||
<div> | ||
<alteryx-pluginwidget type="CheckBox" id="caseInsensitive" dataName="CaseInsensitive" showAsToggle="true" text="Case Insensitive"></alteryx-pluginwidget> | ||
</div> | ||
<div id="previewRegex"> | ||
<label for="previewResult">Preview</label> | ||
<pre id="previewResult" style="background-color: #f7f7f7"> </pre> | ||
</div> | ||
</fieldset> | ||
<fieldset id="MatchFieldSet"> | ||
<legend class='blueTitle'>Match Field</legend> | ||
<div> | ||
<label for="matchField">Name</label> | ||
<alteryx-pluginwidget type="TextBox" id="matchField" dataName="MatchField"></alteryx-pluginwidget> | ||
</div> | ||
<div> | ||
<alteryx-pluginwidget type="CheckBox" id="errorUnmatched" dataName="ErrorUnmatched" showAsToggle="true" text="Error if not matched"></alteryx-pluginwidget> | ||
</div> | ||
</fieldset> | ||
<fieldset id="ReplaceFieldSet"> | ||
<legend class='blueTitle'>Replace</legend> | ||
<div> | ||
<label for="replaceExpression">Expression</label> | ||
<alteryx-pluginwidget type="TextBox" id="replaceExpression" dataName="ReplaceExpression"></alteryx-pluginwidget> | ||
</div> | ||
<!--<div> | ||
<alteryx-pluginwidget type="CheckBox" id="copyUnmatched" dataName="CopyUnmatched" showAsToggle="true" text="Copy unmatched text to output"></alteryx-pluginwidget> | ||
</div>--> | ||
</fieldset> | ||
</form> | ||
<script type="text/javascript" src="OmnibusHTMLHelper.js"></script> | ||
<script type="text/javascript" src="OmnibusRegEx.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.