Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into use-debug
Browse files Browse the repository at this point in the history
# Conflicts:
#	autoflagging/autoflagging.meta.js
#	autoflagging/autoflagging.user.js
#	sds/sds.user.js
  • Loading branch information
ferrybig committed May 19, 2017
2 parents 7e534bc + cf4dcd3 commit 8a81b30
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 51 deletions.
3 changes: 1 addition & 2 deletions autoflagging/autoflagging.meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
// @contributor angussidney
// @contributor ArtOfCode
// @contributor Cerbrus
// @version 0.14.10
// @version 0.14.11
// @updateURL https://raw.githubusercontent.com/Charcoal-SE/Userscripts/master/autoflagging/autoflagging.meta.js
// @downloadURL https://raw.githubusercontent.com/Charcoal-SE/Userscripts/master/autoflagging/autoflagging.user.js
// @supportURL https://github.com/Charcoal-SE/Userscripts/issues
// @match *://chat.stackexchange.com/rooms/11540/charcoal-hq*
// @match *://chat.stackoverflow.com/rooms/41570/so-close-vote-reviewers*
// @match *://chat.meta.stackexchange.com/rooms/89/tavern-on-the-meta*
// @match *://chat.stackexchange.com/rooms/56223/the-spam-blot*
// @match *://chat.stackoverflow.com/rooms/111347/sobotics*
// @require https://cdn.rawgit.com/joewalnes/reconnecting-websocket/f8055b77ba75e5d564ffb50d20a483bdd7edccdf/reconnecting-websocket.min.js
// @require https://wzrd.in/standalone/debug@%5E2.6.6
// @grant none
Expand Down
3 changes: 1 addition & 2 deletions autoflagging/autoflagging.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
// @contributor angussidney
// @contributor ArtOfCode
// @contributor Cerbrus
// @version 0.14.10
// @version 0.14.11
// @updateURL https://raw.githubusercontent.com/Charcoal-SE/Userscripts/master/autoflagging/autoflagging.meta.js
// @downloadURL https://raw.githubusercontent.com/Charcoal-SE/Userscripts/master/autoflagging/autoflagging.user.js
// @supportURL https://github.com/Charcoal-SE/Userscripts/issues
// @match *://chat.stackexchange.com/rooms/11540/charcoal-hq*
// @match *://chat.stackoverflow.com/rooms/41570/so-close-vote-reviewers*
// @match *://chat.meta.stackexchange.com/rooms/89/tavern-on-the-meta*
// @match *://chat.stackexchange.com/rooms/56223/the-spam-blot*
// @match *://chat.stackoverflow.com/rooms/111347/sobotics*
// @require https://cdn.rawgit.com/joewalnes/reconnecting-websocket/f8055b77ba75e5d564ffb50d20a483bdd7edccdf/reconnecting-websocket.min.js
// @require https://wzrd.in/standalone/debug@%5E2.6.6
// @grant none
Expand Down
14 changes: 11 additions & 3 deletions charcoal-autocomments/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,24 @@ callback(
name: "[Q] Vandalism",
description: "Please do not vandalize your posts. Once you've posted a question, you have licensed the content to the $SITENAME$ community at large (under the CC-by-SA license). If you would like to disassociate this post from your account, see [What is the proper route for a disassociation request](https://meta.stackoverflow.com/questions/323395)?"
},
{
name: "[Q] Rude",
description: "**Warning - please do not use obscenities in your posts.** Note that other users may have flagged your post as **rude or abusive** leading to possible rep loss or suspension. Please [Be Nice](https://$SITEURL$/help/be-nice): *Avoid vulgar terms and anything sexually suggestive*"
},
{
name: "[A] No Disclosure",
description: "Please note if you want to promote your own product/blog you **must disclose your affiliation in the answer**, otherwise your answer may be flagged as spam. If you are not affiliated with the site, I recommend you mention it to prevent this. Please read [How to not be a spammer](https://$SITEURL$/help/promotion)"
description: "Please note if you want to promote your own product/blog you **must disclose your affiliation in the answer**, otherwise your answer may be flagged as spam. If you are not affiliated with the site, I recommend you say so to prevent this. Please read [How to not be a spammer](https://$SITEURL$/help/promotion)"
},
{
name: "[A] Rude",
description: "**Warning - please do not use obscenities in your posts.** Note that other users may have flagged your post as **rude or abusive** leading to possible rep loss or suspension. Please Be Nice: *Avoid vulgar terms and anything sexually suggestive*"
description: "**Warning - please do not use obscenities in your posts.** Note that other users may have flagged your post as **rude or abusive** leading to possible rep loss or suspension. Please [Be Nice](https://$SITEURL$/help/be-nice): *Avoid vulgar terms and anything sexually suggestive*"
},
{
name: "[A] Nothing but a URL, and no disclosure",
description: "While this may theoretically answer the question, [it would be preferable](https://meta.stackexchange.com/questions/8231) to include the essential parts of the answer here, and provide the link for reference. Also please note that if you want to promote your own product/blog you **must disclose your affiliation in the answer**, otherwise your answer may be flagged as spam. If you are not affiliated with the site, I recommend you say so to prevent this. Please read [How to not be a spammer](https://$SITEURL$/help/promotion)"
},
{
name: "[A] Nothing but a URL (and isn't spam)",
name: "[A] Nothing but a URL and has disclosure",
description: "While this may theoretically answer the question, [it would be preferable](https://meta.stackexchange.com/questions/8231) to include the essential parts of the answer here, and provide the link for reference."
},
{
Expand Down
4 changes: 4 additions & 0 deletions fire/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ To open the reported post on it's site:

|1.0 ||
| --- |---
|1.0.12 |Reducing the max size of a rendered image.
|1.0.11 |Bugfix: `decorateExistingMessages` timing.
|1.0.10 |Bugfix: got incorrect post ID for reports where the url contains a number.
|1.0.9 |Add SoBotics room.
|1.0.8 |Log toastr messages to the console.
|1.0.7 |Show "loading" error notification if FIRE fails to load a MS report.
|1.0.6 |Fixing incorrect escaping of HTML: Whitelisted some tags.
Expand Down
1 change: 1 addition & 0 deletions fire/TODO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# TODO:
* ___Bug: FIRE doesn't open the report after getting a MS write token.___
* ___Bug: If you’re typing a message, then [k] the spam, hitting [return] sends the message instead of the feedback.___
* Investigate if a Google translate button is a option?
* Add `.fire-done` class to FIRE buttons for which the reported post was deleted / flagged, and feedback was sent. ♦
* Re-structure document
* Wrap similar functions in objects, like `popups.openSettings()`
Expand Down
2 changes: 1 addition & 1 deletion fire/fire.meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// @description FIRE adds a button to SmokeDetector reports that allows you to provide feedback & flag, all from chat.
// @author Cerbrus
// @attribution Michiel Dommerholt (https://github.com/Cerbrus)
// @version 1.0.9
// @version 1.0.12
// @updateURL https://raw.githubusercontent.com/Charcoal-SE/Userscripts/master/fire/fire.meta.js
// @downloadURL https://raw.githubusercontent.com/Charcoal-SE/Userscripts/master/fire/fire.user.js
// @supportURL https://github.com/Charcoal-SE/Userscripts/issues
Expand Down
9 changes: 7 additions & 2 deletions fire/fire.scss
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,12 @@ img.fire-emoji-large {
background-color: #f4eaea;
}

img[src^='http://placehold.it'] {
cursor: pointer;
img {
max-width: 100%;

&[src^='http://placehold.it'] {
cursor: pointer;
}
}

a {
Expand All @@ -203,6 +207,7 @@ img.fire-emoji-large {
padding: 1px 5px;
border-radius: 3px;
box-shadow: 0 0 10px -2px $shadow-color;
display: inline-block;
}
}

Expand Down
24 changes: 13 additions & 11 deletions fire/fire.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// @description FIRE adds a button to SmokeDetector reports that allows you to provide feedback & flag, all from chat.
// @author Cerbrus
// @attribution Michiel Dommerholt (https://github.com/Cerbrus)
// @version 1.0.9
// @version 1.0.12
// @updateURL https://raw.githubusercontent.com/Charcoal-SE/Userscripts/master/fire/fire.meta.js
// @downloadURL https://raw.githubusercontent.com/Charcoal-SE/Userscripts/master/fire/fire.user.js
// @supportURL https://github.com/Charcoal-SE/Userscripts/issues
Expand Down Expand Up @@ -278,9 +278,9 @@
({user_name}) => user_name === fire.chatUser.name
);

const match = data.link.match(/\d+/);
if (match && match[0])
[data.post_id] = match;
const match = data.link.match(/.*\/(\d+)/);
if (match && match[1])
[, data.post_id] = match;

fire.reportCache[data.link] = data; // Store the data

Expand Down Expand Up @@ -1977,7 +1977,7 @@
// Load report data on fire button hover
$('body').on('mouseenter', '.fire-button', loadDataForReport);

fire.log('Registered loadDataForReport');
fire.log('Registered `loadDataForReport` and `decorateExistingMessages`');
}

