Skip to content

Instantly share code, notes, and snippets.

@bre7
Created July 31, 2016 03:29
Show Gist options
  • Save bre7/1b015b4b58dd49372a2347f7a19d2031 to your computer and use it in GitHub Desktop.
Save bre7/1b015b4b58dd49372a2347f7a19d2031 to your computer and use it in GitHub Desktop.
Warframe's Acolytes appearances Slack notifier
<!DOCTYPE html>
<html>
<head>
<!-- Thanks to Deathsnacks for his solution. -->
<!-- This is just a copy-paste from the XB1 panel, but changed the platform to PC and added the webhook notifications. -->
<!-- https://deathsnacks.com/wf/ -->
<!--
INSTRUCTIONS:
Search for FIXME and change the webhook to a valid Slack one.
-->
<meta charset="utf-8">
<title>Warframe Stuff</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/css/bootstrap.min.css">
<style>
.card-columns {
@include media-breakpoint-only(lg) {
column-count: 4;
}
@include media-breakpoint-only(xl) {
column-count: 5;
}
@include media-breakpoint-only(md) {
column-count: 5;
}
}
#confirmation > span {
margin-right: 2em;
}
.segmented-control input[type="radio"] {
display: none;
}
.segmented-control .list-group-item {
display: inline-block;
}
.segmented-control .list-group-item {
margin-bottom: 0;
margin-left: -4px;
margin-right: 0;
}
.segmented-control .list-group-item:first-child {
border-top-right-radius: 0;
border-bottom-left-radius: 4px;
}
.segmented-control .list-group-item:last-child {
border-top-right-radius: 4px;
border-bottom-left-radius: 0;
}
.list-group-item.active.affirmative {
background-color: #21bc18;
border-color: #21bc18;
}
.list-group-item.active.negative {
background-color: #bc1818;
border-color: #bc1818;
}
</style>
</head>
<body style="background-color: #f0f0f0;">
<div class="container" id="containerdiv" style="text-align:center;margin:4em auto 0 auto;">
<div>
<h2>Persistent Enemies</h2>
<div class="card-deck-wrapper">
<div class="card-deck persistentenemies-container text-left">
No enemies have been discovered.
</div>
</div>
</div>
<hr>
<div id="confirmation">
<span style="font-weight: bold;">Notify on disappearance:</span>
<div class="list-group segmented-control" style="display: inline-block;">
<a href="#" class="list-group-item affirmative">
Yes
<input type="radio" name="confirmed" value="1"/>
</a>
<a href="#" class="list-group-item active negative">
No
<input type="radio" checked="" name="confirmed" value="0"/>
</a>
</div>
</div>
<hr>
</div>
</body>
<!--<div id="footer" style="width: 100%; height: 60px;">
<div class="container">
<p class="text-muted"><a href="/privacy.html">Privacy Policy</a></p>
</div>
</div>-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.0/jquery.cookie.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.4.0/moment.min.js"></script>
<script src="https://crossorigin.me/https://deathsnacks.com/includes/common.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0-alpha.4/handlebars.min.js"></script>
<!-- Start templates -->
<script id="alert-template" type="text/x-handlebars-template">
{{#alerts}}
<li class="list-group-item">
<p class="alert-badge"><span class="badge time alert2" data-starttime="{{starttime}}" data-endtime="{{endtime}}"></span>
</p>
{{{badges}}}<span class="alert-node">{{node}} ({{region}})</span> | <span class="alert-type">{{type}}</span> (<span class="alert-fc">{{faction}}</span>) | {{description}} | Level: {{minlevel}}-{{maxlevel}}
</li>
{{/alerts}}
</script>
<script id="sale-template" type="text/x-handlebars-template">
{{#sales}}
<li class="list-group-item flashsale"><span class="badge time" data-starttime="{{starttime}}" data-endtime="{{endtime}}"></span><span class="sale-name">{{name}}</span> | <span class="sale-discount">{{discount}}% off</span> | <span class="sale-amount">{{{amount}}}</span>
</li>
{{/sales}}
</script>
<script id="peaceful_ds-template" type="text/x-handlebars-template">
<div class="armistice_node">
<a class="toggler list-group-item" id="{{id}}">
<span class="pull-left"><strong>{{node}} ({{region}})</strong><i><span class="small-footer"> {{type}} </span>
</i>
</span>
<span class="hidden-xs"> Tax: {{pub_cred}}%/{{pub_resource}}%</span> </span>
<span class="pull-right"><span class="header-time hidden-xs" data-time="{{time}}"></span> <strong>{{status}} </strong>
<span class="caret"></span></span>
<br style="clear: both;">
</a>
<div class="blpanel collapse">
<div class="well">
<h5>{{is_alliance}}</h5>
<p><a target="_blank" href="/wf/clan_bl_history.html#{{def_id}}">{{name}}</a>
</p>
<p>Deployed by: {{deployed}}</p>
<h5>Message</h5>
<p>{{message}}</p>
<p>Authored by: {{author}}</p>
<h5>Tributes</h5>
<ul class="nobullets">
<li>Public Credits/Resource Tribute: {{pub_cred}}%/{{pub_resource}}%</li>
<li>Member Credits/Resource Tribute: {{member_cred}}%/{{member_resource}}%</li>
</ul>
<p>Tribute changed by: {{def_taxchange}} ({{def_taxchange_clan}})
<p>
<h5>Rail Health</h5>
<div class="progress">
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="{{health}}" aria-valuemin="0" aria-valuemax="100" style="width: {{health}}%;">{{health}}%</div>
</div>
<h5>Tribute Change Allowed</h5>
<p class="taxtime" data-time="{{taxtime}}"></p>
{{{timer}}} {{{history}}}
</div>
</div>
</div>
</script>
<script id="deploying_ds-template" type="text/x-handlebars-template">
<div class="deploying_node">
<a class="toggler list-group-item list-group-item-warning" id="{{id}}">
<span class="pull-left"><strong>{{node}} ({{region}})</strong> <i><span class="small-footer">{{type}} </span>
</i>
</span>
<span class="hidden-xs"> Tax: {{def_pub_cred}}%/{{def_pub_resource}}%</span> </span>
<span class="pull-right"><span class="header-time hidden-xs" data-time="{{time}}"></span> <strong><font color="#E34234">ATTACK DEPLOYING </font></strong>
<span class="caret"></span></span>
<br style="clear: both;">
</a>
<div class="blpanel collapse">
<div class="well">
<div class="col-md-6">
<h5>Defending {{def_is_alliance}}</h5>
<p><a target="_blank" href="/wf/clan_bl_history.html#{{def_id}}">{{def_name}}</a>
</p>
<p>Deployed by: {{def_deployer}}</p>
<h5>Message</h5>
<p>{{def_message}}</p>
<p>Authored by: {{def_author}}</p>
<h5>Tributes</h5>
<ul class="nobullets">
<li>Credits/Resource Tribute: {{def_pub_cred}}%/{{def_pub_resource}}%</li>
<li>Member Credits/Resources Tribute: {{def_member_cred}}%/{{def_member_resource}}%</li>
</ul>
<p>Tribute changed by: {{def_taxchange}} ({{def_taxchange_clan}})
<p>
<h5>Rail Health</h5>
<div class="progress">
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="{{def_health}}" aria-valuemin="0" aria-valuemax="100" style="width: {{def_health}}%;">{{def_health}}%</div>
</div>
<h5>Battle Pay</h5>
<p>{{def_pay}}</p>
<h5>Tribute Change Allowed</h5>
<p class="taxtime" data-time="{{def_taxtime}}"></p>
<hr class="hidden-lg hidden-md">
</div>
<div class="col-md-6">
<h5>Attacking {{atk_is_alliance}}</h5>
<p><a target="_blank" href="/wf/clan_bl_history.html#{{atk_id}}">{{atk_name}}</a>
</p>
<p>Deployed by: {{atk_deployer}}</p>
<h5>Message</h5>
<p>{{atk_message}}</p>
<p>Authored by: {{atk_author}}</p>
<h5>Tributes</h5>
<ul class="nobullets">
<li>Credits/Resource Tribute: {{atk_pub_cred}}%/{{atk_pub_resource}}%</li>
<li>Member Credits/Resources Tribute: {{atk_member_cred}}%/{{atk_member_resource}}%</li>
</ul>
<p>Tribute changed by: {{atk_taxchange}} ({{atk_taxchange_clan}})
<p>
<h5>Rail Health</h5>
<div class="progress">
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="{{atk_health}}" aria-valuemin="0" aria-valuemax="100" style="width: {{atk_health}}%;">{{atk_health}}%</div>
</div>
<h5>Battle Pay</h5>
<p>{{atk_pay}}</p>
<h5>Tribute Change Allowed</h5>
<p class="taxtime" data-time="{{atk_taxtime}}"></p>
<br>
<p><span class="bldeploytime" data-time="{{time}}"></span>
</p>
</div>
{{{history}}}
</div>
</div>
</div>
</script>
<script id="conflict_ds-template" type="text/x-handlebars-template">
<div class="conflict_node">
<a class="toggler list-group-item list-group-item-danger" id="{{id}}">
<span class="pull-left"><strong>{{node}} ({{region}})</strong> <i><span class="small-footer">{{type}} </span>
</i>
</span>
<span> <span class="hidden-xs">{{def_name}} (</span><b>{{def_health}}</b>%<span class="hidden-xs">) vs {{atk_name}}</span> </span>
<span class="pull-right"><span class="header-time hidden-xs" data-time="{{time}}"></span> <strong><font color="red">CONFLICT</font></strong>
<span class="caret"></span></span>
<br style="clear: both;">
</a>
<div class="blpanel collapse">
<div class="well">
<div class="row">
<div class="col-md-6">
<h5>Defending {{def_is_alliance}}</h5>
<p><a target="_blank" href="/wf/clan_bl_history.html#{{def_id}}">{{def_name}}</a>
</p>
<p>Deployed by: {{def_deployer}}</p>
<h5>Message</h5>
<p>{{def_message}}</p>
<p>Authored by: {{def_author}}</p>
<h5>Tributes</h5>
<ul class="nobullets">
<li>Credits/Resource Tribute: {{def_pub_cred}}%/{{def_pub_resource}}%</li>
<li>Member Credits/Resources Tribute: {{def_member_cred}}%/{{def_member_resource}}%</li>
</ul>
<p>Tribute changed by: {{def_taxchange}} ({{def_taxchange_clan}})
<p>
<h5>Rail Health</h5>
<div class="progress">
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="{{def_health}}" aria-valuemin="0" aria-valuemax="100" style="width: {{def_health}}%;">{{def_health}}%</div>
</div>
<p>{{def_health_count}}/{{def_max_health}}</p>
<h5>Battle Pay</h5>
<p>{{def_pay}}</p>
<p>Battle Pay set by: {{def_bpchange}} ({{def_bpchange_clan}})
<p>
<h5>Tribute Change Allowed</h5>
<p class="taxtime" data-time="{{def_taxtime}}"></p>
<hr class="hidden-lg hidden-md">
</div>
<div class="col-md-6">
<h5>Attacking {{atk_is_alliance}}</h5>
<p><a target="_blank" href="/wf/clan_bl_history.html#{{atk_id}}">{{atk_name}}</a>
</p>
<p>Deployed by: {{atk_deployer}}</p>
<h5>Message</h5>
<p>{{atk_message}}</p>
<p>Authored by: {{atk_author}}</p>
<h5>Tributes</h5>
<ul class="nobullets">
<li>Credits/Resource Tribute: {{atk_pub_cred}}%/{{atk_pub_resource}}%</li>
<li>Member Credits/Resources Tribute: {{atk_member_cred}}%/{{atk_member_resource}}%</li>
</ul>
<p>Tribute changed by: {{atk_taxchange}} ({{atk_taxchange_clan}})
<p>
<h5>Rail Health</h5>
<div class="progress">
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="{{atk_health}}" aria-valuemin="0" aria-valuemax="100" style="width: {{atk_health}}%;">Attacking</div>
</div>
<p>{{atk_health_count}}/{{atk_max_health}}</p>
<h5>Battle Pay</h5>
<p>{{atk_pay}}</p>
<p>Battle Pay set by: {{atk_bpchange}} ({{atk_bpchange_clan}})
<p>
<h5>Tribute Change Allowed</h5>
<p class="taxtime" data-time="{{atk_taxtime}}"></p>
</div>
</div>
<div class="row"><span class="bltime" data-endtime="{{time}}"></span>
</div>
{{{history}}}
</div>
</div>
</div>
</script>
<script id="voidtrader-template" type="text/x-handlebars-template">
<div class="void-trader">
<a class="toggler-vt list-group-item">
<span style="text-align:left;"><span><strong>{{name}}</strong> - {{node}}</span>
<span class="pull-right"><span class="vttime" data-starttime="{{activation}}" data-endtime="{{expiry}}"></span> <span class="caret"></span></span>
<br style="clear: both;">
</a>
<div class="vtpanel collapse">
<div class="well">
<!--<p>Next Rotation: {{rotation}} (Period (days): {{rotation_period}})--></p>
<!--<p>Node List: {{node_list}}</p>-->
<p>Active Manifest</p>
<table class="table table-bordered table-condensed table-hover table-striped">
<thead>
<tr>
<th>Item</th>
<th>Ducats</th>
<th>Credits</th>
</tr>
</thead>
<tbody>
{{#each active_manifest}}
<tr>
<td>{{ItemType}}</td>
<td>{{PrimePrice}}</td>
<td>{{RegularPrice}}</td>
</tr>
{{/each}}
</tbody>
</table>
<!--<p>Full Manifest List</p>
{{#items}}
<table class="table table-bordered table-condensed table-hover table-striped">
<thead><tr><th>Item</th><th>Ducats</th><th>Credits</th></tr></thead>
<tbody>
{{#each this}}
<tr><td>{{ItemType}}</td><td>{{PrimePrice}}</td><td>{{RegularPrice}}</td></tr>
{{/each}}
</tbody>
</table>
{{/items}}-->
</div>
</div>
</div>
</script>
<script id="darvo-template" type="text/x-handlebars-template">
{{#deals}}
<li class="list-group-item darvodaily"><span class="badge time" data-starttime="{{starttime}}" data-endtime="{{endtime}}"></span><span class="deal-name bold">{{name}}</span> | <span class="deal-discount">{{discount}}% off</span> | <span class="deal-amount bold"><img src="img/plat.png" style="height:16px" title="platinum" alt="platinum"> {{{amount}}}</span> | <span class="deal-inventory"><strong>{{remaining}}</strong>/{{total}} left</span>
</li>
{{/deals}}
</script>
<script id="library-template" type="text/x-handlebars-template">
<li class="list-group-item librarytarget">
<span class="badge target-time" data-starttime="{{time}}"></span>
<span class="target-name bold">{{name}}</span> | Scans required: <strong>{{scans}}</strong>
<div class="progress" style="background-color: #555555">
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="{{progress}}" aria-valuemin="0" aria-valuemax="100" style="width: {{progress}}%;">{{progress}}</div>
</div>
</li>
</script>
<script id="persist-template" type="text/x-handlebars-template">
{{#enemies}}
{{#if discovered}}
<div class="card card-success">
{{else}}
<div class="card card-danger">
{{/if}}
<img class="card-img-top img-responsive" src="http://content.warframe.com/MobileExport/{{image}}" alt="#{{name}} card image">
<div class="card-block">
<h4 class="card-title">{{name}}</h4>
<div class="card-text">
<p>Health : {{parsePercentage heatlh}}</p>
<p class="located">Visible: {{{localizeBool discovered}}}</p>
</div>
</div>
<div class="card-footer text-muted">
Last Discovered: <span class="badge target-time" data-starttime="{{time}}"></span> at {{node}}, <strong>{{region}}</strong>
</div>
</div>
{{/enemies}}
</script>
<!-- End templates -->
<script>
var rnd = Math.floor(Math.random() * (10000000 - 1 + 1)) + 1;
window.config = {
dataUrl: "https://crossorigin.me/https://deathsnacks.com/wf/data/",
platformDataUrl: "https://crossorigin.me/https://deathsnacks.com/wf/data/",
platform: "pc"
};
</script>
<!--<script src="https://crossorigin.me/https://deathsnacks.com/wf/index.js?v=109"></script>-->
<script>
window.firstRun = true;
window.persistentStatus = new Map();
window.alertIds = [];
window.invasionIds = [];
window.existingConflicts = [];
String.prototype.toTitleCase = function() {
var str = this;
if(!str.length) {
return "";
}
str = str.split(" ");
for(var i = 0; i < str.length; i++) {
str[i] = str[i].charAt(0).toUpperCase() + (str[i].substr(1).length ? str[i].substr(1).toLowerCase() : '');
}
return (str.length ? str.join(" ") : str);
};
function shouldNotifyDisappearances() {
return $('[name="confirmed"]:checked').val() === "1";
}
$(document).ready(function() {
$('div.segmented-control a').on('click', function() {
$('div.segmented-control a').each(function(i, e) {
$(e).removeClass('active');
});
$(this).addClass('active');
$(this).find('input').prop('checked', true);
return false;
});
});
function getAlertBadges(rewards) {
var rewards = rewards.split(" - ");
var badgestr = "";
for (i = 0; i < rewards.length; i++) {
var reward = rewards[i];
var style = "";
if (!reward.endsWith("cr"))
style = " style=\"background-color:blue;\"";
badgestr += "<span class=\"badge alert2\"" + style + ">" + reward + "</span>";
}
return badgestr;
}
function updateTime() {
$(".time").each(function(index) {
var starttime = moment.unix($(this).data("starttime"));
var endtime = moment.unix($(this).data("endtime"));
var timetext = "";
if (moment() < starttime) {
var duration = moment.duration(starttime.diff(moment(), 'seconds'), 'seconds');
if (duration.days() != 0)
timetext = "Start: " + pad2(duration.days()) + "d " + pad2(duration.hours()) + "h " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
else if (duration.hours() != 0)
timetext = "Start: " + pad2(duration.hours()) + "h " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
else
timetext = "Start: " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
$(this).css("background-color", "#999");
} else if (starttime < moment()) {
var duration = moment.duration(endtime.diff(moment(), 'seconds'), 'seconds');
if (duration.days() != 0)
timetext = pad2(duration.days()) + "d " + pad2(duration.hours()) + "h " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
else
timetext = pad2(duration.hours()) + "h " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
//$(this).css("background-color", "green");
if (endtime < moment()) {
$(this).css("background-color", "red");
timetext = "Expired: " + timetext;
}
}
$(this).html("<span title=\"Start: " + starttime.format("dddd, MMMM Do YYYY, h:mm:ss a") + " End: " + endtime.format("dddd, MMMM Do YYYY, h:mm:ss a") + "\">" + timetext + "</span>");
});
$(".vttime").each(function(index) {
var starttime = moment.unix($(this).data("starttime"));
var endtime = moment.unix($(this).data("endtime"));
var timetext = "";
if (moment() < starttime) {
var duration = moment.duration(starttime.diff(moment(), 'seconds'), 'seconds');
if (duration.days() != 0)
timetext = "Start: " + pad2(duration.days()) + "d " + pad2(duration.hours()) + "h " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
else if (duration.hours() != 0)
timetext = "Start: " + pad2(duration.hours()) + "h " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
else
timetext = "Start: " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
} else if (starttime < moment()) {
var duration = moment.duration(endtime.diff(moment(), 'seconds'), 'seconds');
if (duration.days() != 0)
timetext = pad2(duration.days()) + "d " + pad2(duration.hours()) + "h " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
else
timetext = pad2(duration.hours()) + "h " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
$(this).css("color", "green");
if (endtime < moment()) {
timetext = "Expired: " + timetext;
$(this).css("color", "red");
}
}
$(this).html("<span title=\"Start: " + starttime.format("dddd, MMMM Do YYYY, h:mm:ss a") + " End: " + endtime.format("dddd, MMMM Do YYYY, h:mm:ss a") + "\">" + timetext + "</span>");
});
$(".bltime").each(function(index) {
var endtime = moment.unix($(this).data("endtime"));
var timetext = "Time remaining: ";
if (endtime > moment()) {
var duration = moment.duration(endtime.diff(moment(), 'seconds'), 'seconds');
timetext += pad2(duration.hours() + duration.days() * 24) + "h " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
} else if (endtime < moment()) {
var duration = moment.duration(endtime.diff(moment(), 'seconds'), 'seconds');
timetext += "-" + pad2(duration.hours() + duration.days() * -24) + "h " + pad2(duration.minutes() * -1) + "m " + pad2(duration.seconds() * -1) + "s";
}
$(this).html("<span title=\"End: " + endtime.format("dddd, MMMM Do YYYY, h:mm:ss a") + "\">" + timetext + "</span>");
});
$(".sortietime").each(function(index) {
var endtime = moment.unix($(this).data("endtime"));
var timetext = "";
if (endtime > moment()) {
var duration = moment.duration(endtime.diff(moment(), 'seconds'), 'seconds');
timetext += pad2(duration.hours() + duration.days() * 24) + "h " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
} else if (endtime < moment()) {
var duration = moment.duration(endtime.diff(moment(), 'seconds'), 'seconds');
timetext += "-" + pad2(duration.hours() + duration.days() * -24) + "h " + pad2(duration.minutes() * -1) + "m " + pad2(duration.seconds() * -1) + "s";
}
$(this).html("<span title=\"End: " + endtime.format("dddd, MMMM Do YYYY, h:mm:ss a") + "\">" + timetext + "</span>");
});
$(".bldeploytime").each(function(index) {
var endtime = moment.unix($(this).data("time"));
var timetext = "Time to deployment: ";
if (endtime > moment()) {
var duration = moment.duration(endtime.diff(moment(), 'seconds'), 'seconds');
timetext += pad2(duration.hours() + duration.days() * 24) + "h " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
} else if (endtime < moment()) {
var duration = moment.duration(endtime.diff(moment(), 'seconds'), 'seconds');
timetext += "-" + pad2(duration.hours() + duration.days() * -24) + "h " + pad2(duration.minutes() * -1) + "m " + pad2(duration.seconds() * -1) + "s";
}
$(this).html("<span title=\"Deployment: " + endtime.format("dddd, MMMM Do YYYY, h:mm:ss a") + "\">" + timetext + "</span>");
});
$(".taxtime").each(function(index) {
var endtime = moment.unix($(this).data("time"));
var timetext = "Allowed in: ";
if (endtime > moment()) {
var duration = moment.duration(endtime.diff(moment(), 'seconds'), 'seconds');
timetext += pad2(duration.hours() + duration.days() * 24) + "h " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
} else if (endtime < moment()) {
timetext = "Tribute change allowed.";
}
$(this).html("<span title=\"Allowed: " + endtime.format("dddd, MMMM Do YYYY, h:mm:ss a") + "\">" + timetext + "</span>");
});
$(".header-time").each(function(index) {
if ($(this).data("time") == '0')
return;
var endtime = moment.unix($(this).data("time"));
var timetext = "";
if (endtime > moment()) {
var duration = moment.duration(endtime.diff(moment(), 'seconds'), 'seconds');
timetext += pad2(duration.hours() + duration.days() * 24) + ":" + pad2(duration.minutes()) + ":" + pad2(duration.seconds()) + ' |';
} else if (endtime < moment()) {
timetext = "Completed.";
}
$(this).html("<span title=\"" + endtime.format("dddd, MMMM Do YYYY, h:mm:ss a") + "\">" + timetext + "</span>");
});
$(".target-time").each(function(index) {
var starttime = moment.unix($(this).data("starttime"));
var timetext = "";
var duration = '';
if (moment() < starttime) {
var duration = moment.duration(starttime.diff(moment(), 'seconds'), 'seconds');
if (duration.days() != 0)
timetext = "Start: " + pad2(duration.days()) + "d " + pad2(duration.hours()) + "h " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
else if (duration.hours() != 0)
timetext = "Start: " + pad2(duration.hours()) + "h " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
else
timetext = "Start: " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
} else if (starttime < moment()) {
var duration = moment.duration(moment().diff(starttime, 'seconds'), 'seconds');
if (duration.days() != 0)
timetext = pad2(duration.days()) + "d " + pad2(duration.hours()) + "h " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
else
timetext = pad2(duration.hours()) + "h " + pad2(duration.minutes()) + "m " + pad2(duration.seconds()) + "s";
//$(this).css("background-color", "green");
}
$(this).html("<span title=\"" + starttime.format("dddd, MMMM Do YYYY, h:mm:ss a") + "\">" + timetext + "</span>");
});
var hour = Math.floor(moment().valueOf() / 3600000) % 24;
var cycle = 'Night';
var colour = 'darkblue';
if ((hour >= 0 && hour < 4) || (hour >= 8 && hour < 12) || (hour >= 16 && hour < 20)) {
cycle = 'Day';
colour = 'orange';
}
var hourleft = 3 - (hour % 4);
minutes = 59 - moment().minutes();
seconds = 59 - moment().seconds();
$('#daynight').text(cycle).css('color', colour);
$('#daynight-timeleft').text("Time left: " + pad2(hourleft) + "h " + pad2(minutes) + "m " + pad2(seconds) + "s");
}
function updateInvasionSound(first) {
$.get(window.config.platformDataUrl + "invasion_raw.txt", function(data) {
var lines = data.split('\n');
var soundqueue = false;
var notify_invasion = [];
for (i = 0; i < lines.length; i++) {
if (lines[i].length < 20)
continue;
var parts = lines[i].split('|');
var id = parts[0];
if ($.inArray(id, window.invasionIds) == -1) {
soundqueue = true;
window.invasionIds.push(id);
notify_invasion.push({
node: parts[1],
region: parts[2],
desc: parts[18],
atk: parts[8],
atkreward: parts[10],
def: parts[3],
defreward: parts[5]
});
}
}
if (soundqueue && !first) {
playSound('#soundYes');
$.each(notify_invasion, function(index, invasion) {
displayNotification('Warframe Invasion', '{0} ({1}) - {2} - {3} ({4}) - {5} ({6})'.f(invasion.node, invasion.region, invasion.desc, invasion.atk, invasion.atkreward, invasion.def, invasion.defreward));
});
}
});
}
function updateBadlands() {
var soundQueue = false;
var newList = [];
$.getJSON(window.config.platformDataUrl + "currentbadlands_2.json", function(data) {
var html = "";
function compare(a, b) {
var region2 = a.NodeRegionName.split('/');
var region = region2[region2.length - 1] + a.NodeDisplayName;
region2 = b.NodeRegionName.split('/');
var region1 = region2[region2.length - 1] + b.NodeDisplayName;
if (region < region1)
return -1;
if (region > region1)
return 1;
return 0;
}
data.sort(compare);
$("#ds_pay_body tr").remove();
$.each(data, function(index, node) {
var name = node.NodeDisplayName;
var region2 = node.NodeRegionName.split('/');
var region = region2[region2.length - 1];
if (node.AttackerInfo == null || (node.ConflictExpiration != null && node.ConflictExpiration.sec < moment().unix())) {
var templateSource = $('#peaceful_ds-template').html();
var template = Handlebars.compile(templateSource);
var def = node.DefenderInfo;
var defname = def.Name;
var message = def.MOTD;
var defhealth = ((def.StrengthRemaining / def.MaxStrength) * 100).toFixed(2);
var deployment = moment.unix(def.DeploymentActivationTime.sec);
var cooldown = moment.unix((node.PostConflictCooldown == null ? -1 : node.PostConflictCooldown.sec));
var oncooldown = node.PostConflictCooldown != null && cooldown > moment();
var data = {
def_id: def.Id.id,
id: node._id.id,
node: name,
region: region,
type: node.NodeGameType,
time: oncooldown ? node.PostConflictCooldown.sec : (deployment > moment() ? def.DeploymentActivationTime.sec : 0),
status: deployment > moment() ? ' DEPLOYING' : (oncooldown ? ' ARMISTICE' : ''),
is_alliance: def.IsAlliance ? "Alliance" : "Clan",
name: defname,
deployed: def.DeployerName,
message: message,
author: def.MOTDAuthor,
pub_cred: def.CreditsTaxRate,
pub_resource: def.ItemsTaxRate,
member_cred: def.MemberCreditsTaxRate,
member_resource: def.MemberItemsTaxRate,
health: defhealth,
taxtime: def.TaxChangeAllowedTime.sec,
timer: deployment < moment() ? (oncooldown ? '<p class="bltime" data-endtime="{0}"></p>'.f(node.PostConflictCooldown.sec) : '') : '<p class="bldeploytime" data-time="{0}"></p>'.f(def.DeploymentActivationTime.seconds),
history: generateHistoryHtml(node.History, node, false),
def_taxchange: def.TaxLastChangedBy,
def_taxchange_clan: def.IsAlliance ? def.TaxLastChangedByClan : def.Name
};
html += template(data);
} else {
var atkname = node.AttackerInfo.Name;
var atkmessage = node.AttackerInfo.MOTD;
var message = node.DefenderInfo.MOTD;
var def = node.DefenderInfo;
var atk = node.AttackerInfo;
var defhealth = ((def.StrengthRemaining / def.MaxStrength) * 100).toFixed(2);
var atkhealth = ((atk.StrengthRemaining / atk.MaxStrength) * 100).toFixed(2);
var defpay = "No Battle Pay";
if (def.MissionBattlePay != null) {
defpay = commafy(def.MissionBattlePay) + "cr" + " (For {0} missions)".f(commafy(def.BattlePayReserve / def.MissionBattlePay));
if (def.BattlePayReserve != 0) {
$('#ds_pay_body').append('<tr><td><a href="#{5}">{0} ({1})</a></td><td>{2}</td><td>{3}</td><td>{4}</td><td>Defender</td></tr>'.f(name, region, commafy(def.MissionBattlePay), commafy(def.BattlePayReserve / def.MissionBattlePay), def.Name, node._id.id));
}
}
newList.push({
id: node._id.id,
action: 'defend',
pay: def.MissionBattlePay
});
var atkpay = "No Battle Pay";
if (atk.MissionBattlePay != null) {
atkpay = commafy(atk.MissionBattlePay) + "cr" + " (For {0} missions)".f(commafy(atk.BattlePayReserve / atk.MissionBattlePay));
if (atk.BattlePayReserve != 0) {
$('#ds_pay_body').append('<tr><td><a href="#{5}">{0} ({1})</a></td><td>{2}</td><td>{3}</td><td>{4}</td><td>Attacker</td></tr>'.f(name, region, commafy(atk.MissionBattlePay), commafy(atk.BattlePayReserve / atk.MissionBattlePay), atk.Name, node._id.id));
}
}
newList.push({
id: node._id.id,
action: 'attack',
pay: atk.MissionBattlePay
});
var atkdeploy = moment.unix(atk.DeploymentActivationTime.sec);
if (atkdeploy > moment()) {
var templateSource = $('#deploying_ds-template').html();
var template = Handlebars.compile(templateSource);
var data = {
id: node._id.id,
node: name,
region: region,
type: node.NodeGameType,
time: atk.DeploymentActivationTime.sec,
def_is_alliance: def.IsAlliance ? "Alliance" : "Clan",
def_id: def.Id.id,
def_name: def.Name,
def_deployer: def.DeployerName,
def_message: message,
def_author: def.MOTDAuthor,
def_pub_cred: def.CreditsTaxRate,
def_pub_resource: def.ItemsTaxRate,
def_member_cred: def.MemberCreditsTaxRate,
def_member_resource: def.MemberItemsTaxRate,
def_health: defhealth,
def_pay: defpay,
def_taxtime: def.TaxChangeAllowedTime.sec,
def_taxchange: def.TaxLastChangedBy,
def_taxchange_clan: def.IsAlliance ? def.TaxLastChangedByClan : def.Name,
atk_is_alliance: atk.IsAlliance ? "Alliance" : "Clan",
atk_id: atk.Id.id,
atk_name: atk.Name,
atk_deployer: atk.DeployerName,
atk_message: atkmessage,
atk_author: atk.MOTDAuthor,
atk_pub_cred: atk.CreditsTaxRate,
atk_pub_resource: atk.ItemsTaxRate,
atk_member_cred: atk.MemberCreditsTaxRate,
atk_member_resource: atk.MemberItemsTaxRate,
atk_health: atkhealth,
atk_pay: atkpay,
atk_taxtime: atk.TaxChangeAllowedTime.sec,
atk_taxchange: atk.TaxLastChangedBy,
atk_taxchange_clan: atk.IsAlliance ? atk.TaxLastChangedByClan : atk.Name,
history: generateHistoryHtml(node.History, node, false)
};
html += template(data);
} else {
var conflictend = node.ConflictExpiration.sec;
var templateSource = $('#conflict_ds-template').html();
var template = Handlebars.compile(templateSource);
var data = {
id: node._id.id,
node: name,
region: region,
type: node.NodeGameType,
time: node.ConflictExpiration.sec,
def_is_alliance: def.IsAlliance ? "Alliance" : "Clan",
def_id: def.Id.id,
def_name: def.Name,
def_deployer: def.DeployerName,
def_message: message,
def_author: def.MOTDAuthor,
def_pub_cred: def.CreditsTaxRate,
def_pub_resource: def.ItemsTaxRate,
def_member_cred: def.MemberCreditsTaxRate,
def_member_resource: def.MemberItemsTaxRate,
def_health: defhealth,
def_pay: defpay,
def_taxtime: def.TaxChangeAllowedTime.sec,
def_health_count: def.StrengthRemaining,
def_max_health: def.MaxStrength,
def_dmg: def.DamagePerMission,
def_taxchange: def.TaxLastChangedBy,
def_taxchange_clan: def.IsAlliance ? def.TaxLastChangedByClan : def.Name,
def_bpchange: def.BattlePaySetBy,
def_bpchange_clan: def.IsAlliance ? def.BattlePaySetByClan : def.Name,
atk_is_alliance: atk.IsAlliance ? "Alliance" : "Clan",
atk_id: atk.Id.id,
atk_name: atk.Name,
atk_deployer: atk.DeployerName,
atk_message: atkmessage,
atk_author: atk.MOTDAuthor,
atk_pub_cred: atk.CreditsTaxRate,
atk_pub_resource: atk.ItemsTaxRate,
atk_member_cred: atk.MemberCreditsTaxRate,
atk_member_resource: atk.MemberItemsTaxRate,
atk_health: atkhealth,
atk_pay: atkpay,
atk_taxtime: atk.TaxChangeAllowedTime.sec,
atk_health_count: atk.StrengthRemaining,
atk_max_health: atk.MaxStrength,
atk_dmg: atk.DamagePerMission,
atk_taxchange: atk.TaxLastChangedBy,
atk_taxchange_clan: atk.IsAlliance ? atk.TaxLastChangedByClan : atk.Name,
atk_bpchange: atk.BattlePaySetBy,
atk_bpchange_clan: atk.IsAlliance ? atk.BattlePaySetByClan : atk.Name,
history: generateHistoryHtml(node.History, node, true)
};
html += template(data);
}
}
});
window.existingConflicts = newList;
$("#badlandaccordion").html(html);
$(".toggler").click(function() {
$(this).toggleClass('dropup');
$(this).parent().children('.blpanel').slideToggle();
});
$(".toggler2").click(function() {
var toggler = $(this);
getHistory(toggler);
toggler.parent().parent().children('.blpanel2').slideToggle();
});
$("#ds_pay_table").trigger('update');
$("#ds_pay_table").tablesorter({
headerTemplate: '{content} {icon}',
widgets: ['uitheme'],
sortList: [
[1, 1]
]
});
});
}
function generateHistoryHtml(history_list, node, add) {
var html = '';
if (add) {
html += '<p><a target="_blank" href="/wf/bl_history.html#{0}_{1}|ongoing">Current Health/Pay History</a></p>'.f(node._id.id, node.AttackerInfo.DeploymentActivationTime.sec);
}
html += '<h5><a class="toggler2" data-id="{0}">Conflict History</a></h5><div class="blpanel2 collapse" id="{0}_history">Loading...</div>'.f(node._id.id);
return html;
}
function getHistory(toggler) {
var nodeid = toggler.data('id');
$.getJSON(window.config.dataUrl + 'bl_logs/history/' + nodeid + '_' + window.config.platform + '.json', function(history_list) {
if (history_list == null || typeof(history_list) == 'undefined')
return '';
function compare(a, b) {
return (b.End.sec - a.End.sec);
}
history_list.sort(compare);
var html = '<ul class="nobullets" id="' + nodeid + '_pagination' + '">';
$.each(history_list, function(index, history) {
var temp = '<li>';
temp += ((history.DefId.id == history.WinId.id) ? '<b>' : '') + '<a target="_blank" href="/wf/clan_bl_history.html#{0}">'.f(history.DefId.id) +
history.Def + (((history.DefId.id == history.WinId.id) ? ' (Winner)</b>' : '') + '</a>');
temp += ' vs ';
temp += ((history.AttId.id == history.WinId.id) ? '<b>' : '') + '<a target="_blank" href="/wf/clan_bl_history.html#{0}">'.f(history.AttId.id) +
history.Att + (((history.AttId.id == history.WinId.id) ? ' (Winner)</b>' : '') + '</a>');
temp += " || ";
var start = moment.unix(history.Start.sec);
var end = moment.unix(history.End.sec);
temp += start.format("MMMM Do, h:mm:ss a");
temp += ' - ';
temp += end.format("MMMM Do, h:mm:ss a");
temp += ' || <a target="_blank" href="/wf/bl_history.html#{0}_{1}">Health/Pay History</a>'.f(nodeid, history.Start.sec);
temp += '</li>'
html += temp;
});
html += '</ul>';
$('#' + nodeid + '_history').html(html);
$('#' + nodeid + '_pagination').quickPager();
});
}
function getRegion(id) {
switch (id) {
case 0:
return "Mercury";
case 1:
return "Venus";
case 2:
return "Earth";
case 3:
return "Mars";
case 4:
return "Jupiter";
case 5:
return "Saturn";
case 6:
return "Uranus";
case 7:
return "Neptune";
case 8:
return "Pluto";
case 9:
return "Ceres";
case 10:
return "Eris";
case 11:
return "Sedna";
case 12:
return "Europa";
case 15:
return "Phobos";
default:
return "-";
}
}
function updatePersistent() {
var rnd = Math.floor(Math.random() * (10000000 - 1 + 1)) + 1;
$.getJSON(window.config.platformDataUrl + "persistenemies.json?v=" + rnd, function(data) {
var templateSource = $('#persist-template').html();
var template = Handlebars.compile(templateSource);
var enemiesData = []
$.each(data, function(index, enemy) {
enemy.LocTag = enemy.LocTag.toLowerCase();
enemiesData.push({
name: enemy.LocTag.toTitleCase(),
image: enemy.Icon,
node: enemy.LastDiscoveredLocation,
time: enemy.LastDiscoveredTime.sec,
heatlh: enemy.HealthPercent * 100,
flee_dmg: enemy.FleeDamage,
discovered: enemy.Discovered,
rank: enemy.Rank,
region: getRegion(enemy.Region),
});
if ( enemy.Discovered ) {
if ( /*window.firstRun === false && */
( window.persistentStatus.has(enemy.LocTag) === false ||
window.persistentStatus.get(enemy.LocTag).discovered !== enemy.Discovered )
) {
sendPersistentEnemyNotification(enemy.LocTag, enemy.LastDiscoveredLocation, getRegion(enemy.Region), enemy.HealthPercent * 100);
}
window.persistentStatus.set(enemy.LocTag, { discovered: enemy.Discovered, location: enemy.LastDiscoveredLocation });
} else {
if ( shouldNotifyDisappearances() &&
window.persistentStatus.has(enemy.LocTag) === true &&
window.persistentStatus.get(enemy.LocTag).discovered !== enemy.Discovered ) {
sendPersistentEnemyDisappearedNotification(enemy.LocTag, enemy.HealthPercent * 100);
}
window.persistentStatus.set(enemy.LocTag, { discovered: enemy.Discovered })
}
});
$('.persistentenemies-container').html(template({
enemies: enemiesData
}));
}).done(function() {
if ( window.firstRun === true ) {
window.firstRun = false;
}
});
}
function isSoundPay(id, action, pay) {
return;
}
function displayNotification(title, msg) {
if (!("Notification" in window)) {
console.log("This browser does not support desktop notification");
return;
}
Notification.requestPermission(function(permission) {});
var options = {
body: msg,
icon: 'https://crossorigin.me/https://deathsnacks.com/wf/img/LotusFlower.png'
}
var n = new Notification(title, options);
}
function sendPersistentEnemyNotification(enemyName, enemyLoc, enemyLocPlanet, enemyHPLeft) {
var payload = JSON.stringify({
icon_url: "https://deathsnacks.com/wf/img/LotusFlower.png",
username: "warframe-notifications",
attachments: [
{
text: "Tenno, a new Acolyte (" + enemyName.toTitleCase() + ") has been detected :crossed_swords::crossed_swords::crossed_swords:",
color: "good",
fields: [
{
"title": "Name",
"value": enemyName.toTitleCase(),
"short": true
},
{
"title": "HP remaining",
"value": parseFloat(Math.round(enemyHPLeft * 100) / 100).toFixed(2) + "%",
"short": true
},
{
"title": "Location",
"value": enemyLoc.toTitleCase() + ", " + enemyLocPlanet.toTitleCase(),
"short": true
}
]
}
]
});
var url = 'https://hooks.slack.com/services/....................'; // FIXME
$.post( url, payload, function() {
console.log( "success" );
}, "json").fail(function() {
console.error( "error sending notification" );
});
}
function sendPersistentEnemyDisappearedNotification(enemyName, enemyHPLeft) {
var payload = JSON.stringify({
icon_url: "https://deathsnacks.com/wf/img/LotusFlower.png",
username: "warframe-notifications",
attachments: [
{
text: "Tenno, an Acolyte (" + enemyName.toTitleCase() + ") has just disappeared :ghost:",
color: "danger",
fields: [
{
"title": "Name",
"value": enemyName.toTitleCase(),
"short": true
},
{
"title": "HP remaining",
"value": parseFloat(Math.round(enemyHPLeft * 100) / 100).toFixed(2) + "%",
"short": true
}
]
}
]
});
var url = 'https://hooks.slack.com/services/....................'; // FIXME
$.post( url, payload, function() {
console.log( "success" );
}, "json").fail(function() {
console.error( "error sending notification" );
});
}
function playSound(check) {
if (!window.HTMLAudioElement) {
alert("New event! Your browser does not support HTML5 audio, so no sound for you.")
return;
}
var s = document.getElementsByTagName("audio")[0];
s.play();
}
function update() {
updatePersistent();
}
function initSettings() {
$('.setting').each(function(index, element) {
var cookie = $.cookie($(this).data('cookie'));
switch ($(this).attr('type')) {
case 'checkbox':
if ($(this).data('cookie') == 'desktopNotification') {
$(this).change(function() {
if (this.checked) {
Notification.requestPermission().then(function(permission) {
if (permission === 'granted') {
$.cookie('desktopNotification', true);
} else {
$.cookie('desktopNotification', false);
$('#notCb').attr('checked', false);
}
});
} else {
$.cookie($(this).data('cookie'), this.checked);
}
});
} else {
$(this).change(function() {
$.cookie($(this).data('cookie'), this.checked);
});
}
if (typeof cookie === 'undefined')
return;
var checked = cookie.toLowerCase() === 'true';
$(this).attr("checked", checked);
break;
}
});
}
var invasionInt, alertInt, invasionSoundInt, timeInt, newsInt, saleInt, badlandsInt, vtInt, dealInt, libraryInt, persistInt;
$(document).ready(function() {
$('.close').bind('click', function() {
var id = $(this).parent().attr('id');
if (id)
$.cookie('alert-' + id, 'closed', {
path: '/'
});
});
$('.alert').each(function() {
var id = $(this).attr('id');
if ($.cookie('alert-' + id))
$(this).hide();
});
initSettings();
Handlebars.registerHelper('ifCond', function(v1, v2, options) {
if (v1 === v2) {
return options.fn(this);
}
return options.inverse(this);
});
Handlebars.registerHelper('parsePercentage', function(number) {
return parseFloat(Math.round(number * 100) / 100).toFixed(2) + "%";
});
Handlebars.registerHelper('isTrue', function(value) {
if ( value === true ) {
return value;
}
var valueNormalized = value.toLowerCase();
return value === "yes" || value === "1" ;
});
Handlebars.registerHelper('toTitleCase', function(text) {
return text.toTitleCase();
});
Handlebars.registerHelper('localizeBool', function(value) {
if ( value === true ) {
return "Yes";
} else {
return "No";
}
});
var dsenabled = $.cookie('ds_enabled');
if (typeof(dsenabled) !== 'undefined') {
var dsEnabled = dsenabled.toLowerCase() === 'true';
if (dsEnabled)
unhideDS();
}
update();
$("#nodes-header").click(function() {
$("#nodes-total-container").slideToggle("slow");
});
timeInt = setInterval(updateTime, 1 * 1000);
persistInt = setInterval(updatePersistent, 0.5 * 60 * 1000);
$("#collapse_all").click(function() {
$(".blpanel").slideUp();
$(".toggler").removeClass('dropup');
});
$("#expand_all").click(function() {
$(".blpanel").slideDown();
$(".toggler").addClass('dropup');
});
$("#enable-ds").click(function() {
unhideDS();
$.cookie('ds_enabled', true);
});
});
</script>
</html>
@louiej
Copy link

louiej commented Feb 11, 2017

Hey, would this still work on the current acolyte hunt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment