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

New Name, new icons #1

Open
wants to merge 6 commits 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
Binary file modified icons/icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/icon16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/icon19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/icon256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "NominationTool",
"version": "0.0.2",
"name": "DataRefugeNominationTool",
"version": "0.0.1",
"manifest_version": 2,
"description": "Nomination Tool for End of Term Presidential Webcrawl",
"description": "Nomination Tool for Data Refuge Philly EOT Webcrawl Event",
"homepage_url": "http://digital2.library.unt.edu/nomination/eth2016/about/",
"icons": {
"16": "icons/icon16.png",
Expand Down
48 changes: 40 additions & 8 deletions popup.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<!doctype html>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style type="text/css">
#nominationTool { width: 300px; padding: 5px;}
#nominationTool { width: 350px; padding: 5px;}
#success { color: green; }
#error { color: red; }
div.quick-col {max-width: 48%; padding-right:2%; float:left;}
div.clear{clear:both;}
.form-group {margin-bottom: 10px;}
.agency-code input, #subprimerID { width: 70px; display: inline-block; }
html, body {min-height: 600px;}
</style>
<div id="nominationTool">
<div class="row">
Expand All @@ -23,8 +28,6 @@
</label>
<input required type="text" class="form-control" id="url" name="url"/>
</div>


<!-- Agency -->
<div class="form-group">
<select class="form-control" id="agency" name="agency" required>
Expand Down Expand Up @@ -323,7 +326,8 @@
<option value="Multi-Family Housing Office">Multi-Family Housing Office</option>
<option value="Music Division">Music Division</option>
<option value="National Advisory Council on Indian Education">National Advisory Council on Indian Education</option>
<option value="National Aeronautics and Space Administration">National Aeronautics and Space Administration</option>
<option value="National Aeronautics and Space Administration: Science Mission Directorate">National Aeronautics and Space Administration: Science Mission Directorate</option>
<option value="National Aeronautics and Space Administration: Sciences and Exploration Directorate">National Aeronautics and Space Administration: Sciences and Exploration Directorate</option>
<option value="National Agricultural Library">National Agricultural Library</option>
<option value="National Agricultural Statistics Service">National Agricultural Statistics Service</option>
<option value="National Air and Space Museum">National Air and Space Museum</option>
Expand Down Expand Up @@ -581,11 +585,39 @@
</div>
<!-- Event Name -->
<div class="form-group">
<label for="eventName">
Event Name
</label>
<input required type="text" class="form-control" id="eventName" name="eventName"/>
<label for="eventName">
Event Name
</label>
<input required type="text" class="form-control" id="eventName" name="eventName"/>
</div>
<!-- Agency Office Code -->
<div class="form-group agency-code">
<label for="agency-code">
Agency Office Code
</label>
<br>
<input required type="number" min="0" max="99" class="form-control" id="agencyID" name="agencyID"/>
<input required type="number" min="0" max="99" class="form-control" id="subAgencyID" name="subAgencyID"/>
<input required type="number" min="0" max="99" class="form-control" id="organizationID" name="organizationID"/>
<input required type="number" min="0" max="99" class="form-control" id="suborgID" name="suborgID"/>
</div>
<!-- Sub-Primer Num -->
<!-- NOTE: This is the only field that is NOT required to submit the form. -->
<div class="quick-col form-group">
<label for="subprimerID">
Sub-Primer Num
</label>
<br>
<input type="number" class="form-control" id="subprimerID" name="subprimerID"/>
</div>
<div class="quick-col form-group">
<label for="crawlableID">
Uncrawlable data?
</label>
<br>
<input type="checkbox" class="form-control" id="crawlableID" name="crawlableID" value="Non-crawlable"/>
</div>
<div class="clear"></div>
<h3 id="success"></h3>
<h3 id="error"></h3>
<button type="submit" id="save" class="btn btn-default" value="Save Bookmark">
Expand Down
78 changes: 70 additions & 8 deletions popup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
// This callback function is called when the content script has been
// injected and returned its results
/* List of Agency Office Codes and their corresponding Department names
*/
window.AGENCY_IDS = {
"1": "Environmental Protection Agency",
"2": "Energy Department",
"3": "National Oceanic and Atmospheric Administration",
"4": "Occupational Safety and Health Administration",
"5": "National Aeronautics and Space Administration: Science Mission Directorate",
"6": "National Aeronautics and Space Administration: Sciences and Exploration Directorate",
"7": "Agriculture Department",
"8": "Interior Department"
};

function onPageDetailsReceived( pageDetails ) {
pageTitle = document.getElementById( 'title' ).value = pageDetails.title;
Expand All @@ -17,8 +27,15 @@ function nominationTool( e ) {
var EVENTNAME_FIELD = '&entry.1800984457=';
var URL_FIELD = '&entry.242612017=';
var TITLE_FIELD = '&entry.1562922032=';

var NOTIFICATION_TOOL_URL = 'http://digital2.library.unt.edu/nomination/eth2016/url/';
var AGENCY_FIELD = '&entry.2097502371=';
var AGENCY_FIELD = '&entry.1285343614=';
var AGENCY_ID = '&entry.536064408=';
var SUBAGENCY_ID = '&entry.1706245913=';
var ORGANIZATION_ID = '&entry.1076101938=';
var SUBORG_ID = '&entry.1768657731=';
var SUBPRIMER_ID = '&entry.615621344=';
var CRAWLABLE_ID = "&entry.2059306163=";

var title = $( '#title' ).val();
var name = $( '#name' ).val();
Expand All @@ -28,7 +45,13 @@ function nominationTool( e ) {
var eventName = $( '#eventName' ).val();
var currentURL = $( '#url' ).val();
var agency = $( '#agency option:selected' ).text();

var agencyID = $( '#agencyID' ).val();
var subAgencyID = $( '#subAgencyID' ).val();
var organizationID = $( '#organizationID' ).val();
var suborgID = $( '#suborgID' ).val();
var subprimerID = $( '#subprimerID' ).val();
var crawlableID = $( '#crawlableID').val();

if ( localStorage.name !== name ) {
localStorage.name = name;
}
Expand All @@ -41,15 +64,30 @@ function nominationTool( e ) {
if ( localStorage.agency !== agency ) {
localStorage.agency = agency;
}

if ( localStorage.agencyID !== agencyID ) {
localStorage.agencyID = agencyID;
}
if ( localStorage.subAgencyID !== subAgencyID ) {
localStorage.subAgencyID = subAgencyID;
}
if ( localStorage.organizationID !== organizationID ) {
localStorage.organizationID = organizationID;
}
if ( localStorage.suborgID !== suborgID ) {
localStorage.suborgID = suborgID;
}


// Do GET call to post to Google Form and open new tab
$.get( {
url: GOOGLE_FORMS_URL + NAME_FIELD + localStorage.name + EMAIL_FIELD + localStorage.email + TITLE_FIELD + title + EVENTNAME_FIELD + localStorage.eventName + URL_FIELD + currentURL + AGENCY_FIELD + agency + '&submit=Submit',
url: GOOGLE_FORMS_URL + NAME_FIELD + localStorage.name + EMAIL_FIELD + localStorage.email + TITLE_FIELD + title + EVENTNAME_FIELD +
localStorage.eventName + URL_FIELD + currentURL + AGENCY_FIELD + agency + AGENCY_ID + agencyID + SUBAGENCY_ID + subAgencyID + ORGANIZATION_ID + organizationID + SUBORG_ID + suborgID + SUBPRIMER_ID + subprimerID + '&submit=Submit',
success: function( res ) {
$( '#success' ).html( "Success!" );
setTimeout( function() {
window.location.reload();
}, 1000 )
}, 1000 );
// uncomment this line to also add the URL through the official notificaiton tool.
// window.open(NOTIFICATION_TOOL_URL + currentURL);
},
Expand All @@ -59,9 +97,10 @@ function nominationTool( e ) {
} );
}

// When the popup HTML has loaded
/* When the popup loads: Autopopulate the name, event name and email if it has been submitted before,
* i.e. if localStorage has these fields already saved.
*/
window.addEventListener( 'load', function( evt ) {
// if localStorage.name, localStorage.eventname or localStorage.email exist, autopopulate the form and autofocus
if ( localStorage.name && localStorage.name !== "null" ) {
$( '#name' ).val( localStorage.name );
}
Expand All @@ -75,6 +114,29 @@ window.addEventListener( 'load', function( evt ) {
$( '#agency' ).val( localStorage.agency );
}

if ( localStorage.agencyID && localStorage.agencyID !== "null" ) {
$( '#agencyID' ).val( localStorage.agencyID );
}
if ( localStorage.subAgencyID && localStorage.subAgencyID !== "null" ) {
$( '#subAgencyID' ).val( localStorage.subAgencyID );
}
if ( localStorage.organizationID && localStorage.organizationID !== "null" ) {
$( '#organizationID' ).val( localStorage.organizationID );
}
if ( localStorage.suborgID && localStorage.suborgID !== "null" ) {
$( '#suborgID' ).val( localStorage.suborgID );
}

/* Disable the Department/Agency dropdown bar once the agency code has been entered.
* Changing the code will re-enter the correct department/agency name.
*/
$( '#agencyID' ).change( function( event ) {
var enteredCode = $( event.currentTarget ).val();
var agencyName = window.AGENCY_IDS[ enteredCode ];
$( "#agency" ).val( agencyName );
$( "#agency" ).attr( 'disabled', 'disabled' );
} );

// Cache a reference to the status display SPAN
statusDisplay = document.getElementById( 'status-display' );
// Handle the bookmark form submit event with our nominationTool function
Expand Down