/**
Expand All @@ -1989,11 +1989,13 @@
* @param {number} timeout The time to wait before trying to decorate the messages.
*/
function decorateExistingMessages(timeout) {
setTimeout(() => {
const chat = $('#chat');
chat.on('DOMSubtreeModified', () => {
const chat = $('#chat');

chat.one('DOMSubtreeModified', () => {
// We need another timeout here, because the first modification occurs before
// the new (old) chat messages are loaded.
setTimeout(() => {
if (chat.html().length !== 0) { // Chat messages have loaded
chat.off('DOMSubtreeModified');
$(fire.SDMessageSelector).each((i, element) => decorateMessage(element));

fire.log('Decorated existing messages.');
Expand All @@ -2003,8 +2005,8 @@
updateReportCache();
*/
}
});
}, timeout);
}, timeout);
});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion sds/sds.meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// @namespace https://github.com/Charcoal-SE/
// @description Show the status of all SmokeDetector instances
// @author J F
// @version 0.0.3
// @version 0.0.4
// @updateURL https://raw.githubusercontent.com/Charcoal-SE/Userscripts/master/sds/sds.meta.js
// @downloadURL https://raw.githubusercontent.com/Charcoal-SE/Userscripts/master/sds/sds.user.js
// @supportURL https://github.com/Charcoal-SE/Userscripts/issues
Expand Down
2 changes: 1 addition & 1 deletion sds/sds.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
float: left;
}

