!7 // "Matrix functions" are not supposed to use the index // ...but now they can. !include once #1013530 // Dyn html { bool authed = creatorAuthed(); S _topic = params.get("topic"); if (empty(_topic)) _topic = ai_randomString(); fS topic = _topic; if (nempty(params.get("topic"))) { // not from "random topic" url // post user's answers (verified or unverified) // free-text line S newCat = params.get("new-cat"), newValue = params.get("new-value"); if (nempty(newCat)) { S verb = ai_matrix_answerToVerb(newValue); if (nempty(verb)) post(topic, verb, newCat); else post(quote(newCat), " is a matrix category for", topic); } // all other lines for (S key : keysStartingWith2(params, "cat-")) { S value = params.get(key); continue if empty(value); S verb = ai_matrix_answerToVerb(value); continue if empty(verb); S cat = urldecode(dropPrefix("cat-", key)); temp tempSetThreadLocal(ai_postTriple_verified, authed); post(topic, verb, cat); } } L functions = ai_matrix_standardFunctions(); Map rawResults = evaluateFunctionsAsMap(functions, topic); SS results = mapValues(f ai_html_struct, rawResults); for (S f : keys(rawResults)) postWithSource(topic, "under " + f + " is", sfu(rawResults.get(f)), "matrix"); final L answers = concatLists(ll(""), ai_matrix_standardAnswers()); Set options = ai_matrix_categoriesForTopic(topic); options.addAll(ai_matrix_standardCategories()); L data = map(options, func(S cat) -> Map { S userAnswer = null; ret litorderedmap( "Statement", b(htmlencode2(topic)) + " is " + html_matrixLink(cat), "Computer Answer", htmlEncode(ai_matrixGet(topic, cat)), "Your Answer", hselect_list(answers, userAnswer, name := "cat-" + urlencode(cat)) //hcheckbox(urlencode(s), tossCoin()) ); }); S formURL = //smartBotRealURL() + "/dyn/" + psI(programID()) + "?topic=" + urlencode(topic); smartBot_matrixLink(topic); // Free category entry line data.add(litorderedmap( "Statement", b(htmlencode2(topic)) + " is " + htextinput("new-cat", onkeypress := [[ if ($("#new_value").val() == '') $("#new_value").val("yes").prop('selected', true); ]]), "Your Answer", hselect_list(answers, name := "new-value", id := "new_value"))); // Main HTML ret hstyle_matrixBackground() + htitle_htmlencode("Matrix: " + topic) + loadJQuery() + div(small(authed ? "Authed" : "Not authed"), style := "position:absolute; right: 10px; top: 10px;") + hcenter( hform("Topic: " + hinputfield('topic, value := topic), style := "display: inline", action := smartBot_emptyMatrixLink()) + " " + hform(hsubmit("Random"), style := "display: inline", action := "/matrix/") + p(b( hfontsize(15, "Matrix Page for:") + "
" + targetBlank(smartBot_encyclopediaLink(topic), hfontsize(40, topic), style := "text-decoration: none")) + "
" /*+ ahref(smartBot_encyclopediaLink(topic), "[more]")*/, style := "margin-top: 3em") + hpostform(hhidden(+topic) + hsubmit("Save answers") + "

" + htable_noEncode(data), action := formURL) + htable_noEncode(mapToListOfMaps(results, "Function", "Result")) ); }