// ==UserScript==
// @name Soylent Upgrade
// @version 11.0
// @match http://soylentnews.org/*article.pl*
// @match http://*.soylentnews.org/*article.pl*
// @match https://soylentnews.org/*article.pl*
// @match https://*.soylentnews.org/*article.pl*// @match http://soylentnews.org/*submit.pl*
// @match http://*.soylentnews.org/*submit.pl*
// @match https://soylentnews.org/*submit.pl*
// @match https://*.soylentnews.org/*submit.pl*// @match http://soylentnews.org/*admin.pl*
// @match http://*.soylentnews.org/*admin.pl*
// @match https://soylentnews.org/*admin.pl*
// @match https://*.soylentnews.org/*admin.pl*// @match http://soylentnews.org/*comments.pl*
// @match http://*.soylentnews.org/*comments.pl*
// @match https://soylentnews.org/*comments.pl*
// @match https://*.soylentnews.org/*comments.pl*// @match http://soylentnews.org/*journal.pl*
// @match http://*.soylentnews.org/*journal.pl*
// @match https://soylentnews.org/*journal.pl*
// @match https://*.soylentnews.org/*journal.pl*
// ==/UserScript==// User Options:
var simplifyChars = true; // Change to false if you don't want stylized quotation marks, ellipses, etc. to be replaced
var stripEmail = false; // Remove auto-filled email from submission
var doiChecker = true; // Add Crossref search to DOIs in the summary// End User Options
/* ! http://mths.be/fromcodepoint v0.1.0 by @mathias */
if (!String.fromCodePoint) { (function() { var defineProperty = (function() { try { var object = {}; var $defineProperty = Object.defineProperty; var result = $defineProperty(object, object, object) && $defineProperty; } catch(error) {} return result; }()); var stringFromCharCode = String.fromCharCode; var floor = Math.floor; var fromCodePoint = function() { var MAX_SIZE = 0x4000; var codeUnits = []; var highSurrogate; var lowSurrogate; var index = -1; var length = arguments.length; if (!length) { return ''; } var result = ''; while (++index < length) { var codePoint = Number(arguments[index]); if ( !isFinite(codePoint) || codePoint < 0 || codePoint > 0x10FFFF || floor(codePoint) != codePoint ) { throw RangeError('Invalid code point: ' + codePoint); } if (codePoint <= 0xFFFF) { codeUnits.push(codePoint); } else { codePoint -= 0x10000; highSurrogate = (codePoint >> 10) + 0xD800; lowSurrogate = (codePoint % 0x400) + 0xDC00; codeUnits.push(highSurrogate, lowSurrogate); } if (index + 1 == length || codeUnits.length > MAX_SIZE) { result += stringFromCharCode.apply(null, codeUnits); codeUnits.length = 0; } } return result; }; if (defineProperty) { defineProperty(String, 'fromCodePoint', { 'value': fromCodePoint, 'configurable': true, 'writable': true }); } else { String.fromCodePoint = fromCodePoint; } }()); }// Add "Quote This" buttons to all initially visible comments
var spans = document.getElementsByTagName("span");
for (var x=0; x<spans.length; x++)
{
if (spans[x].id.indexOf("reply_link_")==0)
{
var button = document.createElement("span");
button.setAttribute("class","nbutton");
var p = document.createElement("p");
var b = document.createElement("b");
var a = document.createElement("a");
// Set the href of the "Quote This" button to the href of the "Reply to This" button, with the escaped contents of the post added to URL and any [domain.names] following links in the post cut out:
a.setAttribute("href",spans[x].getElementsByTagName("a")[0].href.replace("#post_comment","&postercomment="+escape("<blockquote>"+document.getElementById("comment_body_"+spans[x].id.replace("reply_link_","")).innerHTML.replace(/<\/a>\s\[.*?\..*?\]/g,"<\/a>")+"<\/blockquote>\n\n")+"#post_comment"));
// To Do: Shorten URLs longer than 2000 characters
a.appendChild(document.createTextNode("Quote This"));
b.appendChild(a);
p.appendChild(b);
button.appendChild(p);
spans[x].parentNode.insertBefore(button, spans[x].nextSibling);
spans[x].parentNode.insertBefore(document.createTextNode(" "), spans[x].nextSibling); // Divider
}
}// DOI checker in the summary
if (doiChecker && window.location.href.search(/https?\:\/\/.*soylentnews\.org.*?\/article\.pl/)!=-1)
{
var summary = document.getElementById("articles").getElementsByClassName("intro")[0];
summary.innerHTML = summary.innerHTML.replace(/(\(|\[)DOI: (10[^\)]*?)(\)|\])/gi,"$1DOI: <a href='http://search.crossref.org/?q=$2' target='_blank'>$2</a>$3");
summary.innerHTML = summary.innerHTML.replace(/(\(|\[)open, DOI: (10[^\)]*?)(\)|\])/gi,"$1open, DOI: <a href='http://search.crossref.org/?q=$2' target='_blank'>$2</a>$3");
}// Empty email input area, but only on submission page
if (stripEmail && window.location.href.search(/https?\:\/\/.*soylentnews\.org.*?\/submit\.pl/)!=-1)
{
var boxes = document.getElementsByTagName("input");
for (var x=0; x<boxes.length; x++)
{
if (boxes[x].name == "email")
{
boxes[x].value = "";
}
}
}// Add title case button next to title/subj field on Story Submissions, Submission Preview, and Story Preview
if (window.location.href.search(/https?\:\/\/.*soylentnews\.org.*?\/(submit|admin)\.pl/)!=-1)
{
var boxes = document.getElementsByTagName("input");
for (var x=0; x<boxes.length; x++)
{
if (boxes[x].name == "title" || boxes[x].name == "subj")
{
boxes[x].id = "storyTitle";
var button = document.createElement("input");
button.setAttribute("type","button");
button.setAttribute("value","Title Case");
button.setAttribute("title","Convert title to title case.");
button.setAttribute("onclick","document.getElementById('storyTitle').value=document.getElementById('storyTitle').value.replace(/^\\s/gi,'').replace(/\\b([a-z])/gi,function(m, p1){return p1.toUpperCase();}).replace(/\\b(at|of|is|and|to|in|by|as|its|be|the|on|a|an|but|or|for)\\b/gi,function(m, p1){return p1.toLowerCase();}).replace(/^([a-z])/gi,function(m, p1){return p1.toUpperCase();}).replace(/:\\s([a-z])/gi,function(m, p1){return ': '+p1.toUpperCase();}).replace(/([a-z])['\u2019]([a-z])/gi,function(m, p1, p2){return p1+'\\''+p2.toLowerCase();}).replace(/\\bx(86|64)\\b/gi,'x$1').replace(/\\s$/gi,'');");
boxes[x].parentNode.insertBefore(button, boxes[x].nextSibling);
if (window.location.href.search(/https?\:\/\/.*soylentnews\.org.*?\/admin\.pl/)!=-1 || boxes[x].name == "subj")
{
boxes[x].parentNode.insertBefore(document.createElement("br"), boxes[x].nextSibling);
}
else
{
boxes[x].parentNode.insertBefore(document.createTextNode(" "), boxes[x].nextSibling);
}
}
}
}// Add warning for creating a story in the past
if (window.location.href.search(/https?\:\/\/.*soylentnews\.org.*?\/admin\.pl/)!=-1)
{
var boxes = document.getElementsByTagName("input");
for (var x=0; x<boxes.length; x++)
{
if (boxes[x].name == "op" && (boxes[x].value == "save"))
{
// New onclick extracts the post date, compares to the current date, and only submits if the post date is in the future or the user overrides the warning:
boxes[x].setAttribute("onclick","var d = new Date(document.getElementById('slashstoryform').elements['time'].value.replace(/\\s/,'T')); var a = true; if (d < Date.now()){a = confirm('Are you sure you want to post a story '+(Math.round((Date.now()-d)/60000))+' minutes in the past?');} if (a) {st_submit(this);}");
}
}
}var boxes = document.getElementsByTagName("textarea");
for (var x=0; x<boxes.length; x++)
{
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var temp = boxes[x].value; // Retrieve textarea contents
temp = temp.replace(/<\/p><p>/g,"<\/p>\n\n<p>"); // Add newlines between paragraphs
temp = temp.replace(/<br>\s?<br>/g,"<\/p>\n\n<p>"); // Convert double break tags to paragraph tags
temp = temp.replace(/<\/blockquote><p>/g,"<\/blockquote>\n\n<p>"); // Add newlines after blockquotes
temp = temp.replace(/<\/p><blockquote>/g,"<\/p>\n\n<blockquote>"); // Add newlines before blockquotes
temp = temp.replace(/<blockquote><div><p>/g,"<blockquote><div>\n\n<p>"); // Add newlines within start of blockquotes
temp = temp.replace(/<\/p><\/div><\/blockquote>/g,"<\/p>\n\n<\/div><\/blockquote>"); // Add newlines within end of blockquotes
temp = temp.replace(/<\/blockquote><blockquote>/g,"<\/blockquote>\n\n<blockquote>"); // Add newlines between two blockquotes
temp = temp.replace(/<p class="byline">\s/i,"<p class=\"byline\">"); // Remove extra space from byline
temp = temp.replace(/<p>\s/g,"<p>"); // Remove extra space from start of paragraph
temp = temp.replace(/\s<\/p>/g,"<\/p>"); // Remove extra space from end of paragraph
temp = temp.replace(/<\/li><li>/g,"<\/li>\n<li>"); // Add newlines between list items
temp = temp.replace(/(<\/li>)(<\/[u|o]l>)/g,'$1\n$2'); // Add newline after last list item
temp = temp.replace(/(<\/p>)(<[u|o]l>)/g,'$1\n$2'); // Add newlines before lists
temp = temp.replace(/<p>\[...\]/g,"<p>[...] "); // Add space within beginning of foreshortened paragraph
while (temp.indexOf(" ")!=-1)
{
temp = temp.replace(/ /g," "); // Replace double spaces with single spaces
}
if (simplifyChars)
{
temp = temp.replace(/\u2018/g,"'"); // 'LEFT SINGLE QUOTATION MARK' (U+2018) to (U+0027)
temp = temp.replace(/\u2019/g,"'"); // 'RIGHT SINGLE QUOTATION MARK' (U+2019) to (U+0027)
temp = temp.replace(/\u201C/g,"\""); // 'LEFT DOUBLE QUOTATION MARK' (U+201C) to (U+0022)
temp = temp.replace(/\u201D/g,"\""); // 'RIGHT DOUBLE QUOTATION MARK' (U+201D) to (U+0022)
temp = temp.replace(/\u2026/g,"..."); // 'HORIZONTAL ELLIPSIS' (U+2026) to (U+002E) x3
}
boxes[x].value = temp;
boxes[x].rows = 32; // Expand textarea height to 32 rows
}
var toolbar = document.createElement("div");// Blockquote button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Blockquote");
tempbutton.setAttribute("title","Wrap \u003Cblockquote\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addBlockquote(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Paragraph and Line break buttons
var tempspan = document.createElement("span");
tempspan.setAttribute("id","htmlFormatButtons");
if (document.getElementById("posttype") && document.getElementById("posttype").selectedIndex == 0)
{
tempspan.setAttribute("style","display:none;"); // Hide if initial post type option is "Plain Old Text"
}
if (document.getElementById("posttype"))
{
document.getElementById("posttype").addEventListener("change", function() {if (document.getElementById('posttype').selectedIndex == 0) {document.getElementById('htmlFormatButtons').style.display = 'none'} else {document.getElementById('htmlFormatButtons').style.display = 'inline'}}); // Change visibility of these buttons based on value of post type
}
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","P");
tempbutton.setAttribute("title","Wrap \u003Cp\u003E tags around the selected text.");
tempbutton.setAttribute("onclick","addPara(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","BR");
tempbutton.setAttribute("title","Insert a line break.");
tempbutton.setAttribute("onclick","addBreak(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
toolbar.appendChild(tempspan);// HR button, if editing a story
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","HR");
tempbutton.setAttribute("title","Insert a horizontal rule.");
tempbutton.setAttribute("style","text-decoration:underline overline;");
tempbutton.setAttribute("onclick","addHRule(document.getElementsByTagName('textarea')["+x+"]);");
tempspan.appendChild(tempbutton);
toolbar.appendChild(tempspan);
}// URL button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","URL");
tempbutton.setAttribute("title","Create a hyperlink around the selected text.");
tempbutton.setAttribute("style","text-decoration:underline;");
tempbutton.setAttribute("onclick","addHyperlink(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
toolbar.appendChild(document.createTextNode(" "));// Bold button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","B");
tempbutton.setAttribute("title","Bold");
tempbutton.setAttribute("style","font-weight:bold;");
tempbutton.setAttribute("onclick","addBold(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Italic button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","I");
tempbutton.setAttribute("title","Italic");
tempbutton.setAttribute("style","font-style:italic;");
tempbutton.setAttribute("onclick","addItalic(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Strike button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","S");
tempbutton.setAttribute("title","Strikethrough");
tempbutton.setAttribute("style","text-decoration:line-through;");
tempbutton.setAttribute("onclick","addStrike(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
// Code button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Code");
tempbutton.setAttribute("title","Wrap \u003Cecode\u003E tags around the selected text.");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addEcode(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Teletype button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","TT");
tempbutton.setAttribute("title","Wrap \u003Ctt\u003E (teletype, i.e. monospace) tags around the selected text.");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addTT(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Small button, if editing a story
if (boxes[x].name == "introtext" || boxes[x].name == "bodytext" || boxes[x].name == "story")
{
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","\u0073\u1D0D\u1D00\u029F\u029F");
tempbutton.setAttribute("title","Wrap \u003Csmall\u003E tags around the selected text.");
// tempbutton.setAttribute("style","font-size:75%;");
tempbutton.setAttribute("onclick","addSmall(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);
}toolbar.appendChild(document.createTextNode(" ")); // Divider
// Superscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u00B2");
tempbutton.setAttribute("title","Superscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSuper(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Subscript button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","x\u2082");
tempbutton.setAttribute("title","Subscript");
tempbutton.setAttribute("style","font-family:monospace;");
tempbutton.setAttribute("onclick","addSubsc(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createTextNode(" ")); // Divider
// Ordered list button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","1. List");
tempbutton.setAttribute("title","Insert an ordered list or convert newline-separated text into an ordered list.");
tempbutton.setAttribute("onclick","addOrdlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Unordered list button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","\u2022 List");
tempbutton.setAttribute("title","Insert an unordered list or convert newline-separated text into an unordered list.");
tempbutton.setAttribute("onclick","addUnordlist(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createElement("br")); // Divider
// Create 7 macro buttons
for (var i=1; i<=7; i++)
{
// Create macros if they don't exist
if(!localStorage.getItem("soymacro"+i))
{
localStorage.setItem("soymacro"+i,JSON.stringify(["M"+i,"string","Sample Text"]));
//localStorage.setItem("soymacro"+i,JSON.stringify(["M"+i,"regexp","/a/gi","b"]));
}
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("id","soymacros"+x+"button"+i);
tempbutton.setAttribute("value",JSON.parse(localStorage.getItem("soymacro"+i))[0]);
if (JSON.parse(localStorage.getItem("soymacro"+i))[1]=="string")
{
if (JSON.parse(localStorage.getItem("soymacro"+i))[2].length < 40)
{
tempbutton.setAttribute("title","Insert or replace selected text with: " + JSON.parse(localStorage.getItem("soymacro"+i))[2]);
}
else
{
tempbutton.setAttribute("title","Insert or replace selected text with: " + JSON.parse(localStorage.getItem("soymacro"+i))[2].substring(0,40)+"...");
}
tempbutton.setAttribute("onclick","macroChoose(document.getElementsByTagName('textarea')["+x+"],"+i+");");
}
else
{
tempbutton.setAttribute("title","Replace text matched by the regular expression: " + JSON.parse(localStorage.getItem("soymacro"+i))[2] + " with: " + JSON.parse(localStorage.getItem("soymacro"+i))[3]);
tempbutton.setAttribute("onclick","macroChoose(document.getElementsByTagName('textarea')["+x+"],"+i+");");
}
toolbar.appendChild(tempbutton);
}
// Create macros edit button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Edit");
tempbutton.setAttribute("title","Configure user macros or discard changes.");
tempbutton.setAttribute("onclick","if (document.getElementById('macrobar"+x+"').style.display == 'none') {document.getElementById('macrobar"+x+"').style.display = 'block'; macrobarInit("+x+");} else {document.getElementById('macrobar"+x+"').style.display = 'none'; if (p = document.getElementById('postercomment')) { var x = p.offsetTop; while (p = p.offsetParent) {x += p.offsetLeft;} window.scrollTo(0,x-75);}}");
toolbar.appendChild(tempbutton);toolbar.appendChild(document.createElement("br")); // Divider
// Despace button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value","Despace");
tempbutton.setAttribute("title","Delete newlines within the selection.");
tempbutton.setAttribute("onclick","despace(document.getElementsByTagName('textarea')["+x+"]);");
toolbar.appendChild(tempbutton);// Symbol button
var tempbutton = document.createElement("input");
tempbutton.setAttribute("type","button");
tempbutton.setAttribute("value",":-)");
tempbutton.setAttribute("title","Insert a symbol.");
tempbutton.setAttribute("onclick","if (document.getElementById('smilebar"+x+"').style.display == 'none') {document.getElementById('smilebar"+x+"').style.display = 'block'} else {document.getElementById('smilebar"+x+"').style.display = 'none'; if (p = document.getElementById('postercomment')) { var x = p.offsetTop; while (p = p.offsetParent) {x += p.offsetLeft;} window.scrollTo(0,x-75); } }");
toolbar.appendChild(tempbutton);
boxes[x].parentNode.insertBefore(toolbar, boxes[x].nextSibling);// Symbol list
var smilebar = document.createElement("div");
smilebar.setAttribute("style","-moz-user-select:none; -webkit-user-select:none; display:none; font-size:16pt; max-height:240px; overflow:auto; padding:0.5em;");
smilebar.setAttribute("id","smilebar"+x);
var smiles = ["\u0026amp;","\u0026lt;","\u0026gt;"];var codes = [[161,169],[171,172],[174],[176,177],[180,183],[187,191],[215],[224,255],[402],[629],[632],[916],[920],[931],[934],[937],[945,946],[956],[960],[963],[8216,8221],[8226],[8230],[8251],[8364],[8478],[8482],[8528,8542],[8585],[8592,8652],[8712,8716],[8721],[8730],[8733,8734],[8736],[8743,8749],[8756,8757],[8773],[8776],[8800,8805],[8834,8837],[8984],[9760],[9762,9765],[9770],[9773,9775],[9784,9794],[9812,9831],[9833,9842],[9850],[9855,9861],[9874,9877],[9882,9885],[9888,9893],[9913],[9940],[9962],[9971],[9981],[9992,10087],[65533],[127744,127756],[127759],[127775,127776],[127797],[127801],[127804,127812],[127817],[127820,127822],[127828,127831],[127838,127839],[127843],[127849],[127855],[127860,127867],[127891],[127904,127911],[127918],[127939],[127942],[127977],[128025],[128074,128078],[128123,128131],[128137,128142],[128148,128150],[128152],[128158],[128161,128164],[128168,128170],[128172],[128176,128177],[128187],[128189,128190],[128193,128194],[128197],[128203,128204],[128206],[128214],[128225,128227],[128231,128233],[128241],[128244],[128246],[128250,128252],[128259],[128266,128270],[128273,128276],[128278,128280],[128286],[128293,128299],[128302,128303],[128509,128565],[128659],[128684,128685]];
for (var i=0; i<codes.length; i++) { if (codes[i].length > 1) { for (var j=codes[i][0]; j<=codes[i][1]; j++) { smiles[smiles.length] = String.fromCodePoint(j); } } else { smiles[smiles.length] = String.fromCodePoint(codes[i][0]); } } // Populate smiles array with code ranges converted to individual characters
smiles = smiles.concat(["xD",":-)",":^)","(^_^;)","(\u00A0\u0361\u00B0\u00A0\u035C\u0296\u00A0\u0361\u00B0)","(\u00A0\u0361\u007E\u00A0\u035C\u0296\u00A0\u0361\u00B0)\uFEFF","\u00AF\u005C\u005F(\u30C4)\u005F\u002F\u00AF","(\u256F\u00B0\u25A1\u00B0\uFF09\u256F\uFE35\u00A0\u253B\u2501\u253B","(\u30CE\u0CA0\u76CA\u0CA0)\u30CE\u5F61\u253B\u2501\u253B","(\u0060\uFF65\u03C9\uFF65\u00B4)","\u0CA0_\u0CA0","\u0295\u2022\u1D25\u2022\u0294","(\u3065\uFFE3\u00A0\u00B3\uFFE3)\u3065","\u0669(\u204E\u275B\u1D17\u275B\u204E)\u06F6","\u30FD\u0F3C\u0E88\u0644\u035C\u0E88\u0F3D\uFF89","(\uB208\u2038\uB208)","\u006F(\u3003\uFF3E\u25BD\uFF3E\u3003)\u006F","\u0028\u0028\u30FE\u0028\u2267\u76BF\u2266\uFF1B\u0029\u30CE\uFF3F\u0029\u0029","\u30FD\u0028\u002A\u2312\u2207\u2312\u002A\u0029\uFF89","\u0028\u2267\u2207\u2266\u0029\u002F"]); // Add in arbitrary emoticons
for (var i=0; i<smiles.length; i++)
{
var smile = document.createElement("span");
smile.setAttribute("style","cursor:pointer; padding:2px; white-space:nowrap;");
smile.setAttribute("onclick","addSmile(document.getElementsByTagName('textarea')["+x+"],'"+smiles[i].replace("\u005C","\u005C\u005C")+"');");
smile.appendChild(document.createTextNode(smiles[i]));
smilebar.appendChild(smile);
if (i+1<smiles.length)
{
smilebar.appendChild(document.createTextNode(" "));
}
}
toolbar.parentNode.insertBefore(smilebar, toolbar.nextSibling);// Create macro configuration interface
var macrobar = document.createElement("div");
macrobar.setAttribute("style","display:none; padding:0.5em;");
macrobar.setAttribute("id","macrobar"+x);
var table = document.createElement("table");
var tr = document.createElement("tr");
var th = document.createElement("th");
th.appendChild(document.createTextNode("Name"));
tr.appendChild(th);
var th = document.createElement("th");
th.appendChild(document.createTextNode("Type"));
tr.appendChild(th);
var th = document.createElement("th");
th.appendChild(document.createTextNode("String | Expression"));
tr.appendChild(th);
var th = document.createElement("th");
th.setAttribute("title","Only used with expressions. Parenthesized substring matches (e.g. '$1') can be used.");
th.setAttribute("style","cursor:help;");
th.appendChild(document.createTextNode("Expression Replace"));
tr.appendChild(th);
table.appendChild(tr);
for (var i=1; i<=7; i++)
{
var tr = document.createElement("tr");// Macro name
var td = document.createElement("td");
var name = document.createElement("input");
name.setAttribute("type","text");
name.setAttribute("id","soymacros"+x+"name"+i);
td.appendChild(name);
tr.appendChild(td);// Macro type
var td = document.createElement("td");
var rad = document.createElement("input");
rad.setAttribute("type","radio");
rad.setAttribute("name","soymacros"+x+"type"+i);
rad.setAttribute("id","soymacros"+x+"type"+i+"S");
td.appendChild(rad);
td.appendChild(document.createTextNode(" String "));
var rad = document.createElement("input");
rad.setAttribute("type","radio");
rad.setAttribute("name","soymacros"+x+"type"+i);
rad.setAttribute("id","soymacros"+x+"type"+i+"E");
td.appendChild(rad);
td.appendChild(document.createTextNode(" Expression "));
tr.appendChild(td);// Field A
var td = document.createElement("td");
var f1 = document.createElement("input");
f1.setAttribute("type","text");
f1.setAttribute("id","soymacros"+x+"fieldA"+i);
td.appendChild(f1);
tr.appendChild(td);// Field B
var td = document.createElement("td");
var f1 = document.createElement("input");
f1.setAttribute("type","text");
f1.setAttribute("id","soymacros"+x+"fieldB"+i);
td.appendChild(f1);
tr.appendChild(td);table.appendChild(tr);
}
macrobar.appendChild(table);var p = document.createElement("p");
var save = document.createElement("input");
save.setAttribute("type","button");
save.setAttribute("value","Save");
save.setAttribute("title","Save any edits to the macro configuration.");
save.setAttribute("onclick","macrobarSave("+x+");");
p.appendChild(save);
p.appendChild(document.createTextNode(" "));
var guide = document.createElement("a");
guide.setAttribute("href","https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions");
guide.setAttribute("target","_blank");
guide.appendChild(document.createTextNode("Regexp Guide"));
p.appendChild(guide);
macrobar.appendChild(p);toolbar.parentNode.insertBefore(macrobar, toolbar.nextSibling);
}var temp = document.createElement("script");
// Add selection handling function
temp.appendChild(document.createTextNode("function getSelection(textarea) { if ('selectionStart' in textarea) { if (textarea.selectionStart != textarea.selectionEnd) { return [textarea.selectionStart,textarea.selectionEnd]; } } } "));// Add comment formatting buttons
temp.appendChild(document.createTextNode("function addBlockquote(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<blockquote>'+area.value.substring(sel[0],sel[1])+'<\/blockquote>' + area.value.substring(sel[1]); } } function addPara(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<p>'+area.value.substring(sel[0],sel[1])+'<\/p>' + area.value.substring(sel[1]); } } function addBreak(area) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + '<br>' + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+4,pos+4) } } function addHRule(area) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + '<hr>' + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+4,pos+4) } } function addHyperlink(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { url = prompt('URL:', 'https://'); area.value = area.value.substring(0,sel[0]) + '<a href=\"'+url+'\">'+area.value.substring(sel[0],sel[1])+'<\/a>' + area.value.substring(sel[1]); } } function addBold(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<b>'+area.value.substring(sel[0],sel[1])+'<\/b>' + area.value.substring(sel[1]); } } function addItalic(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<em>'+area.value.substring(sel[0],sel[1])+'<\/em>' + area.value.substring(sel[1]); } } function addStrike(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<strike>'+area.value.substring(sel[0],sel[1])+'<\/strike>' + area.value.substring(sel[1]); } } function addEcode(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<ecode>'+area.value.substring(sel[0],sel[1])+'<\/ecode>' + area.value.substring(sel[1]); } } function addTT(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<tt>'+area.value.substring(sel[0],sel[1])+'<\/tt>' + area.value.substring(sel[1]); } } function addSmall(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<small>'+area.value.substring(sel[0],sel[1])+'<\/small>' + area.value.substring(sel[1]); } } function addSuper(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sup>'+area.value.substring(sel[0],sel[1])+'<\/sup>' + area.value.substring(sel[1]); } } function addSubsc(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + '<sub>'+area.value.substring(sel[0],sel[1])+'<\/sub>' + area.value.substring(sel[1]); } } "));// Add list creation functions
temp.appendChild(document.createTextNode("function addOrdlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ol><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>').replace(/\\n<li><\\/li>/g,'') + '<\/li><\/ol>' + area.value.substring(area.selectionEnd); } else { temp = '<ol>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>\\n'; } area.value = area.value.substring(0,area.selectionStart) + temp.substring(0,temp.length-1) + '<\/ol>' + area.value.substring(area.selectionStart); } } } function addUnordlist(area) { if ('selectionStart' in area) { if (area.selectionStart != area.selectionEnd) { area.value = area.value.substring(0,area.selectionStart) + '<ul><li>' + area.value.substring(area.selectionStart,area.selectionEnd).replace(/\\n/g,'<\/li>\\n<li>').replace(/\\n<li><\\/li>/g,'') + '<\/li><\/ul>' + area.value.substring(area.selectionEnd); } else { temp = '<ul>'; while(listitem = prompt('Enter a list item. Leave the box empty or press Cancel to complete the list:', '')) { temp += '<li>' + listitem + '<\/li>\\n'; } area.value = area.value.substring(0,area.selectionStart) + temp.substring(0,temp.length-1) + '<\/ul>' + area.value.substring(area.selectionStart); } } }"));// Add macro functions
temp.appendChild(document.createTextNode("function macroChoose(area,x) { if (JSON.parse(localStorage.getItem('soymacro'+x))[1]=='string') { macroString(area,x); } else { macroRegexp(area,x); } }"));
temp.appendChild(document.createTextNode("function macroString(area,x) { var sel = getSelection(area); if (sel && sel[0] != sel[1]) { area.value = area.value.substring(0,sel[0]) + JSON.parse(localStorage.getItem('soymacro'+x))[2] + area.value.substring(sel[1]); } else if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,area.selectionStart) + JSON.parse(localStorage.getItem('soymacro'+x))[2] + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+JSON.parse(localStorage.getItem('soymacro'+x))[2].length,pos+JSON.parse(localStorage.getItem('soymacro'+x))[2].length); } }"));
temp.appendChild(document.createTextNode("function macroRegexp(area,x) { var sel = getSelection(area); if (sel && sel[0] != sel[1]) { var reg = JSON.parse(localStorage.getItem('soymacro'+x))[2]; area.value = area.value.substring(0,sel[0]) + area.value.substring(sel[0],sel[1]).replace(new RegExp(reg.substring(reg.indexOf('/')+1,reg.lastIndexOf('/')), reg.substring(reg.lastIndexOf('/')+1)),JSON.parse(localStorage.getItem('soymacro'+x))[3]) + area.value.substring(sel[1]); } }"));
temp.appendChild(document.createTextNode("function macrobarInit(x) { for (var y=1; y<=7; y++) { document.getElementById('soymacros'+x+'name'+y).value = JSON.parse(localStorage.getItem('soymacro'+y))[0]; if (JSON.parse(localStorage.getItem('soymacro'+y))[1]=='string') { document.getElementById('soymacros'+x+'type'+y+'S').checked = true; } else { document.getElementById('soymacros'+x+'type'+y+'E').checked = true; } document.getElementById('soymacros'+x+'fieldA'+y).value = JSON.parse(localStorage.getItem('soymacro'+y))[2]; if (JSON.parse(localStorage.getItem('soymacro'+y))[1]!='string') { document.getElementById('soymacros'+x+'fieldB'+y).value = JSON.parse(localStorage.getItem('soymacro'+y))[3]; } else { document.getElementById('soymacros'+x+'fieldB'+y).value = ''; } } }"));
temp.appendChild(document.createTextNode("function macrobarSave(x) { for (var y=1; y<=7; y++) { if (document.getElementById('soymacros'+x+'type'+y+'S').checked == true) { localStorage.setItem('soymacro'+y,JSON.stringify([document.getElementById('soymacros'+x+'name'+y).value,'string',document.getElementById('soymacros'+x+'fieldA'+y).value])); } else { localStorage.setItem('soymacro'+y,JSON.stringify([document.getElementById('soymacros'+x+'name'+y).value,'regexp',document.getElementById('soymacros'+x+'fieldA'+y).value,document.getElementById('soymacros'+x+'fieldB'+y).value])); } } document.getElementById('macrobar'+x).style.display = 'none'; var boxes = document.getElementsByTagName('textarea'); for (var z=0; z<boxes.length; z++) { for (var y=1; y<=7; y++) { document.getElementById('soymacros'+z+'button'+y).value = JSON.parse(localStorage.getItem('soymacro'+y))[0]; if (JSON.parse(localStorage.getItem('soymacro'+y))[1]=='string') { if (JSON.parse(localStorage.getItem('soymacro'+y))[2].length < 40) { document.getElementById('soymacros'+z+'button'+y).title = 'Insert or replace selected text with: ' + JSON.parse(localStorage.getItem('soymacro'+y))[2]; } else { document.getElementById('soymacros'+z+'button'+y).title = 'Insert or replace selected text with: ' + JSON.parse(localStorage.getItem('soymacro'+y))[2].substring(0,40)+'...'; } } else { document.getElementById('soymacros'+z+'button'+y).title = 'Replace text matched by the regular expression: ' + JSON.parse(localStorage.getItem('soymacro'+y))[2] + ' with: ' + JSON.parse(localStorage.getItem('soymacro'+y))[3]; } } } }"));// Add despace function
temp.appendChild(document.createTextNode("function despace(area) { var sel = getSelection(area); if (!(sel[0] == 0 && sel[1] == 0)) { area.value = area.value.substring(0,sel[0]) + area.value.substring(sel[0],sel[1]).replace(/\\r/g,' ').replace(/\\n/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ').replace(/\\s\\s/g,' ') + area.value.substring(sel[1]); } }"));// Add unicode insertion function
temp.appendChild(document.createTextNode("function addSmile(area, smile) { if ('selectionStart' in area) { var pos = area.selectionStart; area.value = area.value.substring(0,pos) + smile + area.value.substring(pos); area.focus(); area.setSelectionRange(pos+smile.length,pos+smile.length) } }"));document.getElementsByTagName('head')[0].appendChild(temp); // Add script to page
Kanye West wants $1 billion from Facebook’s Mark Zuckerberg
He’s “this generation’s Disney” and technology leaders like Mark Zuckerberg would be doing the world a favor by investing a cool $1 billion in his musical ambitions.
That was the gist of an early Monday tweetstorm by rapper Kanye West, hours after he raised questions about his personal finances with this tweet that hinted he has $53 million worth of debt:
I write this to you my brothers while still 53 million dollars in personal debt... Please pray we overcome... This is my true heart...
— KANYE WEST (@kanyewest) February 14, 2016In a fresh crop of posts, West made direct pleas to Zuckerberg, chief executive of Facebook Inc., and Larry Page, Alphabet Inc.’s CEO and the co-founder of Google, asking that they funnel some cash into his ideas:
Mark Zuckerberg invest 1 billion dollars into Kanye West ideas
— KANYE WEST (@kanyewest) February 14, 2016Mark Zuckerberg I know it’s your bday but can you please call me by 2mrw…
— KANYE WEST (@kanyewest) February 15, 2016World, please tweet, FaceTime, Facebook, instagram, whatever you gotta do to get Mark to support me…
— KANYE WEST (@kanyewest) February 15, 2016Mark, I am publicly asking you for help…
— KANYE WEST (@kanyewest) February 15, 2016hey Larry Page I’m down for your help too …
— KANYE WEST (@kanyewest) February 15, 2016West insinuated that Silicon Valley was full of hypocrites — executives who want to look cool listening to rap, yet never did anything to further growth in the music industry:
All you dudes in San Fran play rap music in your homes but never help the real artists…
— KANYE WEST (@kanyewest) February 15, 2016The rapper made a thinly veiled reference to Zuckerberg’s education philanthropy — he is part of an investment group that aims to bring cheap, private education to millions of children across Africa and Asia. Frankly, said West, the money could be better spent helping him with his creative efforts, as he claimed to be the “Jordan and Steph Curry of music, meaning I’m the best of 2 generations”
The raving, foaming-at-the-mouth, ideologically-driven Conservatives, having all but ruined the state education system, virtually rendered social housing impotent, all but made access to lawyers impossible for everyone except the rich, gone back on their environmental commitments, gerrymandering the electoral constituencies (in their favour), ridden roughshod over the House of Lords, sent sick and dying people to work for large, rich corporations for free, are now about to eviscerate the National Health Service.
Stewart Lee has a very insightful column in the Guardian.
He gets in the Noam Chomsky one, "Defund, make sure things don’t work, people get angry, you hand it over to private capital.
Why should money be used to do good for people? Money should only ever be used to make more money!
If the sick needed treating, the Market would see to their treatment. This is just the Market's way of ridding decent, honest, hard-working people of the dead wood who are just holding us back!
Is that clear?
Give him a blast. Make that hair fly.
Wait, what?
Alex Jones: Banning order for fan who tweeted he loved presenter
A fan who bombarded the BBC's Alex Jones with tweets declaring he was in love with her has been banned from any contact with the Welsh TV presenter.
Shane Goldsmith sent the 38-year-old One Show star a string of messages for 17 months and waited outside the BBC's headquarters to tell her he loved her.
A judge imposed a restraining order which also bars him from the BBC's New Broadcasting House in central London.
Mr Goldsmith, 44, was formally cleared of a single charge of harassment.
'Armani Communist' divides China
When Liu Bo attended a regional communist party event as the official ambassador of local students it wasn't his youthful demeanour which made the biggest impression.
Nor was it the remarks which the 14-year-old made to the Shenzhen People's Political Consultative Conference, calling for the greater use of non-exam based assessments in the Chinese education system.
What made people stare, and what rapidly become a major topic of conversation as photos of Liu spread across Chinese social media this week, was what he was wearing.Around his neck was a red scarf of the type worn by Chairman Mao's Red Guards during the Cultural Revolution and now standard issue wear for the Communist Party Youth League. But Liu had paired that with what was taken to be an Armani suit, because of the lapel badge he was wearing with the distinctive logo of the Italian luxury brand.
In the eyes of many Chinese observers this was not so much a wardrobe malfunction as a clash of ideologies in a single outfit. Some on China's micro blogging platform Weibo dubbed Liu the "Armani Youngster" and attacked his choice of clothing.
PM left red nosed by censorship protest
When Malaysian police warned activist and graphic designer Fahmi Reza that his Twitter account was under surveillance after he posted an image of the prime minister, Najib Razak, as a clown, they probably hoped such behaviour would stop.
But then members of an art collective, Grupa posted even more clownish images of the premier to express their solidarity with him and to champion the ideal of free speech.
The pictures have spread across social media with the hashtag #KitaSemuaPenghasut which translates as "we are all seditious".
Fahmi's mockery of the prime minister was part of a wider reaction to news last week, when the country's attorney-general cleared Mr Najib of any corruption relating to a long-running financial scandal.
too-lazy-to-sub dept.
James Reinders: Parallelism Has Crossed a Threshold
Is the parallel everything era here? What happens when you can assume parallel cores? In the second half of our in-depth interview, Intel’s James Reinders discusses the fading out of single-core machines and the ramifications of the democratization of parallel computing, remarking “we don’t need to worry about single-core processors anymore and that’s pretty significant in the world of programming for this next decade.” Other topics covered include the intentions behind OpenHPC and trends to watch in 2016.
First half: A Conversation with James Reinders
Sensors, not CPUs, are the tech that swings the smartphone market
Flash back a quarter of a century: I’m sourcing components for a consumer virtual reality system. An accelerometer is an absolute necessity in a head-mounted display, because it senses the motion of the head. Accelerometers exist in silicon, but priced at US$25 apiece, their only customer is the automotive industry - sensors used to trigger deployment of the airbags in a crash.
In the end, I invented my own sensor, because silicon accelerometers cost too much.
A few hundred million smartphones later, accelerometers and gyroscopes have become cheap as chips. Literally. From twenty-five dollars to less than twenty-five cents, the conjunction of Moore’s Law and Steve Jobs made these sensors cheap and abundant.
With many smartphones using high-quality accelerometer/gyroscope sensors, the groundwork had been laid for Google’s Cardboard - really no more than a cheap set of plastic lenses set at the right distance from a smartphone screen. Everything else about the Cardboard experience happened inside the smartphone - because the smartphone suddenly had the right suite of sensors to generate a head-tracking display.
Theoretically, Google’s Cardboard should give you the same smooth virtual reality experience as Samsung’s Gear VR. But it’s like chalk and cheese: Cardboard does the job, but it always feels as though you’re fighting the hardware, where Gear VR feels as comfortable as an old shoe.
The reason for that lies with the sensors built into Gear VR. Oculus CTO John Carmack worked with Samsung to specify an accelerometer/gyroscope sensor suite that could feed Samsung's flagship Galaxy S6 smartmobe with a thousand updates a second. The average sensors, on a typical smartphone - even the very powerful Galaxy S6 - won’t come anywhere near that.
Head tracking can only be as good as the sensors used to track the head. The proof of this is the difference between Galaxy S6 in Cardboard, and Galaxy S6 in Gear VR - try both and see for yourself.
This is one bleeding edge in the smartphone sensor arms race. Within the next eighteen months, every high-end smartphone will specify incredibly sensitive and fast accelerometers and gyroscopes. Smartphones work well both in the palm of your hand and when mounted over your eyes. Every major manufacturer will have their own Gear VR-like plastic case for wearing their latest top-of-the-line handset. Except at the very high end - the province of serious gamers and information designers - smartphones and VR will become entirely interchangeable.
[...] Back during the Cold War, the Soviets were caught out shining laser beams onto the windows at the White House, reading voices out of the reflections. The White House responded by pointing speakers at their windows, playing music just loud enough to drown out any other signal. We may need a new app for our smartphones, one that keeps just enough music piping out its speaker to confound anyone using our newly sensitive accelerometers against us.
This topic has, perhaps, been discussed ad infinitum, ad nauseam. But I won't let that stop me. :)
I do understand that online forums aren't going to bastions of quality argument and rhetoric, especially given the temptation to go all GIFT when folks can be anonymous (or even pseudonymous). I've been guilty of that myself, from time to time.
One of the positives I've seen with Soylent (as compared with other places) is that, as a group, we tend to reward (via positive moderation) those who provide cogent, clear arguments and back them up with data to support those arguments.
AFAICT, there are a variety of motivations for submitting stories and posting comments:
An interest in discussing the topic;
An opportunity to promote their personal political bent/beliefs;
An opportunity to say things one wouldn't say in a meat-space conversation;
An opportunity to share one's sense of humor (such as it might be);
An excuse to troll (in the classical sense);
and many other motivations as well.
My focus is on the first two motivations I list. Making rational, fact-based arguments to support (or elucidate) a point of view often makes for interesting discussions which can illuminate a topic and create a positive environment for exploring a particular subject.
What's more, I suspect that expanding the pool of those who express arguments clearly and cogently could reduce the level of personal attacks and nastiness, at least among those who actually wish to engage with others.
One of the issues I've noticed with those engaged in this sort of discussion are arguments which rely upon faulty data, irrational arguments, unclear prose and poor rhetorical style.
Often, moderation causes the best arguments to rise to the top, which can elevate the discussion considerably. However, that can minimize the voices of those with useful and/or interesting things to say simply because they lack the skills to express those things effectively.
I wonder if a section on the site which contains articles, book references, discussions and other resources can help those with poor logic, writing and/or rhetorical skills to up their game?
It seems to me that while we likely wouldn't create any new Pulitzer Prize winners, we may be able to encourage those with a sincere desire to engage others in more cogent, coherent fashion.
I'm all for freewheeling discussion and am certainly not above poking fun at just about anything. At the same time, I believe it might enhance the level of discourse here by helping people to be better writers.
Am I just pissing in the wind here, or does any of this make sense to the rest of you Soylentils?