Commit d09557a3 authored by Jon Phillips's avatar Jon Phillips
Browse files

Added configs system + queryString output + LINK option

parent 5d4c9cd8
[submodule "js/twitter-bootstrap-wizard"]
path = js/twitter-bootstrap-wizard
url = git@github.com:VinceG/twitter-bootstrap-wizard.git
...@@ -9,7 +9,7 @@ th.version { ...@@ -9,7 +9,7 @@ th.version {
width: 25%; width: 25%;
} }
th.apply-format { th.apply-format {
width: 20%; width: 28%;
} }
#result { #result {
......
...@@ -257,7 +257,7 @@ class="input-block-level" placeholder="If one or more of your preferred licenses ...@@ -257,7 +257,7 @@ class="input-block-level" placeholder="If one or more of your preferred licenses
<label for="patent-type" id="patent-type-label" data-toggle="popover" data-trigger="hover" title="Patent License" data-content="You can choose between a patent license and an identified patent pledge. The patent pledge is an alternative tailored for contributors who are reluctant to sign the patent license and looking for an alternative to control their patents. The patent pledge requires for the pledging contributor to identify the pledged patents and list them in the agreement.">What type of Patent License do you want in your agreement?</label> <label for="patent-type" id="patent-type-label" data-toggle="popover" data-trigger="hover" title="Patent License" data-content="You can choose between a patent license and an identified patent pledge. The patent pledge is an alternative tailored for contributors who are reluctant to sign the patent license and looking for an alternative to control their patents. The patent pledge requires for the pledging contributor to identify the pledged patents and list them in the agreement.">What type of Patent License do you want in your agreement?</label>
<select id="patent-type" name="patent-type" class="input-block-level"> <select id="patent-type" name="patent-type" class="input-block-level">
<option value="Traditional">Traditional Patent License</option> <option value="Traditional">Traditional Patent License</option>
<option value="Patent Pledge">Identified Patent Pledge</option> <option value="Patent-Pledge">Identified Patent Pledge</option>
</select> </select>
...@@ -427,13 +427,13 @@ class="input-block-level" placeholder="If one or more of your preferred licenses ...@@ -427,13 +427,13 @@ class="input-block-level" placeholder="If one or more of your preferred licenses
<tr id="apply-individual"> <tr id="apply-individual">
<td>Individual Contributor License Agreement</td> <td>Individual Contributor License Agreement</td>
<td>Contributor Agreements 1.1</td> <td>Contributor Agreements 1.1</td>
<td><a href="#myHTML" role="button" class="btn btn-primary btn-html" data-toggle="modal" data-inline="true">HTML</a> <form method="POST" action="http://service.fabricatorz.com/html2pdf/" id="html2pdf-form-individual"><input type="hidden" name="title" value="Individual Contributor License Agreement 1.1" /><input type="hidden" class="htmlstore" id="htmlstore-individual" name="htmlstore" /><a role="button" class="btn btn-primary" id="html2pdf-individual" data-inline="true">PDF</a></form></td> <td><a href="#" role="button" class="btn btn-primary btn-html final-link" data-toggle="modal" data-inline="true">LINK</a> <a href="#myHTML" role="button" class="btn btn-primary btn-html" data-toggle="modal" data-inline="true">HTML</a> <form method="POST" action="http://service.fabricatorz.com/html2pdf/" id="html2pdf-form-individual"><input type="hidden" name="title" value="Individual Contributor License Agreement 1.1" /><input type="hidden" class="htmlstore" id="htmlstore-individual" name="htmlstore" /><a role="button" class="btn btn-primary" id="html2pdf-individual" data-inline="true">PDF</a></form></td>
</tr> </tr>
<tr id="apply-entity"> <tr id="apply-entity">
<td>Entity Contributor License Agreement</td> <td>Entity Contributor License Agreement</td>
<td>Contributor Agreements 1.1</td> <td>Contributor Agreements 1.1</td>
<td><a href="#myHTML" role="button" class="btn btn-primary btn-html" data-toggle="modal" data-inline="true">HTML</a> <form method="POST" action="http://service.fabricatorz.com/html2pdf/" id="html2pdf-form-entity"><input type="hidden" name="title" value="Entity Contributor License Agreement 1.1" /><input type="hidden" class="htmlstore" id="htmlstore-entity" name="htmlstore" /><a role="button" class="btn btn-primary" id="html2pdf-entity" data-inline="true">PDF</a></form></td> <td><a href="#" role="button" class="btn btn-primary btn-html final-link" data-toggle="modal" data-inline="true">LINK</a> <a href="#myHTML" role="button" class="btn btn-primary btn-html" data-toggle="modal" data-inline="true">HTML</a> <form method="POST" action="http://service.fabricatorz.com/html2pdf/" id="html2pdf-form-entity"><input type="hidden" name="title" value="Entity Contributor License Agreement 1.1" /><input type="hidden" class="htmlstore" id="htmlstore-entity" name="htmlstore" /><a role="button" class="btn btn-primary" id="html2pdf-entity" data-inline="true">PDF</a></form></td>
</tr> </tr>
</table> </table>
...@@ -513,7 +513,7 @@ class="input-block-level" placeholder="If one or more of your preferred licenses ...@@ -513,7 +513,7 @@ class="input-block-level" placeholder="If one or more of your preferred licenses
<script src="//code.jquery.com/jquery-1.11.1.js"></script> <script src="//code.jquery.com/jquery-1.11.1.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script> <script src="bootstrap/js/bootstrap.min.js"></script>
<script src="js/showdown.js"></script> <script src="js/showdown.js"></script>
<script src="js/jquery.bootstrap.wizard.js"></script> <script src="js/twitter-bootstrap-wizard/jquery.bootstrap.wizard.js"></script>
<script src="js/prettify.js"></script> <script src="js/prettify.js"></script>
<script src="js/tooltip.js"></script> <script src="js/tooltip.js"></script>
<script src="js/chooser.js"></script> <script src="js/chooser.js"></script>
......
/** cla chooser main javascript by Fabricatorz **/ /** cla chooser main javascript by Fabricatorz **/
/**
* @TODO Need to make compact the config setting code and the review/apply
* because lots of duplicated code.
* @TODO the final configs are currently not set from user interface changes
* @TODO test the default configs, make sure set here in the code
* @TODO possibly reset some variable names if not consistent
* @TODO reduce some code complexity
*
* @TODO need to finish the query2form and query2email to interface changes
* @TODO replace the github and google options with this custom option
* @TODO make simple flatfile backed query2updatelist (list of updates
*/
var doDebug = true; var doDebug = false;
var debugNeedle = 1337;
var generalPageIndex = 0; var generalPageIndex = 0;
var isGeneralPageOk = false; var isGeneralPageOk = false;
...@@ -25,6 +39,53 @@ var mediaLicenses = ''; ...@@ -25,6 +39,53 @@ var mediaLicenses = '';
var naField = 'Not Applicable'; var naField = 'Not Applicable';
var emptyField = '____________________'; var emptyField = '____________________';
/** could even set defaults here
*
* Query String Possible Parameters:
*
* beneficiary-name=STRING
* project-name=STRING
* project-website=URL
* project-email=EMAIL
* contributor-process-url=URL
* project-jurisdiction=STRING
*
* contributor-option-entity=entity|individual
* agreement-exclusivity=exclusive|nonexclusive
* outbound-option=same|same-licenses|fsf|no-commitment
* outboundlist=Artistic-1.0,Apache-2.0,LIST
* outboundlist-custom=STRING
* medialist=None|GFDL-1.1|CC-BY-1.0,GFDL-1.3,LIST
* patent-option=Traditional|Patent-Pledge
*
* pos=general|copyright|patents|review|apply
*/
var configs = {
'beneficiary-name': '',
'project-name': '',
'project-website': '',
'project-email': '',
'contributor-process-url': '',
'project-jurisdiction': '',
'contributor-option-entity': '',
'agreement-exclusivity': '',
'outbound-option': '',
'outboundlist': '',
'outboundlist-custom': '',
'medialist': '',
'patent-option': '',
'post': ''
};
function printConfigs ()
{
// make query string url
$.each( configs, function(p,v){
console.log("configs(p,v): " + p + ": \t\t\t\t\t\t\t " + v);
});
}
// gives us $.QueryString["parameter-name"] function // gives us $.QueryString["parameter-name"] function
(function ($) { (function ($) {
$.QueryString = (function (a) { $.QueryString = (function (a) {
...@@ -43,76 +104,94 @@ var emptyField = '____________________'; ...@@ -43,76 +104,94 @@ var emptyField = '____________________';
* Cleanup of the query string data and setting it. * Cleanup of the query string data and setting it.
* @usage: http://cla.localhost/?beneficiary-name=Fabricatorz&project-name=Archive%20Software&project-website=http://archive.fabricatorz.com&project-email=jon@fabricatorz.com&contributor-process-url=http://archive.fabricatorz.com/signing&project-jurisdiction=United%20States,%20Hong%20Kong,%20and%20China%20Mainland * @usage: http://cla.localhost/?beneficiary-name=Fabricatorz&project-name=Archive%20Software&project-website=http://archive.fabricatorz.com&project-email=jon@fabricatorz.com&contributor-process-url=http://archive.fabricatorz.com/signing&project-jurisdiction=United%20States,%20Hong%20Kong,%20and%20China%20Mainland
* *
* contributor-option-entity=entity|individual
* agreement-exclusivity=exclusive|nonexclusive
* outbound-option=same|same-licenses|fsf|no-commitment
* outboundlist=Artistic-1.0,Apache-2.0
* outboundlist-custom=AnythingAtAll
* medialist=None|GFDL-1.1|CC-BY-1.0,GFDL-1.3
* patent-option=Traditional|Patent Pledge
*/ */
function setQueryStringData () function queryStringToConfigs ()
{
$.each( $.QueryString, function(p,v) {
configs[p] = v;
// console.log("configs[p]=v: " + configs[p] + ": " + p + ": " + v);
});
}
/**
* @todo can combine this with review code and save code, but will need
* to abstract the following more thanlikely into functions.
* Then, that will allow creating a querystring easier
*/
function updateConfigs ()
{ {
/* general */ /* general */
if ( $.QueryString["contributor-option-entity"] == 'individual' ) if ( configs["contributor-option-entity"] == 'individual' )
{
$("#contributor-option-individual").prop('checked', true ); $("#contributor-option-individual").prop('checked', true );
else } else {
$("#contributor-option-entity").prop('checked', true ); $("#contributor-option-entity").prop('checked', true );
}
console.log("contributor-option-entity: " + if ( doDebug)
$.QueryString["contributor-option-entity"]); console.log("contributor-option-entity: " +
configs["contributor-option-entity"]);
console.log("#contributor-option-entity: " + if ( doDebug)
$('#contributor-option-entity').val() ); console.log("#contributor-option-entity: " +
$('#contributor-option-entity').val() );
if ( $.QueryString["beneficiary-name"] ) if ( configs["beneficiary-name"] )
$('#beneficiary-name').val( $.QueryString["beneficiary-name"] ); $('#beneficiary-name').val( configs["beneficiary-name"] );
console.log("beneficiary-name: " + $.QueryString["beneficiary-name"]); if ( doDebug)
console.log("beneficiary-name: " + configs["beneficiary-name"]);
if ( $.QueryString["project-name"] ) if ( configs["project-name"] )
$('#project-name').val( $.QueryString["project-name"] ); $('#project-name').val( configs["project-name"] );
console.log("project-name: " + $.QueryString["project-name"]); if ( doDebug)
console.log("project-name: " + configs["project-name"]);
if ( $.QueryString["project-website"] ) if ( configs["project-website"] )
$('#project-website').val( $.QueryString["project-website"] ); $('#project-website').val( configs["project-website"] );
console.log("project-website: " + $.QueryString["project-website"]); if ( doDebug)
console.log("project-website: " + configs["project-website"]);
if ( $.QueryString["project-email"] ) if ( configs["project-email"] )
$('#project-email').val( $.QueryString["project-email"] ); $('#project-email').val( configs["project-email"] );
console.log("project-email: " + $.QueryString["project-email"]); if ( doDebug)
console.log("project-email: " + configs["project-email"]);
if ( $.QueryString["contributor-process-url"] ) if ( configs["contributor-process-url"] )
$('#contributor-process-url').val( $('#contributor-process-url').val(
$.QueryString["contributor-process-url"] ); configs["contributor-process-url"] );
console.log("contributor-process-url: " + if ( doDebug)
$.QueryString["contributor-process-url"]); console.log("contributor-process-url: " +
configs["contributor-process-url"]);
if ( $.QueryString["project-jurisdiction"] ) if ( configs["project-jurisdiction"] )
$('#project-jurisdiction').val( $.QueryString["project-jurisdiction"] ); $('#project-jurisdiction').val( configs["project-jurisdiction"] );
console.log("project-jurisdiction: " + if ( doDebug)
$.QueryString["project-jurisdiction"]); console.log("project-jurisdiction: " +
configs["project-jurisdiction"]);
/* copyright */ /* copyright */
if ( $.QueryString["agreement-exclusivity"] == 'exclusive' ) if ( configs["agreement-exclusivity"] == 'exclusive' )
$("#agreement-exclusivity").val( 'exclusive' ); $("#agreement-exclusivity").val( 'exclusive' );
else else
$("#agreement-exclusivity").val( 'nonexclusive' ); $("#agreement-exclusivity").val( 'nonexclusive' );
console.log("agreement-exclusivity: " + if ( doDebug)
$.QueryString["agreement-exclusivity"]); console.log("agreement-exclusivity: " +
configs["agreement-exclusivity"]);
if ( $.QueryString["outbound-option"] == 'same' ) if ( configs["outbound-option"] == 'same' )
$("#contributor-option-individual").prop('checked', true ); $("#contributor-option-individual").prop('checked', true );
// hide by default // hide by default
$("#outboundlist").hide(); $("#outboundlist").hide();
$("#outboundlist-custom").hide(); $("#outboundlist-custom").hide();
switch ( $.QueryString["outbound-option"] ) { switch ( configs["outbound-option"] ) {
case 'same-licenses': case 'same-licenses':
$("#outbound-option-same-licenses").prop('checked', true ); $("#outbound-option-same-licenses").prop('checked', true );
$("#outbound-option-same-licenses" ).change(); $("#outbound-option-same-licenses" ).change();
...@@ -140,51 +219,64 @@ function setQueryStringData () ...@@ -140,51 +219,64 @@ function setQueryStringData ()
// @todo delete later if no need // @todo delete later if no need
// setOutboundOptionSame(); // setOutboundOptionSame();
} }
console.log("outbound-option: " + $.QueryString["outbound-option"]);
if ( doDebug)
console.log("outbound-option: " + configs["outbound-option"]);
if ( $.QueryString["outboundlist"] ) if ( configs["outboundlist"] )
{ {
$.each($.QueryString["outboundlist"].split(","), function(i,e){ $.each( configs["outboundlist"].split(","), function(i,e) {
$("#outboundlist option[value='" + e + "']").prop("selected", true); $("#outboundlist option[value='" + e + "']").prop("selected", true);
}); });
} }
console.log("outboundlist: " + if ( doDebug)
$.QueryString["outboundlist"]); console.log("outboundlist: " +
configs["outboundlist"]);
if ( $.QueryString["outboundlist-custom"] ) if ( configs["outboundlist-custom"] )
$("#outboundlist-custom" ).val( $.QueryString["outboundlist-custom"] ); $("#outboundlist-custom" ).val( configs["outboundlist-custom"] );
console.log("outboundlist-custom: " + if ( doDebug)
$.QueryString["outboundlist-custom"]); console.log("outboundlist-custom: " +
configs["outboundlist-custom"]);
$("#medialist option[value='None']").prop("selected", false); $("#medialist option[value='None']").prop("selected", false);
if ( $.QueryString["medialist"] ) if ( configs["medialist"] )
{ {
$.each($.QueryString["medialist"].split(","), function(i,e){ $.each( configs["medialist"].split(","), function(i,e){
$("#medialist option[value='" + e + "']").prop("selected", true); $("#medialist option[value='" + e + "']").prop("selected", true);
}); });
} }
console.log("medialist: " + $.QueryString["medialist"]); if ( doDebug)
console.log("medialist: " + configs["medialist"]);
/* patent page */ /* patent page */
if ( $.QueryString["patent-option"] == 'Traditional' ) if ( configs["patent-option"] == 'Traditional' )
$("#patent-type").val( 'Traditional' ); $("#patent-type").val( 'Traditional' );
else else
$("#patent-type").val( 'Patent Pledge' ); $("#patent-type").val( 'Patent-Pledge' );
console.log("patent-option: " + $.QueryString["patent-option"] ); if ( doDebug)
console.log("patent-option: " + configs["patent-option"] );
} printConfigs();
}
/**
* A better test now:
* http://cla.localhost/?beneficiary-name=Fabricatorz&project-name=Archive+Software&project-website=http%3A%2F%2Farchive.fabricatorz.com&project-email=jon%40fabricatorz.com&contributor-process-url=http%3A%2F%2Farchive.fabricatorz.com%2Fsigning&project-jurisdiction=United+States%2C+Hong+Kong%2C+and+China+Mainland.&contributor-option-entity=&agreement-exclusivity=&outbound-option=&outboundlist=&outboundlist-custom=&medialist=&patent-option=&post=
*/
function setFakeData () function setFakeData ()
{ {
$('#beneficiary-name').val('Fabricatorz'); configs['beneficiary-name'] = 'Fabricatorz';
$('#project-name').val('Archive Software'); configs['project-name'] = 'Archive Software';
$('#project-website').val('http://archive.fabricatorz.com'); configs['project-website'] = 'http://archive.fabricatorz.com';
$('#project-email').val('jon@fabricatorz.com'); configs['project-email'] = 'jon@fabricatorz.com';
$('#contributor-process-url').val('http://archive.fabricatorz.com/signing'); configs['contributor-process-url'] =
$('#project-jurisdiction').val('United States, Hong Kong, and China Mainland.'); 'http://archive.fabricatorz.com/signing';
configs['project-jurisdiction'] =
'United States, Hong Kong, and China Mainland.';
} }
function ucFirst(string) function ucFirst(string)
...@@ -385,6 +477,30 @@ function setOutboundOptionNoCommitment () ...@@ -385,6 +477,30 @@ function setOutboundOptionNoCommitment ()
} }
function updatePosition ()
{
switch ( $.QueryString["pos"] ) {
case 'general':
$('#rootwizard').bootstrapWizard('show','general');
break;
case 'copyright':
$('#rootwizard').bootstrapWizard('show',1);
break;
case 'patents':
$('#rootwizard').bootstrapWizard('show',2);
break;
case 'review':
$('#rootwizard').bootstrapWizard('show',3);
break;
case 'apply':
$('#rootwizard').bootstrapWizard('last');
break;
}
testAllPages();
if ( doDebug)
console.log("pos: " + $.QueryString["pos"] );
}
function testGeneralPage () function testGeneralPage ()
...@@ -455,7 +571,8 @@ function testCopyrightPage () ...@@ -455,7 +571,8 @@ function testCopyrightPage ()
// isCopyrightPageOk = false; // isCopyrightPageOk = false;
} else { } else {
outboundCopyrightLicenses = outboundChoices.join(", "); outboundCopyrightLicenses = outboundChoices.join(", ");
console.log("outboundCopyrightLicenses: " + if ( doDebug)
console.log("outboundCopyrightLicenses: " +
outboundCopyrightLicenses); outboundCopyrightLicenses);
// $('#outboundlist').removeClass("cla-alert"); // $('#outboundlist').removeClass("cla-alert");
...@@ -470,8 +587,9 @@ function testCopyrightPage () ...@@ -470,8 +587,9 @@ function testCopyrightPage ()
outboundCopyrightLicenses += outboundCopyrightLicenses +=
", " + $('#outboundlist-custom').val(); ", " + $('#outboundlist-custom').val();
} }
console.log("outboundCopyrightLicenses: " + if ( doDebug)
outboundCopyrightLicenses); console.log("outboundCopyrightLicenses: " +
outboundCopyrightLicenses);
} }
...@@ -482,7 +600,8 @@ function testCopyrightPage () ...@@ -482,7 +600,8 @@ function testCopyrightPage ()
} else { } else {
*/ */
mediaLicenses = mediaChoices.join(", "); mediaLicenses = mediaChoices.join(", ");
console.log("mediaLicenses: " + if ( doDebug)
console.log("mediaLicenses: " +
mediaLicenses); mediaLicenses);
// $('#medialist').removeClass("cla-alert"); // $('#medialist').removeClass("cla-alert");
...@@ -506,7 +625,8 @@ function testReviewPage () ...@@ -506,7 +625,8 @@ function testReviewPage ()
{ {
isReviewPageOk = true; isReviewPageOk = true;
console.log("At testReviewPage"); if ( doDebug)
console.log("At testReviewPage");
if ( $("#contributor-option-entity").prop("checked") ) if ( $("#contributor-option-entity").prop("checked") )
{ {
...@@ -707,32 +827,41 @@ function testReviewPage () ...@@ -707,32 +827,41 @@ function testReviewPage ()
function testApplyPage () function testApplyPage ()
{ {
console.log("at testApplyPage"); if ( doDebug)
console.log("at testApplyPage");
isApplyPageOk = true; isApplyPageOk = true;
/* NEED TO REVIEW AFTER DECISIONS */ /* NEED TO REVIEW AFTER DECISIONS */
if ( $("#contributor-option-entity").prop("checked") ) if ( $("#contributor-option-entity").prop("checked") )
{ {
$("#apply-individual").hide(); $("#apply-individual").hide();
$("#apply-entity").show(); $("#apply-entity").show();
} }
else else
{ {
$("#apply-individual").show(); $("#apply-individual").show();
$("#apply-entity").hide(); $("#apply-entity").hide();
} }
$("#embed-offscreen").html( $( "#review-text" ).html() );
$(".htmlstore").val( $( "#review-text-style" ).html() +
$( "#review-text" ).html() );
$("#embed-offscreen .nuke").remove();
/* console.log("EMBEDDING: " + $("#embed-offscreen").html() ); */ // creates the querystring to recreate current wizard state
finalQueryString = $.param(configs);
console.log("finalQueryString: " + finalQueryString);
// set final linkto be used in the interface
$(".final-link").attr("href", "?" + finalQueryString);
$("#embed-agreement").html( $("#embed-offscreen").html() );
return isApplyPageOk; $("#embed-offscreen").html( $( "#review-text" ).html() );
$(".htmlstore").val( $( "#review-text-style" ).html() +
$( "#review-text" ).html() );
$("#embed-offscreen .nuke").remove();
// if ( doDebug)
/* console.log("EMBEDDING: " + $("#embed-offscreen").html() ); */
$("#embed-agreement").html( $("#embed-offscreen").html() );
return isApplyPageOk;
} }
function testAllPages() function testAllPages()
...@@ -747,10 +876,11 @@ function testAllPages() ...@@ -747,10 +876,11 @@ function testAllPages()
$(document).ready(function() { $(document).ready(function() {
// if ( doDebug )
// setFakeData();
setQueryStringData(); queryStringToConfigs();
// if ( doDebug )
// setFakeData();
updateConfigs();
$("#patent-option-2-options").hide(); $("#patent-option-2-options").hide();
...@@ -836,7 +966,7 @@ $(document).ready(function() { ...@@ -836,7 +966,7 @@ $(document).ready(function() {
$( "#patent-type" ).change(function() { $( "#patent-type" ).change(function() {
if ( $( "#patent-type" ).val() == 'Patent Pledge' ) if ( $( "#patent-type" ).val() == 'Patent-Pledge' )
$("#patent-option-2-options").show(); $("#patent-option-2-options").show();
else