Quip how to have a reply link and inline form for threading

It seems that the difference between a threaded and a non-threaded comment is just the value of the input field “parent” in the form.

<input type="hidden" name="parent" value="0" />

The value is “0” if the comment is not a reply to another comment, else the value is the id of the comment you reply to.

With some Javascript code it should be possible to read the “quip_parent” parameter from the reply-link and write it to input-field “parent” in the form.

<span class="quip-reply-link"><a href="index.php?id=123&quip_thread=mythread&quip_parent=20">Reply</a></span>

Here is some jQuery code to illustrate my point.

[[!Quip? &thread=`mythread` &replyResourceId=`123`]]
<br />
[[!QuipReply? &thread=`mythread`]]

<script>
$(function() {
    //helper function to get a parameter from a url
    function getUrlParameter(sParam, sPageURL)
    {
    	var sURLVariables = sPageURL.split('&');
    	for (var i = 0; i < sURLVariables.length; i++)
    	{
    		var sParameterName = sURLVariables[i].split('=');
    		if (sParameterName[0] == sParam)
    		{
    			return sParameterName[1];
    		}
    	}
    }    
    
    //new click-handler for reply-links
    $(".quip-reply-link a").click(function(e) {
        e.preventDefault();
		
        //extract quip_parent from href
        var parent = getUrlParameter('quip_parent',$(this).attr("href"));		
		//set parent in the form
		$("input[name='parent']").val(parent);
		
		//scroll to form
		$('html, body').animate({
            scrollTop: $("#quip-add-comment-qcom").offset().top
        }, 500);
	});
});
</script>
1 Like