So you have a javascript function.
function func () {}
It accepts a value.
function func (param) {}
<button class="cybr-btn"> | |
Cyber<span aria-hidden>_</span> | |
<span aria-hidden class="cybr-btn__glitch">Cyber_</span> | |
<span aria-hidden class="cybr-btn__tag">R25</span> | |
</button> | |
<button class="cybr-btn"> | |
Buttons<span aria-hidden>_</span> | |
<span aria-hidden class="cybr-btn__glitch">Buttons_</span> | |
<span aria-hidden class="cybr-btn__tag">R25</span> | |
</button> |
"use strict"; | |
const words = require("./words.json"); | |
const faces = [":grin:", ":smile:", ":grinning:", ":slight_smile:", ":neutral_face:", ":slight_frown:", ":worried:", ":persevere:", ":tired_face:", ":dizzy_face:", ":skull:"]; | |
module.exports = class Hangman | |
{ | |
constructor() | |
{ | |
this.guesses = new Set(); |
function messageIdToRoomId (mid) { | |
return fetch(`http://crossorigin.me/http://chat.stackoverflow.com/messages/${mid}/history`).then(function (res) { | |
return res.text(); | |
}).then(function (html) { | |
return new DOMParser().parseFromString(html, 'text/html'); | |
}).then(function (doc) { | |
return doc.querySelector(`a[name="${mid}"]`).getAttribute('href').match(/\d+/)[0]; | |
}); | |
} | |
// ==UserScript== | |
// @name SO Dark Chat + JS | |
// @author Robert Lemon | |
// @version 0.1.1 | |
// @namespace | |
// @description adds colors to users messages and a whole bunch of other crap. | |
// @include http://chat.stackoverflow.com/rooms/* | |
// @include http://chat.stackexchange.com/rooms/* | |
// ==/UserScript== | |
(function () { |
body { | |
background-color : #000 !important; | |
background-image : url("http://raw.github.com/oliversalzburg/se-chat-dark-theme/master/img/skewed_print.png") !important; | |
color : #ddd !important; | |
} | |
.messages { | |
background-color : #222 !important; | |
border : none !important; | |
color : #ddd !important; |
So you have a javascript function.
function func () {}
It accepts a value.
function func (param) {}
$(function () { | |
"use strict"; | |
// for better performance - to avoid searching in DOM | |
var content = $('#content'); | |
var input = $('#input'); | |
var status = $('#status'); | |
// my color assigned by the server | |
var myColor = false; |
This indirection was intended to make the language seem more familiar to classically trained programmers, but failed to do that, as we can see from the very low opinion Java programmers have of JavaScript. JavaScript's constructor pattern did not appeal to the classical crowd. It also obscured JavaScript's true prototypal nature. As a result, there are very few programmers who know how to use the language effectively.The indirection Mr. Crockford refers to here is the Pseudo-Classical Pattern, also known as the Constructor Pattern. This is a way of simulating classical inheritance in JavaScript - a prototypal language.~ Douglas Crockford, "Prototypal Inheritance"
If it wasn't obvious from both the title of this post, and from the frankly negative quote above, this is not my favorite object-oriented pattern in JavaScript. I'
var style = document.createElement('style'); style.textContent = '.vote-count-container.stars span.img, span.vote-count-container.sidebar-vote.owner-star.stars span.img, span.vote-count-container.sidebar-vote.user-star.stars span.img { background-image: url("http://0.gravatar.com/avatar/6d8ebb117e8d83d74ea95fbdd0f87e13?s=16&d=identicon&r=PG"); background-position: 0px 0px; height: 16px; width: 16px;} .user-star span.img { outline: 1px solid #ff0; }'; document.head.appendChild(style); |