This repository was archived by the owner on Oct 24, 2022. It is now read-only.
forked from pwhitebe/Photon-Admin
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathPhotonAdmin.html
More file actions
307 lines (257 loc) · 14.9 KB
/
PhotonAdmin.html
File metadata and controls
307 lines (257 loc) · 14.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<!doctype html>
<html lang="en" xmlns="https://www.w3.org/1999/html">
<head>
<meta charset="utf-8">
<title>Photon Admin JSON Generator</title>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/>
<link href="css/jquery.tagit.css" rel="stylesheet" type="text/css">
<link href="css/tagit.ui-zendesk.css" rel="stylesheet" type="text/css">
<script type='text/javascript' src='JavaScriptSpellCheck/include.js' ></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>
<!-- The real deal -->
<script src="js/tag-it.js" type="text/javascript" charset="utf-8"></script>
<script>
$(function(){
var sampleTags = ['c++', 'java', 'php', 'coldfusion', 'javascript', 'asp', 'ruby','python', 'c', 'scala', 'groovy', 'haskell', 'perl', 'erlang', 'apl', 'cobol', 'go', 'lua'];
$('#ArticleKeywords').tagit({
availableTags: sampleTags
});
});
$(function() {
$( "#IssueDate" ).datepicker();
$( "#IssueDate" ).datepicker("option", "dateFormat", "yy-mm-dd");
});
$(document).ready(function(){
$("#serialize_button").hide();
$("#parseArticle").click(function(event){
event.preventDefault();
$('#ArticleKeywords').tagit('removeAll');
var article_url=$("#ArticleURL").val();
article_url = article_url.substring(0, article_url.indexOf('?'));
var originSource = $('input[name=whatOrigin]:checked').val()
if (article_url.length > 0){
var workaroundurl = 'https://whateverorigin.org/get?url=' + encodeURIComponent(article_url) + '&callback=?'
if (originSource == 'edemo')
{
workaroundurl = 'https://edemo.phiresearchlab.org/whatorigin/get?url=' + encodeURIComponent(article_url) + '&callback=?'
}
// console.log(article_url);
$.getJSON(workaroundurl,
function(data){
if(data.contents){
// pageContents = data.results[0];
pageContents = data.contents;
var htmlDoc = $.parseHTML(pageContents);
$html = $(htmlDoc);
$title = $html.filter("title");
//alert($title.text());
$("#IssueTitle").val($html.filter("title").text());
$("#IssueDate").val($html.filter("meta[name=\"Date\"]").attr("content"));
$("#IssueVolume").val($html.filter("meta[name=\"Volume\"]").attr("content"));
$("#IssueNumber").val($html.filter("meta[name=\"Issue\"]").attr("content"));
if($("#IssueVolume").val()== "")
{
//article in post 2016 format
var dateLine = $html.find(".dateline").text()
var dateTxt = dateLine.split('/')[1];
var articleDate = new Date(dateTxt);
var yyyy = articleDate.getFullYear().toString();
var mm = (articleDate.getMonth()+1).toString(); // getMonth() is zero-based
var dd = articleDate.getDate().toString();
var dateString = yyyy + '-' + (mm[1]?mm:"0"+mm[0]) + '-' + (dd[1]?dd:"0"+dd[0]); // padding
var init = dateLine.indexOf('(');
var fin = dateLine.indexOf(')');
$("#IssueVolume").val($html.filter("meta[name=\"citation_volume\"]").attr("content"));
$("#IssueDate").val(dateString);
$("#IssueNumber").val(dateLine.substr(init+1,fin-init-1));
}
var summaryText = $html.find(".module-typeC").html();
var summaryTextHTML = $.parseHTML(summaryText);
$summaryTextHTML = $(summaryTextHTML);
var firstSummary = $summaryTextHTML.find('p:eq(0)').text();
//console.log(firstSummary + ';;;' +summaryText);
$("#AlreadyKnownInfo").val($summaryTextHTML.find('p:eq(0)').text());
$("#AddedInfo").val($summaryTextHTML.find('p:eq(1)').text());
$("#Implications").val($summaryTextHTML.find('p:eq(2)').text());
if($("#AlreadyKnownInfo").val()== "What is already known about this topic?")
{
$("#AlreadyKnownInfo").val($summaryTextHTML.find('p:eq(1)').text());
$("#AddedInfo").val($summaryTextHTML.find('p:eq(3)').text());
$("#Implications").val($summaryTextHTML.find('p:eq(5)').text());
}
else if($("#AlreadyKnownInfo").val()== "")
{
$("#AlreadyKnownInfo").val($html.find(".Summary-Box-Text:eq(0)").text());
$("#AddedInfo").val($html.find(".Summary-Box-Text:eq(1)").text());
$("#Implications").val($html.find(".Summary-Box-Text:eq(2)").text());
if($("#AlreadyKnownInfo").val()== "")
{
$("#AlreadyKnownInfo").val($html.find(".fb-answer:eq(0)").text());
$("#AddedInfo").val($html.find(".fb-answer:eq(1)").text());
$("#Implications").val($html.find(".fb-answer:eq(2)").text());
if($("#AlreadyKnownInfo").val()== "")
{
$("#AlreadyKnownInfo").val("Summary not available.\nView Full Article for more information.");
$("#AddedInfo").val("Summary not available.\nView Full Article for more information.");
$("#Implications").val("Summary not available.\nView Full Article for more information.");
}
}
}
showButtonIfFilled();
$("#IssueTitle").val(($html.filter("meta[name=\"citation_title\"]").attr("content")).text());
} else {
var errormsg = "Error: could not load the page.";
//output to firebug's console
//use alert() for other browsers/setups
// console.log(errormsg);
alert(errormsg);
}
}
);
}
} );
function showButtonIfFilled()
{
if( $("#AlreadyKnownInfo").val().length >0 &&
$("#AddedInfo").val().length >0 &&
$("#Implications").val().length >0)
{
//alert("trying to show serialize button");
$("#serialize_button").show();
}
else
$("#serialize_button").hide();
}
$("#AlreadyKnownInfo").on('input',function(){
showButtonIfFilled();
});
$("#AddedInfo").on('input',function(){
showButtonIfFilled();
});
$("#Implications").on('input',function(){
showButtonIfFilled();
});
$("#clearArticle").click(function(event){
$("#ArticleURL").val("");
$('#ArticleKeywords').tagit('removeAll');
$("#IssueTitle").val("");
$("#IssueDate").val("");
$("#IssueVolume").val("");
$("#IssueNumber").val("");
$("#AlreadyKnownInfo").val("");
$("#AddedInfo").val("");
$("#Implications").val("");
} );
function dequote (quotable)
{
return quotable.replace(/[\u201C\u201D]/g, "\"").replace(/[\u2018\u2019]/g, "'");
}
$("#serializeButton").click(function(){
//var JSONArticle = "poo";
var issueNumber = $("#IssueNumber").val();
var issue = $("#IssueDate").val() + " / Vol. " + $("#IssueVolume").val()
+ " / No. "+ issueNumber;
if (issueNumber == null || issueNumber == "" )
{
alert("There is no issue number. Please provide one even if this is an Early Release.");
}
var tagstring = $("#ArticleKeywords").val();
var tagarray = [];
if (tagstring.length >0)
{
tagarray = tagstring.split(",");
var tagbuilder = [];
var counter = 0;
while (counter < tagarray.length)
{
var capTagString = tagarray[counter].toString().substring(0,1).toUpperCase() + tagarray[counter].toString().substring(1);
var tag = {"tag":capTagString};
tagbuilder[counter] = tag;
counter++;
}
}
var tags = JSON.stringify(tagbuilder);
//var title = dequote($("#IssueTitle").val());
//var strTitle = title.replace(/"/g, "\\\"");
var JSONArticle = {
"issue-date":$("#IssueDate").val(),
"issue-vol":$("#IssueVolume").val(),
"issue-no":$("#IssueNumber").val(),
"title":dequote($("#IssueTitle").val()),
"already_known":dequote($("#AlreadyKnownInfo").val()),
"added_by_report":dequote($("#AddedInfo").val()),
"implications":dequote($("#Implications").val()),
"tags":tagbuilder,
"url":$("#ArticleURL").val(),
"content-ver":"1",
"schema-ver":"1",
"command":"add",};
//var JSONArticle = {"issue":issue,
// "articles":[article],
// "ver":1};
$("#JSONBlurb").val(JSON.stringify(JSONArticle));
$("#JSONBlurb").select();
$("#serialize_message").show();
// };
});
$("#enableArticleEdit").click(function(){
//var JSONArticle = "poo";
$("#IssueDate").attr('contenteditable','true');
$("#IssueVolume").attr('contenteditable','true');
$("#IssueNumber").attr('contenteditable','true');
$("#IssueTitle").attr('contenteditable','true');
$("#AlreadyKnownInfo").attr('contenteditable','true');
$("#AddedInfo").attr('contenteditable','true');
$("#Implications").attr('contenteditable','true');
});
});
</script>
</head>
<body>
<div id="branding"><div class="header_image"><img src="images/branding.png" alt="MMWR Express Editor" title="MMWR Express Editor" border="0" /></div> </div>
<div id="header"><div class="page_title">Photon Admin JSON Generator</div>
</div>
<div id="white_div"></div>
<div id="header_gradient"></div>
<div id="white_div"></div>
<br>
<form action="">
<p><label for="ArticleURL" class="top_fields">Article URL:</label> <input type="text" name="ArticleURL" id="ArticleURL" size="60"/>
</p>
<center><button type="button" id="parseArticle">Auto Fetch Article</button>
<button type="button" id="clearArticle">Clear Article</button>
<button type="button" id="enableArticleEdit">Edit Article Fields</button></center></p>
<p><label for="IssueDate" class="top_fields">Issue Date:</label> <input type="text" name="FirstName" value="" id="IssueDate" size="12" contenteditable="false"/></p>
<p><label for="IssueVolume" class="top_fields">Volume Number:</label> <input type="text" name="LastName" value="" id="IssueVolume" size="12" contenteditable="false"/></p>
<p><label for="IssueNumber" class="top_fields">Issue Number:</label> <input type="text" name="IssueNumber" value="" id="IssueNumber" size="12" contenteditable="false"/></p>
<p><label for="IssueTitle" class="top_fields">Article Title:</label> <textarea type="text" name="ArticleTitle" id="IssueTitle" rows="2" cols="70" contenteditable="false"></textarea></p>
<div>
<p><label for="ArticleKeywords" class="top_fields">Article Subjects:</label>
<input type="text" name="ArticleKeywords" id="ArticleKeywords" size="40" spellcheck="true" />
<div class="instructions">Type a keyword, then hit Enter. Surround "multi-word keywords" with quotation marks.</div>
<!-- <button name="AddKeyword" id="btnFoo">Add</button>-->
</div>
<div id="bluebox">
<div class="bluebox_topics_header">Blue Box Topics</div>
<p><div class="label_above">
<label for "AlreadyKnownInfo" class="bluebox_topics"><img src="images/blue_bubble.png" style="padding-right:.4em;" alt="What is already known on this topic?" title="What is already known on this topic?" />What is <strong>already known</strong> on this topic?</label><br/> <textarea type="text" id="AlreadyKnownInfo" rows="4" cols="70" contenteditable="false"></textarea></div></p>
<p><div class="label_above"><label for "AddedInfo" class="bluebox_topics"><img src="images/orange_bubble.png" style="padding-right:.4em;" alt="What is added by this report?" title="What is added by this report?" />What is <strong>added</strong> by this report?</label><br/> <textarea type="text" id="AddedInfo" rows="4" cols="70" contenteditable="false"></textarea></div></p>
<p><div class="label_above"><label for "Implications" class="bluebox_topics"><img src="images/green_bubble.png" style="padding-right:.4em;" alt="What are the implications for public health practice?" title="What are the implications for public health practice?"/>What are the <strong>implications for public health practice</strong>?</label><br/> <textarea type="text"
id="Implications" rows="4" cols="70" contenteditable="false"></textarea></div></p>
</div>
</form>
<div id="serialize_button">
<button id="serializeButton" onclick="$Spelling.SpellCheckInWindow('ArticleKeywords')">Serialize Form Values</button></div>
<div style="clear:both;"></div>
<p><div class="json"><label for "JSONBlurb" class="top_fields">JSON Blurb:</label> <textarea type="text" name="JSONBlurb" id="JSONBlurb" rows="7" cols="73" spellcheck="true"></textarea> </div><br/>
<div class="serialize_message" id="serialize_message">Please copy (Control+C) and paste the JSON Blob into the <a href="http://toolsadmin.cdc.gov/medialibraryadmin/Feeds/Feeds.htm?view=detail&id=342419">CDC Content Syndication Service Admin Site</a>.</div>
<!-- <button name="AddKeyword" id="btnFoo">Add</button>-->
</div></p></div>
<!--<div id="subscription"><a href="https://toolsadmin.cdc.gov">CDC Subscription Service</a></div>-->
<div style="clear:both;"></div>
<br/>
<br><br>Article Parser: <input type="radio" name="whatOrigin" value="edemo" checked/>EDemo. <input type="radio" name="whatOrigin" value="whatorigin" />Whatever Origin.
</body>
</html>