-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax_magic.js
787 lines (598 loc) · 20.3 KB
/
ajax_magic.js
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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
// this variable holds the latest hash (page view). it is set to init (a dummy value) so that we can enter the site via a predefined hash, for example by navigating directly to #cart or #restorecart:uidlist
var recentHash = "init";
// index.php's onload function
function page_load()
{
// function to check the page hash to see if anything has changed and update appropriately
// this is delicate machinery. don't emerick it up!
var check_hash = function ()
{
var hash = document.location.hash.substr(1);
//hasharray = hash.split(":");
//operator = hasharray[0];
//hasharray.splice(0,1); // remove the first element of the array
//args = decodeURI(hasharray.join(":")); // merge all of them back together to account for not: operators
if (decodeURIComponent(hash) == recentHash) { // recentHash is assumed to always be decoded
return;
}
//alert("hash changed from " +recentHash + " to " + hash + ". ver1");
recentHash = decodeURIComponent(hash); // recentHash is assumed to always be decoded
load_content(hash);
}
setInterval(check_hash, 500); // need to check hash very often to detect back button presses. 1000 = 1 sec.
}
// function to be called whenever a new dynamic page is "loaded."
// rules for use:
// use this to set a new hash in a function which creates a page from which you should be able to hit "back" and expect proper behavior.
// syntax: you need to call manual_hash("operator:args"), where operator is:
// qt: query_tags
// qu: query_uids
// etc. see the load_content function for all operators.
// generally this won't be necessary, since every ajax_magic function will have its own operator, and you'll only need to add one or call it when you're writing a new function that gives a "full page"
// none of this probably makes sense. sorry.
// EXECUTIVE SUMMARY: if you do an AJAX request into d_query, you should probably add a manual_hash to the end of the AJAX request, and add the corresponding entry in the load_content function.
function manual_hash(hash)
{
recentHash = decodeURIComponent(hash); // recentHash is assumed to always be decoded
document.location.hash = hash;
}
// function called when hash changes, so we can load new content appropriately
// this function could also probably be used as a sitemap
function load_content(hash)
{
//alert("loading content for hash: " + hash);
hasharray = hash.split(":");
operator = hasharray[0];
hasharray.splice(0,1); // remove the first element of the array
args = decodeURI(hasharray.join(":")); // merge all of them back together to account for not: operators
//alert("operator is " + operator);
// here we goooooo. these should _roughly_ correspond to the order the functions appear in this file
switch (operator)
{
case "":
home(); break;
case "sq":
search_query(args); break;
case "qt":
query_tags(args); break;
case "qu":
query_uids(args); break;
case "restorecart":
restore_cart(args); break;
case "cart":
query_cart(); break;
case "listtags":
list_tags(); break;
case "helpout":
help_out(); break;
case "userinfo":
user_info(); break;
case "savedcarts":
saved_carts(); break;
case "sharedcarts":
shared_carts(); break;
case "taggame":
play_tag_game(); break;
case "myprobs":
query_my_probs(); break;
}
}
// This will be called from the search box. Currently, it only handles a single uid input, or a tag input.
function search_query(item)
{
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
manual_hash("sq:"+item);
document.getElementById("d_query").innerHTML=xmlhttp.responseText;
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"d_query"]); // re-renders page with MathJax
}
}
if(!isNaN(parseInt(item))) {
// If we have a number...
xmlhttp.open("GET","query_uids.php?uids="+item);
xmlhttp.send();
document.getElementById("d_query").innerHTML=splines();
} else {
// If we have a tag...
xmlhttp.open("GET","query_tags.php?tags="+encodeURI(item));
xmlhttp.send();
document.getElementById("d_query").innerHTML=splines();
}
}
// the following are the various query functions
function query_tags(taglist)
{
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
manual_hash("qt:" + encodeURI(taglist));
window.last_query_type = "tags";
window.last_query_value = taglist;
document.getElementById("d_query").innerHTML=xmlhttp.responseText;
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"d_query"]); // re-renders page with MathJax
}
}
xmlhttp.open("GET","query_tags.php?tags="+encodeURI(taglist));
xmlhttp.send();
document.getElementById("d_query").innerHTML=splines();
}
function query_uids(uidlist)
{
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
manual_hash("qu:" + encodeURI(uidlist));
window.last_query_type = "uids";
window.last_query_value = uidlist;
document.getElementById("d_query").innerHTML=xmlhttp.responseText;
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"d_query"]); // re-renders page with MathJax
}
}
xmlhttp.open("GET","query_uids.php?uids="+uidlist);
xmlhttp.send();
document.getElementById("d_query").innerHTML=splines();
}
function query_cart()
{
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
manual_hash("cart");
window.last_query_type = "cart";
window.last_query_value = "";
document.getElementById("d_query").innerHTML=xmlhttp.responseText;
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"d_query"]); // re-renders page with MathJax
}
}
xmlhttp.open("GET","query_cart.php");
xmlhttp.send();
document.getElementById("d_query").innerHTML=splines();
}
function query_all()
{
}
function query_last()
{
if (window.last_query_type == "tags")
{
query_tags(window.last_query_value);
}
else if (window.last_query_type == "uids")
{
query_uids(window.last_query_value);
}
else if (window.last_query_type == "cart")
{
query_cart();
}
else if (window.last_query_type == "myprobs")
{
query_my_probs();
}
else
{
}
}
// tag box functions
function load_tag_box(uid)
{
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("tagarea"+uid).innerHTML=xmlhttp.responseText;
document.getElementById('text'+uid).focus();
}
}
xmlhttp.open("GET","tag_box.php?uid="+uid);
xmlhttp.send();
document.getElementById("tagarea"+uid).innerHTML="Loading";
}
function add_tag(uid,tag)
{
regex=/^[0-9a-zA-Z ,]+$/;
if (regex.test(tag))
{
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("taglist"+uid).innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","tag_problem.php?uid="+uid+"&tag="+tag);
xmlhttp.send();
document.getElementById("taglist"+uid).innerHTML="Loading";
document.getElementById("text"+uid).value="";
}
else
{
alert("Only letters, numbers and spaces are allowed in tag names.");
}
}
// function to add a problem to the cart by uid
function add_to_cart(uid)
{
xmlhttp[uid]=new XMLHttpRequest();
xmlhttp[uid].onreadystatechange=function() {
if (xmlhttp[uid].readyState==4 && xmlhttp[uid].status==200) {
document.getElementById("button"+uid).innerHTML=xmlhttp[uid].responseText;
update_cart_count();
}
}
xmlhttp[uid].open("GET","addtocart.php?uid="+uid, true);
xmlhttp[uid].send();
document.getElementById("button"+uid).innerHTML="<img src='img/ajax-loader.gif'>";
}
// Shares or unshares a cart from the carts menus
function share_cart(cartnumber,personid) {
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("cart"+cartnumber+"_"+personid).innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","cart_share.php?cart="+cartnumber+"&personid="+personid+"&change=true", true);
xmlhttp.send();
}
// function that accepts multiple uids to add to cart, forcing each one and looping only on completion
// this prevents an overload of ajax requests all at once, which evidently is bad form, and also doesn't work.
function add_to_cart_bulk()
{
var args = Array.prototype.slice.call(arguments);
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("button"+args[0]).innerHTML=xmlhttp.responseText;
args.shift();
if (args[0] !== undefined)
{
add_to_cart_bulk.apply(null, args); // continue the loop of adding problems to cart
} else {
update_cart_count(); // if there's nothing left, update the cart count.
}
}
}
xmlhttp.open("GET","addtocart.php?uid="+args[0]+"&force=true", true);
xmlhttp.send();
document.getElementById("button"+args[0]).innerHTML="<img src='img/ajax-loader.gif'>";
}
// function to update the cart count
function update_cart_count()
{
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("cartcount").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","print_cart_count.php", true);
xmlhttp.send();
}
// empty the cart
function empty_cart()
{
ans=confirm("You are about to remove all your selected problems. This action cannot be undone. Are you sure?");
if (ans) {
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("d_query").innerHTML=xmlhttp.responseText;
update_cart_count();
manual_hash("");
}
}
xmlhttp.open("GET","empty_cart.php?header=emptycart", true);
xmlhttp.send();
}
}
// restore a cart
function restore_cart(uid_list)
{
ans=confirm("You are restoring a list of problems. This will REPLACE your currenly selected problems and cannot be undone. Do you wish to continue?");
if (ans) {
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
//manual_hash("restorecart:"+uid_list);
document.getElementById("d_query").innerHTML=xmlhttp.responseText;
update_cart_count();
query_cart();
}
}
xmlhttp.open("GET","index_restore_cart.php?restore_cart="+uid_list, true);
xmlhttp.send();
}
}
// function to toggle solution display
function toggle_sol_disp()
{
xmlhttp_sol=new XMLHttpRequest();
xmlhttp_sol.onreadystatechange=function() {
if (xmlhttp_sol.readyState==4 && xmlhttp_sol.status==200) {
document.getElementById("sol_disp").innerHTML=xmlhttp_sol.responseText;
query_last();
}
}
xmlhttp_sol.open("GET","print_sol_disp_pref.php?toggle=true", true);
xmlhttp_sol.send();
}
// function to toggle the display of solutions with the checkbox.
function toggle_sol_disp_checkbox()
{
xmlhttp_sol=new XMLHttpRequest();
xmlhttp_sol.onreadystatechange=function() {
if (xmlhttp_sol.readyState==4 && xmlhttp_sol.status==200) {
document.getElementById("solutions_topbar").innerHTML=xmlhttp_sol.responseText;
conditional_reload();
}
}
xmlhttp_sol.open("GET","toggle.php?q=solutions", true);
xmlhttp_sol.send();
}
// function to toggle the display of tags with the checkbox.
function toggle_tag_disp_checkbox()
{
xmlhttp_sol=new XMLHttpRequest();
xmlhttp_sol.onreadystatechange=function() {
if (xmlhttp_sol.readyState==4 && xmlhttp_sol.status==200) {
document.getElementById("tags_topbar").innerHTML=xmlhttp_sol.responseText;
conditional_reload();
}
}
xmlhttp_sol.open("GET","toggle.php?q=tags", true);
xmlhttp_sol.send();
}
// function for the above two checkbox functions, to avoid reloading on pages that don't need it
function conditional_reload()
{
curhash = document.location.hash.substr(1);
if (curhash != "" && curhash != "sharedcarts" && curhash != "savedcarts" && curhash != "helpout" && curhash != "userinfo" && curhash != "listtags")
{
location.reload(true);
}
}
// function to toggle tag display
function toggle_tag_disp()
{
xmlhttp_sol=new XMLHttpRequest();
xmlhttp_sol.onreadystatechange=function() {
if (xmlhttp_sol.readyState==4 && xmlhttp_sol.status==200) {
document.getElementById("tag_disp").innerHTML=xmlhttp_sol.responseText;
query_last();
}
}
xmlhttp_sol.open("GET","print_tag_disp_pref.php?toggle=true", true);
xmlhttp_sol.send();
}
// function to toggle preferences for a given tag
function toggle_tag_pref(tag)
{
xmlhttp_sol=new XMLHttpRequest();
xmlhttp_sol.onreadystatechange=function() {
if (xmlhttp_sol.readyState==4 && xmlhttp_sol.status==200) {
document.getElementById("error_box").innerHTML=xmlhttp_sol.responseText;
}
}
xmlhttp_sol.open("GET","toggle_tag_pref.php?tag="+encodeURIComponent(tag), true);
xmlhttp_sol.send();
}
// show the tag preferences page
function list_tags()
{
xmlhttp_add=new XMLHttpRequest();
xmlhttp_add.onreadystatechange=function() {
if (xmlhttp_add.readyState==4 && xmlhttp_add.status==200) {
manual_hash("listtags");
document.getElementById("d_query").innerHTML=xmlhttp_add.responseText;
}
}
xmlhttp_add.open("GET","list_tags.php", true);
xmlhttp_add.send();
}
// show the help out page
function help_out()
{
xmlhttp_add=new XMLHttpRequest();
xmlhttp_add.onreadystatechange=function() {
if (xmlhttp_add.readyState==4 && xmlhttp_add.status==200) {
manual_hash("helpout");
document.getElementById("d_query").innerHTML=xmlhttp_add.responseText;
}
}
xmlhttp_add.open("GET","help_out.php", true);
xmlhttp_add.send();
}
// Show the home page
function home()
{
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
manual_hash("");
document.getElementById("d_query").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","index_default_content.php", true);
xmlhttp.send();
document.getElementById("d_query").innerHTML=splines();
}
// show the user info page
function user_info()
{
xmlhttp_add=new XMLHttpRequest();
xmlhttp_add.onreadystatechange=function() {
if (xmlhttp_add.readyState==4 && xmlhttp_add.status==200) {
manual_hash("userinfo");
document.getElementById("d_query").innerHTML=xmlhttp_add.responseText;
}
}
xmlhttp_add.open("GET","user_info.php", true);
xmlhttp_add.send();
}
// show the saved carts page
function saved_carts()
{
xmlhttp_add=new XMLHttpRequest();
xmlhttp_add.onreadystatechange=function() {
if (xmlhttp_add.readyState==4 && xmlhttp_add.status==200) {
manual_hash("savedcarts");
document.getElementById("d_query").innerHTML=xmlhttp_add.responseText;
}
}
xmlhttp_add.open("GET","save_cart.php", true);
xmlhttp_add.send();
}
// show the shared carts page
function shared_carts()
{
xmlhttp_add=new XMLHttpRequest();
xmlhttp_add.onreadystatechange=function() {
if (xmlhttp_add.readyState==4 && xmlhttp_add.status==200) {
manual_hash("sharedcarts");
document.getElementById("d_query").innerHTML=xmlhttp_add.responseText;
}
}
xmlhttp_add.open("GET","shared_carts.php", true);
xmlhttp_add.send();
}
// Saves a new password.
function save_new_pw()
{
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("d_query").innerHTML=xmlhttp.responseText;
}
}
params=
"oldpw="+encodeURIComponent(document.edit_pw.oldpw.value)
+"&newpw1="+encodeURIComponent(document.edit_pw.newpw1.value)
+"&newpw2="+encodeURIComponent(document.edit_pw.newpw2.value);
xmlhttp.open("POST","user_info.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(params);
}
function save_my_cart()
{
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
manual_hash("savedcarts");
document.getElementById("d_query").innerHTML=xmlhttp.responseText;
}
}
params=
"cartname="+encodeURIComponent(document.save_cart.cart_name.value);
xmlhttp.open("POST","save_cart.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(params);
}
// allows people to change the course they are currently associated to
function change_current_course(course) {
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("current_selected_course").innerHTML=xmlhttp.responseText;
}
}
close_everything_but('');
xmlhttp.open("GET","change_current_course.php?course="+encodeURIComponent(course),true);
xmlhttp.send();
}
// play tag game!
function play_tag_game()
{
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
manual_hash("taggame");
document.getElementById("d_query").innerHTML=xmlhttp.responseText;
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"d_query"]); // re-renders page with MathJax
}
}
xmlhttp.open("GET","tag_game.php",true);
xmlhttp.send();
document.getElementById("d_query").innerHTML=splines();
}
function addTagRevert(uid) {
document.getElementById("tagarea"+uid).innerHTML="<small>Tags: (<a class='xbutton' href=\"javascript:load_tag_box("+uid+")\">add tag</a>)</small>";
}
// This is only used on the "My carts" page at the moment...
function yesToNo(personid,cartnumber)
{
if(document.getElementById( cartnumber+"_"+personid ).innerHTML=="Yes") {
document.getElementById( cartnumber+"_"+personid ).innerHTML="No";
} else {
document.getElementById( cartnumber+"_"+personid ).innerHTML="Yes";
}
}
function switchMenu(obj) {
var el = document.getElementById(obj);
if ( el.style.display != "none" ) {
el.style.display = 'none';
}
else {
el.style.display = '';
}
}
function popup_image(filename) { // this doesn't seem to be working for the moment...
window.open( "problem_images/"+filename, "myWindow", "status = 1, height = 300, width = 300, resizable = 0" );
}
function visibility_toggle(div) {
var current=document.getElementById(div).style.display;
if(current=="none") {
document.getElementById(div).style.display="block";
} else if(current=="block") {
document.getElementById(div).style.display="none";
} else {
alert("Something went wrong."+current);
}
}
// This closes all currently known divs except for a fixed one.
function close_everything_but(div) {
//if(div!="list_of_current_course_options") {
// document.getElementById('list_of_current_course_options').style.display="none";
//}
//if(div!="cart_pop_down") {
// document.getElementById('cart_pop_down').style.display="none";
//}
if(div!="login_pop_down_options") {
document.getElementById('login_pop_down_options').style.display="none";
}
}
// More link for related.
function related_more_toggle() {
if(document.getElementById('related_search').style.height=="60px") { // need to open.
document.getElementById('related_search').style.height="auto";
document.getElementById('related_search_more').innerHTML="<a href='javascript:related_more_toggle();' style='color: black; text-decoration: none;'>Less</a>";
document.getElementById('related_search_more_td').vAlign="bottom";
} else { // need to close.
document.getElementById('related_search').style.height="60px";
document.getElementById('related_search_more').innerHTML="<a href='javascript:related_more_toggle();' style='color: black; text-decoration: none;'>More</a>";
document.getElementById('related_search_more_td').vAlign="top";
}
}
// Query my problems.
function query_my_probs()
{
xmlhttp_add=new XMLHttpRequest();
xmlhttp_add.onreadystatechange=function() {
if (xmlhttp_add.readyState==4 && xmlhttp_add.status==200) {
manual_hash("myprobs");
window.last_query_type = "myprobs";
document.getElementById("d_query").innerHTML=xmlhttp_add.responseText;
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"d_query"]); // re-renders page with MathJax
}
}
xmlhttp_add.open("GET","query_my_probs.php", true);
xmlhttp_add.send();
}
// returns the text for a loading page
function splines()
{
return "<br><br><center>Reticulating splines...</center>";
}