####
"use strict";
if ( typeof $().emulateTransitionEnd !== 'function')
{
throw("Bootstrap doesn’t seem to be available…");
}
function colorReps() {
$("div.reputation").each(function(){
$(this).text().match(/\s\d/) ?
$(this).css({color:"teal", opacity:0.66, fontSize:"85%"}) :
$(this).css({color:"#DF3969", opcaity:0.66 , fontSize:"85%"});
});
}
function submitVote () {
// Need to unbind and/or include a spinner.
console.log("submitVote…");
let $clicked = $(this);
$clicked.off(); // Right?
$clicked.closest("div").animate({opacity:0},999)
.children().prop("disabled",true);
let $vote = $clicked.parent("label").find("button");
let $form = $vote.closest("form");
let voteName = $vote.attr("name");
let voteNodeId = voteName.replace(/vote__/,"");
let nodeId = $form.find("input[name='node_id']").val();
let formData = {
node_id: nodeId
,vc: $form.find("input[name='vc']").val()
,op: $form.find("input[name='op']").val()
,sexisgreat: $form.find("input[name='sexisgreat']").val()
};
formData[voteName] = $vote.val();
$.ajax({ method: $form.attr("method")
,url: $form.attr("action")
,data: formData
})
.fail(function(jqXHR, textStatus, errorThrown){
console.log(jqXHR);
if ( textStatus === "abort" ) return;
$clicked.closest("div").stop().animate({ opacity: 1 });
$vote.closest("div.reputation").text([textStatus, errorThrown || "unknown"].join(": "));
})
.done(function( html, textStatus, jqXHR ) {
console.log("here in top of done with node " + nodeId + " and vote " + voteNodeId);
console.log("div.reputation with node " + nodeId + " and vote " + voteNodeId);
let $html = $($.parseHTML(html));
let $rep = $html.find("#rep-" + voteNodeId);
console.log("received html find " + $rep.html());
$rep.css({opacity:0});
$clicked.closest("div").replaceWith($rep);
$rep.animate({ opacity: 1 }, 666);
let $xp = $("h1:contains(XP Nodelet)")
.filter(function(){ return $(this).children().length === 0 })
.parent()
.find("div");
// Can't use the same selector because the DOM isn't the same pre-transform.
let $newXp = $html.find("#XP_Nodelet td");
// Account for out of votes for day.
if ( $newXp.length )
{
$xp.fadeOut(100, function(){ $(this).html( $newXp.html() ).fadeIn(100) });
}
else
{
$xp.closest("section").fadeOut(100, function(){ $(this).remove() });
// Remove all vote buttons too. Untested, might work.
$("div.reputation").find("button").closest("div.reputation")
.fadeOut(100, function(){ $(this).remove() });
}
colorReps();
});
}
jQuery(function($) {
$("body").hide().fadeIn(100);
colorReps();
$("body").css({ color:"#00000a" }); // not being carried over anywhere...
let $stripe = $('
##
// What XML generators are currently available on PerlMonks? https://perlmonks.org/?node_id=72241
// PerlMonks Related Scripts https://perlmonks.org/?node_id=26649
// REQUIRES he.js
"use strict";
// throw("Not ready to be incurring load from regular visits");
jQuery(function($) {
let $currentMsg = $(".cb_msg");
setTimeout(function(){ $currentMsg.fadeOut(function(){ $(this).remove() }) }, 500000);
//
$("table.cb_table").css({margin:"1ex 0", fontSize:"1.4rem"}); // Dup.
let $CBform = $("input[type='submit'][name='message_send']").closest("form");
$CBform.find("input[name='message']").css({width:"100%",border:"1px solid gray",borderRadius:"2px"});
$CBform.find("input[name='message_send']").hide();
$CBform.parent().find("hr, input[type='checkbox']").remove();
$CBform.find("label, span.msg, span.cb_more_messages").delay(15000).slideUp(1000, function(){ $CBform.parent().find("br").remove() });
//span.cb_more_messages
$CBform.parent().css({padding:0});
// Needs some click animation-
$("input[type='submit']").css({border:"1px solid gray",borderRadius:"2px",margin:"2px 3px"});
$("i.cb_quiet").wrap('');
let intID;
let chatURI = document.location.origin + "/bare/";
// .cb_table
// Timer, interval, like gmail; check frequently if there are a lot of current messages.
// Less and less frequently when there is none.
// getCB
// displayCB
function getCB ( arg ) {
if ( ! arg ) arg = { timeout: 5000 };
if ( arg.timeout < 500000 ) arg.timeout += 10000; // maybe 10% of current instead?
let queryData = { "node_id":207304 // hardcode node…
,"xmlstyle":"modern" } // Get the parsed->rendered messages.
$.ajax({
method: "GET"
,url: chatURI
,data: queryData
,dataType: "xml"
})
.fail(function(jqXHR, textStatus, errorThrown){
console.log(jqXHR);
console.log([textStatus, errorThrown || "unknown"].join(": "));
console.log('setTimeout( getCB, ' + arg.timeout + ', arg );');
intID = setTimeout( getCB, arg.timeout, arg );
})
.done(function( xml, textStatus, jqXHR ) {
console.log("Received…", xml);
if ( ! xml ) {
console.log('setTimeout( getCB, ' + arg.timeout + ', arg );');
intID = setTimeout( getCB, arg.timeout, arg );
return false;
}
// Getting null sometimes.
let messages = xml.getElementsByTagName("message");
if ( ! messages.length ) {
console.log('setTimeout( getCB, ' + arg.timeout + ', arg );');
intID = setTimeout( getCB, arg.timeout, arg );
return false;
}
let $CBtable = $("table.cb_table");
if ( ! $CBtable.length ) { // No messages in the page currently…
$CBtable = $('');
// and all is quiet...
// Always there by class? and all is quiet...
$("i.cb_quiet").replaceWith($CBtable);
}
$CBtable.css({margin:"1ex 0", fontSize:"1.4rem"}); // Dup…
for (var i = 0; i < messages.length; i++ )
{
let message = {
author: messages[i].getElementsByTagName("author")[0].textContent
,user: messages[i].getElementsByTagName("author_user")[0].textContent
,epoch: messages[i].getElementsByTagName("createdepoch")[0].textContent
,id: messages[i].getElementsByTagName("message_id")[0].textContent
,text: messages[i].getElementsByTagName("parsed")[0].textContent
};
// Skip duplicates!
let renderedMessage = `
`;
setTimeout(function(){ $(".msg_id_" + message.id).fadeOut() }, 500000);
console.log(renderedMessage);
$CBtable.append(renderedMessage); // I think the direction is settable…
}
intID = setTimeout( getCB, 5000 );
});
}
getCB();
// console.log( "node_id from CB form -> " + $CBform.find("input[name='node_id']").val() );
$CBform.submit(function(evt){
evt.preventDefault();
sendMessage();
});
function sendMessage () {
let formData = {
node_id: $CBform.find("input[name='node_id']").val()
,op: $CBform.find("input[name='op']").val() // "message"
,message: he.encode( $CBform.find("input[name='message']").val() )
,message_send: $CBform.find("input[name='message_send']").val() // "talk"
};
console.log(formData);
$.ajax({
method: $CBform.attr("method")
,url: $CBform.attr("action")
,data: formData
})
.fail(function(jqXHR, textStatus, errorThrown){
console.log(jqXHR);
console.log(".fail -> " + [textStatus, errorThrown || "unknown"].join(": "));
})
.done(function( html, textStatus, jqXHR ) {
$CBform.find("input[name='message']").val("");
clearTimeout(intID);
getCB({ timeout: 10000 });
});
}
$(document).on("visibilitychange", function(){
if ( document.hidden )
{
console.log("Tab is hidden, ceasing ajax CB");
clearTimeout(intID);
}
else
{
getCB({ timeout: 60000 });
console.log("Tab is visible, restarting ajax CB");
}
});
});
##
##
body {
opacity: 0 !important;
transition: opacity 0.5s;
}
##
##
plackup -p 8282 -MPlack::App::Directory -e \
'Plack::App::Directory->new({root => q{/path/to/the/files}})->to_app' \
--enable-ssl \
--ssl-key-file /path/to/certs/localhost.key \
--ssl-cert-file /path/to/certs/localhost.cert