Skip to content

Instantly share code, notes, and snippets.

@roman-yagodin
Created October 13, 2014 11:00
Show Gist options
  • Save roman-yagodin/59203f612718c5b283d4 to your computer and use it in GitHub Desktop.
Save roman-yagodin/59203f612718c5b283d4 to your computer and use it in GitHub Desktop.
Feedback helper exploring (Razor, Javascript, jQuery, Rangy)
@{
var errorTabID = Request.QueryString["errortabid"];
var errorContext = Request.QueryString["errorcontext"] ?? "";
if (!string.IsNullOrWhiteSpace(errorTabID))
{
var textAreaID = "#dnn_ctr9144_Feedback_txtBody";
var errorTabUrl = "http://" + Dnn.Portal.PortalAlias.HTTPAlias + "?tabid=" + errorTabID;
<script type="text/javascript">
$(function() {
$("#dnn_ctr9144_Feedback_cmdSend").attr ("onclick", "PreSendFeedback()");
});
function PreSendFeedback ()
{
$("@textAreaID").val( $("@textAreaID").val() +
"\n---\n" + "@errorTabUrl" + "\n" + "@errorContext");
//.attr ("disabled", "true");
}
</script>
}
<p>@Dnn.Tab.TabName</p>
}
<a class="dnnPrimaryAction" onclick="PreSendFeedback ()">Test</a>
<script type="text/javascript" src="/Resources/Shared/scripts/rangy/rangy-core.js"></script>
<style type="text/css">
*.unselectable {
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
/*
Introduced in IE 10.
See http://ie.microsoft.com/testdrive/HTML5/msUserSelect/
*/
-ms-user-select: none;
user-select: none;
}
</style>
@{
<form action="http://www.volgau.com?tabid=4017" method="post" target="_blank">
<input name="errortabid" type="hidden" value="@Dnn.Tab.TabID" />
<input name="errorcontext" type="hidden" value="Error Context Value" />
<input class="dnnSecondaryAction" type="submit" />
</form>
<a class="dnnPrimaryAction unselectable" id="sendfeeback" onclick="javascript:return getErrorContext(this)" target="_blank" unselectable="true">Send feedback</a>
<script type="text/javascript">
/*
$(function() {
rangy.init();
});
*/
function getErrorContext (obj)
{
$(obj).attr ("href", "http://@Dnn.Portal.PortalAlias.HTTPAlias?tabid=4017&[email protected]");
var sel = rangy.getSelection();
var errorContext = encodeURIComponent(sel.toString().replace(/(\n|\r)/gm," ").replace(/\s+/g, " ").replace(/\"/g, "").trim().substring (0,100));
if (!!errorContext)
{
$(obj).attr ("href", $(obj).attr ("href") + "&errorcontext=" + errorContext);
}
return true;
}
</script>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment