-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathjson.html
297 lines (275 loc) · 12.2 KB
/
json.html
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
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<style>
body, #form-preview {
background: url(http://calvein.github.io/humble-games/images/bg.png);
color: rgba(255, 255, 255, .8);
text-shadow: 0 2px 4px hsla(0, 0%, 0%, 0.4);
padding: 20px;
}
h1, h2, h3, h4 {
text-align: center;
//line-height:.2em;
margin-bottom:0;
}
h5, h2, h3, h4 {
text-align: center;
margin-top:0;
}
a {
color: #658B1C;
}
#form label, #form .label {
display: block;
font-weight: bold;
margin-bottom: 4px;
}
#form .label {
display: inline;
font-weight: normal;
}
#form .required {
font-weight: bold;
font-size: 11px;
}
#form input[type="text"], #form textarea, #form select {
background: #ffffff;
margin: 5px 0;
padding: 6px 8px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
border: 1px solid #d3d3d3;
width: 400px;
-webkit-box-shadow: 1px 1px 0px #ffffff;
-moz-box-shadow: 1px 1px 0px #ffffff;
box-shadow: 1px 1px 0px #ffffff;
}
#form div {
margin-bottom: 20px;
}
#form select {
width: 318px;
}
#form textarea {
font-family: Tahoma;
font-size: 12px;
height: 140px;
}
#form .likert-question {
font-style: italic;
margin-right: 10px;
}
#form .likert-answer {
text-align: center;
}
#form .likert-option {
font-weight: bold;
text-align: center;
margin: 0 15px;
}
pre {
background: rgb(72, 72, 72);
background: rgba(255, 255, 255, .1);
margin: 10px;
padding: 10px;
overflow: auto;
}
</style>
<script>
function generate() {
var name = document.getElementById("gamename").value;
var url = document.getElementById("urlfrag").value;
var price = document.getElementById("price").value;
var description = document.getElementById("description").value;
var developer = document.getElementById("developer").value;
var android = document.getElementById("android").checked;
var linux = document.getElementById("linux").checked;
var windows = document.getElementById("windows").checked;
var mac = document.getElementById("mac").checked;
var audio = document.getElementById("soundtrack").checked;
var steam = document.getElementById("steam").checked;
var desura = document.getElementById("desura").checked;
var GOG = document.getElementById("gog").checked;
var drmfree = document.getElementById("drm-free").checked;
var extras = document.getElementById("extras").checked;
var notes = document.getElementById("notes").value;
var review = document.getElementById("review").value;
var steamurl = document.getElementById("steamurl").value;
var desuraurl = document.getElementById("desuraurl").value;
var devurl = document.getElementById("devurl").value;
var myJSON = generatejson(devurl,extras,review,steamurl,desuraurl,name,url,price,description,developer,android,linux,windows,mac,audio,steam,desura,GOG,drmfree,notes);
var myWiki = generatewiki(name,url,price,description,developer,android,linux,windows,mac,audio,steam,desura,GOG,drmfree,notes);
document.getElementById('json').textContent=JSON.stringify(myJSON,null,4) + ",";
document.getElementById('wiki').innerText=myWiki;
return false;
}
function generatewiki(name,url,price,description,developer,android,linux,windows,mac,audio,steam,desura,GOG,drmfree,notes) {
var wikiformatting="|-\n|[["+name+"]]\n|[http://www.humblebundle.com/store/"+url+" 1]\n|$"+price;
wikiformatting += (linux ? "{{OS|Linux}}" : "") + (windows ? "{{OS|Windows}}" : "") + (mac ? "{{OS|Mac}}" : "") + (android ? "{{OS|Android}}" : "");
wikiformatting += "\n|\n|"
wikiformatting += (steam ? "{{ID|Steam}}" : "") + (desura ? "{{ID|Desura}}" : "") + (GOG ? "{{ID|GOG}}" : "");
wikiformatting += "\n|";
wikiformatting += (audio ? "Can come with a soundtrack. " + notes : notes);
return wikiformatting;
}
function generatejson(devurl,extras,review,steamurl,desuraurl,name,url,price,description,developer,android,linux,windows,mac,audio,steam,desura,GOG,drmfree,notes) {
// make an empty object
var myGame = {};
myGame['name']=jescape(name);
myGame['url']=jescape(url);
myGame['price']=jescape(price);
myGame['description']=jescape(description);
myGame['developer']=jescape(developer);
var myPlatform = {}
myPlatform['android']=android;
myPlatform['linux']=linux;
myPlatform['windows']=windows;
myPlatform['mac']=mac;
myPlatform['audio']=audio;
var myDRM = {};
myDRM["steam"]=steam;
myDRM["desura"]=desura;
myDRM["gog"]=GOG;
myDRM["drm-free"]=drmfree;
var myURLs = {};
myURLs["review"]=review;
myURLs["steam"]=steamurl;
myURLs["desura"]=desuraurl;
myURLs["developer"]=devurl;
myGame.platform = myPlatform;
myGame.drm = myDRM;
myGame.URL = myURLs;
myGame["notes"]=jescape(notes);
myGame["extras"]=extras;
return myGame;
}
function jescape(unescapedstring) {
var escapedstring = unescapedstring.replace(/\\n/g, "\\n").replace(/\\'/g, "\\'").replace(/\\"/g, "\\\"").replace(/\\&/g, "\\&").replace(/\\r/g, "\\r").replace(/\\t/g, "\\t").replace(/\\b/g, "\\b").replace(/\\f/g, "\\f");
return escapedstring;
}
function selectText(containerid) {
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(containerid));
range.select();
} else if (window.getSelection) {
var range = document.createRange();
range.selectNodeContents(document.getElementById(containerid));
window.getSelection().addRange(range);
}
}
</script>
</head>
<body>
<div style="margin:auto"><div style="width:400px;margin:auto;"><div>
<h1>Generate JSON</h1>
<h5>(and WikiCode)</h5>
<form method="post" action="process.php" id="form">
<div>
<label data-key="gamename">Game Name <span class="required">*</span></label>
<input id="gamename" type="text" name="gamename" required="required" onkeyup="generate();" placeholder="A.N.N.E" />
</div>
<div>
<label data-key="urlfrag">URL Fragment <span class="required">*</span></label>
<input id="urlfrag" type="text" name="urlfrag" required="required" onkeyup="generate();" placeholder="anne?preview=lmX7v6blw6VX" />
</div>
<div>
<label data-key="price">Price <span class="required">*</span></label>
<input id="price" type="text" name="price" required="required" onkeyup="generate();" placeholder="10"/>
</div>
<div>
<label data-key="description">Description <span class="required">*</span></label>
<input id="description" type="text" name="description" required="required" onkeyup="generate();" placeholder="Pre-order A.N.N.E. now, cross platform and DRM-free! Explore a vast Metroidvania open world and retrieve pieces of your girlfriend to put her back together." />
</div>
<div>
<label data-key="developer">Developer <span class="required">*</span></label>
<input id="developer" type="text" name="developer" required="required" onkeyup="generate();" placeholder="Gamesbryo" />
</div>
<div><h2>URLs</h2><h3>Useful for table view. Optional.</h3><h5>The samples do not match the game above.</h5></div>
<div>
<label data-key="devurl">Developer URL</label>
<input id="devurl" type="text" name="devurl" onkeyup="generate();" placeholder="http://www.gamesbymo.com" />
</div>
<div>
<label data-key="review">Review URL</label>
<input id="review" type="text" name="review" onkeyup="generate();" placeholder="http://www.doublejump.co/a-n-n-e-a-beautiful-side-scrolling-shootermetroidvania-hybrid-is-now-on-kickstarter/" />
</div>
<div>
<label data-key="steamurl">Steam URL</label>
<input id="steamurl" type="text" name="steamid" onkeyup="generate();" placeholder="http://store.steampowered.com/app/70500/" />
</div>
<div>
<label data-key="desuraurl">Desura URL</label>
<input id="desuraurl" type="text" name="desura" onkeyup="generate();" placeholder="http://www.desura.com/games/running-with-rifles" />
</div>
<div><h2>Platforms, DRM, and Extras</h2></div>
<div style="float:right;width:50%;>
<label data-key="drm">DRM/Distributor</label><br>
<input id="steam" name="drm[]" value="steam" type="checkbox" onclick="generate();" /> <span class="label">Steam</span><br/>
<input id="desura" name="drm[]" value="desura" type="checkbox" onclick="generate();" /> <span class="label">Desura</span><br/>
<input id="gog" name="drm[]" value="gog" type="checkbox" onclick="generate();" /> <span class="label">GOG</span><br/>
<input id="drm-free" name="drm[]" value="drm-free" type="checkbox" onclick="generate();" /> <span class="label">DRM Free</span><br/>
</div>
<div style="width: 50%;>
<label data-key="platforms">Platforms</label><br>
<input id="android" name="platforms[]" value="android" type="checkbox" onclick="generate();" /> <span class="label">Android</span><br/>
<input id="linux" name="platforms[]" value="linux" type="checkbox" onclick="generate();" /> <span class="label">Linux</span><br/>
<input id="windows" name="platforms[]" value="windows" type="checkbox" onclick="generate();" /> <span class="label">Windows</span><br/>
<input id="mac" name="platforms[]" value="mac" type="checkbox" onclick="generate();" /> <span class="label">Mac</span><br/>
</div>
<div style="float:right;width:50%;">
<input id="extras" name="extras[]" value="extras" type="checkbox" onclick="generate();" /> <span class="label">Other Extras</span><br/>
</div>
<div style="width: 50%;">
<input id="soundtrack" name="soundtrack[]" value="soundtrack" type="checkbox" onclick="generate();" /> <span class="label">Soundtrack</span><br/>
</div>
<div>
<label data-key="developer">Notes <span class="required"></span></label>
<textarea id="notes" type="text" name="notes" onkeyup="generate();" placeholder="here, tell us about any other forms of DRM or distributors available, the publisher's website, the game release date, etc. Also tell us if the game is a preorder. A couple linebreaks are ok for Calvein's, but not for PCGamingWiki. Keep this short."></textarea>
</div>
<h1>Results</h1>
<div>JSON for the <a href="http://calvein.github.com/humble-games">list</a><br><pre id="json" onclick="selectText('json');">
{
"name": "A.N.N.E.",
"url": "anne?preview=lmX7v6blw6VX",
"price": "10",
"description": "Pre-order A.N.N.E. now, cross platform and DRM-free! Explore a vast Metroidvania open world and retrieve pieces of your girlfriend to put her back together.",
"developer": "Gamesbymo",
"platform": {
"android": false,
"linux": false,
"windows": false,
"mac": false,
"audio": false
},
"drm": {
"steam": false,
"desura": "http://www.desura.com/games/anne",
"gog": false,
"drm-free": false
},
"url": {
"review": "http://www.doublejump.co/a-n-n-e-a-beautiful-side-scrolling-shootermetroidvania-hybrid-is-now-on-kickstarter/",
"steam": "http://store.steampowered.com/app/70500/",
"desura": "http://www.desura.com/games/anne",
"developer": "http://www.gamesbymo.com"
},
"notes": "",
"extras": false
},
</pre>Double check to make sure the formatting here matches the formatting <a href="https://github.com/Calvein/humble-games">here</a> and <a href="https://github.com/Calvein/humble-games/edit/gh-pages/games.js">edit</a> <a href="https://github.com/Calvein/humble-games/blob/gh-pages/games.js">games.js</a>.</div>
<a id="displaywiki" onclick="document.getElementById('wikicode').style.display='block';document.getElementById('displaywiki').style.display='none';">Display Wikicode</a>
<div id="wikicode" style="display:none">Wikicode for <a href="http://pcgamingwiki.com/wiki/Humble_Store">PCGamingWiki</a><br><pre id="wiki" onclick="selectText('wiki');"></pre>PCGamingWiki uses <i>one</i> entry for all versions of a game, so you'll need to fix the title, links, and prices here. Once you've done that, <a href="http://pcgamingwiki.com/index.php?title=Humble_Store&action=edit">insert</a> the row into PCGamingWiki's <a href="http://pcgamingwiki.com/wiki/Humble_Store">table</a> source.</div>
</div>
</form>
</div></div></div>
<script>
var _gaq=[['_setAccount','UA-37825336-1'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
</body>
</html>