&.smokey-dead {
.smokey-dead {
display: none;
}
.ping {
Expand Down
39 changes: 11 additions & 28 deletions sds/sds.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// @namespace https://github.com/Charcoal-SE/
// @description Show the status of all SmokeDetector instances
// @author J F
// @version 0.0.3
// @version 0.0.4
// @updateURL https://raw.githubusercontent.com/Charcoal-SE/Userscripts/master/sds/sds.meta.js
// @downloadURL https://raw.githubusercontent.com/Charcoal-SE/Userscripts/master/sds/sds.user.js
// @supportURL https://github.com/Charcoal-SE/Userscripts/issues
Expand All @@ -24,29 +24,28 @@
// Inject CSS
const css = window.document.createElement("link");
css.rel = "stylesheet";
css.href = "https://charcoal-se.org/userscripts/sds/sds.css";
css.href = "//charcoal-se.org/userscripts/sds/sds.css";
document.head.appendChild(css);

const apiKey = "05f3eb1fb4edd821e32299f5b2e65f78bc53ed4fa0415b034d0e84b4e273329e";

$.get("https://metasmoke.erwaysoftware.com/api/smoke_detectors?key=" + apiKey, data => {
data.items.forEach(smokey => {
addData(smokey, getDot(smokey));
});
});

const ActionCable = window.actioncable;
const cable = ActionCable.createConsumer("wss://metasmoke.erwaysoftware.com/cable");
const $pings = $("<span />").addClass("pings-container");
$("#roomname").after($pings);
cable.subscriptions.create("PingsChannel", {
received({smokey}) {
debug.ping(smokey);
const $dot = getDot(smokey);
let $dot = $pings.children(".smokey-" + smokey.id);
if ($dot.length === 0) {
$dot = $("<span />").addClass("smokey smokey-" + smokey.id);
$dot.append($("<span />").addClass("ping"));
$dot.appendTo($pings);
}
$dot.toggleClass("smokey-standby", smokey.is_standby);
const $ping = $dot.find(".ping");
$ping.removeClass("ping-pulse");
requestAnimationFrame(() => $ping.addClass("ping-pulse"));
addData(smokey, $dot);
$dot.attr("data-location", smokey.location);
$dot.attr("data-last-ping", smokey.last_ping);
updatePing($dot);
}
});
Expand All @@ -55,22 +54,6 @@
updatePing($(this));
});
}, 1000);

function getDot(smokey) {
let $dot = $pings.children(".smokey-" + smokey.id);
if ($dot.length === 0) {
$dot = $("<span />").addClass("smokey smokey-" + smokey.id);
$dot.append($("<span />").addClass("ping"));
$dot.appendTo($pings);
}
return $dot;
}
function addData(smokey, $dot) {
$dot.attr("data-location", smokey.location);
$dot.attr("data-last-ping", smokey.last_ping);
$dot.toggleClass("smokey-standby", smokey.is_standby);
}

const colorClasses = "green/yellow/red/dead".split("/").map(color => `smokey-${color}`);
function updatePing($dot) {
let diff = Number(new Date()) - new Date($dot.attr("data-last-ping"));
Expand Down

0 comments on commit 8a81b30

Please sign in to comment.