This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.
My player message system isn't working. You start on the Diplomacy page which lists the player nations. Once a player nation is selected they are sent to the send message page which shows any messages between themselves and the nation selected. It also gives them a message box to write their own message to send. Here is the code.
If under FORM ACTION I link the page to itself it works but you have to refresh the page to see the new message which also resends the message. If the FORM ACTION goes to the previous page then it does not INSERT the message into the table on the server.
This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.
php, sql INSERT TO not working when ACTION links to another page
I was watching Avengers and I thought it would be it wresting to make something like Jarvis with Python which is what I'm doing. I've only been doing Python for 1 year ( I'm 15) so I'm not the best.
So basically, I want to make something basic at the beginning where if I say "Cameron, activate" it will out put to the speakers "Cameron activated". Them if I say "hello" it'll reply "hello".
I first want to know if this is possible and if so, could someone help me with it?? Thanks so much!
This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.
When validating the jQuery I receive the followers 2 errors: "'$' was used before it was defined." & "'window' was used before it was defined." What does this mean? & how do I remove these errors? Thank you :-)
var lastScrollTop = 0;
$(window).scrollTop(0);
$(window).on('scroll', function() {
var header = $('header');
var content = $('content');
var headerBg = $('.header-bg');
var headerCnt = $('.header-content');
var scrollTop = $(window).scrollTop();
var dynHeaderVisible = false;
if (lastScrollTop > scrollTop) {
if (scrollTop <= 400) {
headerBg.css("height", 0);
headerCnt.css('color', 'white');
} else {
headerBg.css("height", 80);
headerCnt.css("height", 80);
headerCnt.css('color', 'black');
}
} else {
// Down
if (scrollTop > 350) {
console.log ("hi");
headerCnt.css("height", 0);
headerBg.css("height", 0);
}
}
lastScrollTop = scrollTop;
});
$.fn.isOnScreen = function(){
var element = this.get(0);
var bounds = element.getBoundingClientRect();
return bounds.top < window.innerHeight && bounds.bottom > 0;
}
This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.
I have this straight forward example where I wanted to use my data and my topojson instead. I get the data loaded but the visualization is not working properly.
Logging the dataRange() gives my -INFINITY,INFINITY, so something with the ranging is noch wokring but I can't see what it is.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>d3 choropleth map</title>
<style>
#wrapper {
width: 960px;
margin: -30px auto 0;
}
#map {
width: 960px;
height: 580px;
position: relative;
}
.stroke {
fill: none;
stroke: #888;
stroke-width: 2px;
}
.fill {
fill: #fff;
}
.graticule {
fill: none;
stroke: #777;
stroke-width: .5px;
stroke-opacity: .5;
}
.land {
fill: #222;
}
.boundary {
fill: none;
stroke: #fff;
stroke-width: .5px;
}
.country {
fill: steelblue;
stroke: white;
}
#play, #clock {
position: absolute;
top: 15px;
}
#play {
left: 15px;
}
#clock {
left: 65px;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="map"></div>
<button id="play">play</button>
<span id="clock">year</span>
</div>
<script src="http://ift.tt/JmLP3T"></script>
<script src="http://ift.tt/1oOECWY"></script>
<script src="http://ift.tt/1hUyqi2"></script>
<script src="http://ift.tt/JmLP3U"></script>
<script>
//globals
var width, height, projection, path, graticule, svg, attributeArray = [], currentAttribute = 0, playing = false;
function init() {
setMap();
animateMap();
}
function setMap() {
width = 960, height = 580; // map width and height, matches
var projection = d3.geo.mercator()
.translate([width / 2, height])
//.scale((width - 1) / 2 / Math.PI);
.scale(400);
path = d3.geo.path() // create path generator function
.projection(projection); // add our define projection to it
graticule = d3.geo.graticule(); // create a graticule
svg = d3.select("#map").append("svg") // append a svg to our html div to hold our map
.attr("width", width)
.attr("height", height);
svg.append("defs").append("path") // prepare some svg for outer container of svg elements
.datum({type: "Sphere"})
.attr("id", "sphere")
.attr("d", path);
svg.append("use") // use that svg to style with css
.attr("class", "stroke")
.attr("xlink:href", "#sphere");
svg.append("path") // use path generator to draw a graticule
.datum(graticule)
.attr("class", "graticule")
.attr("d", path);
loadData(); // let's load our data next
}
function loadData() {
queue() // queue function loads all external data files asynchronously
.defer(d3.json, "mapdata/germany.json") // our geometries
.defer(d3.csv, "choroplethmap.csv") // and associated data in csv file
.await(processData); // once all files are loaded, call the processData function passing
// the loaded objects as arguments
}
function processData(error,world,countryData) {
// function accepts any errors from the queue function as first argument, then
// each data object in the order of chained defer() methods above
var countries = world.objects.states_germany.geometries // store the path in variable for ease
//console.log(countries);
for (var i in countries) { // for each geometry object
for (var j in countryData) { // for each row in the CSV
console.log(countryData[j]);
if(countries[i].id == countryData[j].id) {
//console.log("SUCCESS"); // if they match
for(var k in countryData[i]) { // for each column in the a row within the CSV
if(k != 'name' && k != 'id') { // let's not add the name or id as props since we already have them
if(attributeArray.indexOf(k) == -1) {
attributeArray.push(k); // add new column headings to our array for later
}
countries[i][k] = Number(countryData[j][k]) // add each CSV column key/value to geometry object
}
}
break; // stop looking through the CSV since we made our match
}
}
}
d3.select('#clock').html(attributeArray[currentAttribute]); // populate the clock initially with the current year
drawMap(world); // let's mug the map now with our newly populated data object
}
function drawMap(world) {
svg.selectAll(".country") // select country objects (which don't exist yet)
.data(topojson.feature(world, world.objects.states_germany).features) // bind data to these non-existent objects
.enter().append("path") // prepare data to be appended to paths
.attr("class", "country") // give them a class for styling and access later
.attr("id", function(d) { return "code_" + d.properties.id; }, true) // give each a unique id for access later
.attr("d", path); // create them using the svg path generator defined above
var dataRange = getDataRange(); // get the min/max values from the current year's range of data values
d3.selectAll('.country') // select all the countries
.attr('fill-opacity', function(d) {
return getColor(d[attributeArray[currentAttribute]], dataRange); // give them an opacity value based on their current value
});
}
function sequenceMap() {
var dataRange = getDataRange(); // get the min/max values from the current year's range of data values
d3.selectAll('.country').transition() //select all the countries and prepare for a transition to new values
.duration(750) // give it a smooth time period for the transition
.attr('fill-opacity', function(d) {
return getColor(d[attributeArray[currentAttribute]], dataRange); // the end color value
})
}
function getColor(valueIn, valuesIn) {
var color = d3.scale.linear() // create a linear scale
.domain([valuesIn[0],valuesIn[1]]) // input uses min and max values
.range([.3,1]); // output for opacity between .3 and 1 %
return color(valueIn); // return that number to the caller
}
function getDataRange() {
// function loops through all the data values from the current data attribute
// and returns the min and max values
var min = Infinity, max = -Infinity;
d3.selectAll('.country')
.each(function(d,i) {
var currentValue = d.properties[attributeArray[currentAttribute]];
if(currentValue <= min && currentValue != -99 && currentValue != 'undefined') {
min = currentValue;
}
if(currentValue >= max && currentValue != -99 && currentValue != 'undefined') {
max = currentValue;
}
});
console.log([min,max]);
return [min,max]; //boomsauce
}
function animateMap() {
var timer; // create timer object
d3.select('#play')
.on('click', function() { // when user clicks the play button
if(playing == false) { // if the map is currently playing
timer = setInterval(function(){ // set a JS interval
if(currentAttribute < attributeArray.length-1) {
currentAttribute +=1; // increment the current attribute counter
} else {
currentAttribute = 0; // or reset it to zero
}
sequenceMap(); // update the representation of the map
d3.select('#clock').html(attributeArray[currentAttribute]); // update the clock
}, 2000);
d3.select(this).html('stop'); // change the button label to stop
playing = true; // change the status of the animation
} else { // else if is currently playing
clearInterval(timer); // stop the animation by clearing the interval
d3.select(this).html('play'); // change the button label to play
playing = false; // change the status again
}
});
}
window.onload = init(); // magic starts here
</script>
</body>
</html>
So where is the mistake? You can finde the full data (map etc) here
This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.
I want to convert an instance class to plain object, without losing methods and/or inherited properties. So for example:
class Human {
height: number;
weight: number;
constructor() {
this.height = 180;
this.weight = 180;
}
getWeight() { return this.weight; }
// I want this function to convert the child instance
// accordingly
toJSON() {
// ???
return {};
}
}
class Person extends Human {
public name: string;
constructor() {
super();
this.name = 'Doe';
}
public getName() {
return this.name;
}
}
class PersonWorker extends Person {
constructor() {
super();
}
public report() {
console.log('I am Working');
}
public test() {
console.log('something');
}
}
let p = new PersonWorker;
let jsoned = p.toJSON();
jsoned should look like this:
{
// from Human class
height: 180,
weight: 180,
// when called should return this object's value of weight property
getWeight: function() {return this.weight},
// from Person class
name: 'Doe'
getName(): function() {return this.name},
// and from PersonWorker class
report: function() { console.log('I am Working'); },
test: function() { console.log('something'); }
}
Is this possible to achieve, and if so, how?
In case you're wondering, I need this because I am using a framework that, unfortunately, accepts as input only a json object, whereas I am trying to use typescript and class inheritance.
This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.
Convert javascript class instance to plain object preserving methods
I'm working on an Android app that is supposed to block incoming calls and (eventually) messages. So far I've read that you can use the internal ITelephony interface to intercept and eventually block calls.
One step of that process involves creating a package called "com.android.internal.telephony" containing a "ITelephony.aidl" file. I've got the following path right now:
\MyApp\app\src\main\java\company\MyApp\com\android\internal\telephony\ITelephony.aidl (this is what Android Studio creates with the "Create Package" command.
The issue is that, for some reason, I get the following error:
error: package com.android.internal.telephony does not exist. I've tried placing the aidl file in different locations but with the same result. Am I doing something wrong and, if so, how do I solve this?
This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.