Well.. Need some help understanding a wee bit of code
Posted: Sat Oct 25, 2014 6:17 pm
Github page of code im talking about:
https://github.com/TechGeddon/openra.gi ... index.html
i'd like to know how to separate these variables so that i can declare them a different var to use in the row.append areas (so that i can successfully separate these values for a searchable/filterable data set.)
function initMapInfo(hash) {
var doMap = function(map) {
if ('title' in map) //if a 'title' exists from the searched hash
$('.map-'+hash).html(map['title']+'<br /><span class="gameSubline">'+map['map_type']+'& nbsp;('+map['players']+' Players)</span>'); //i'd love to know how to use the map_type, Players, and title outside of this function (say where the rows are appended)
};
if (hash in data) { //THIS
doMap(data[hash]); //THIS
return;
}
$.ajax({
type: "GET", //Get action
url: "http://resource.openra.net/map/hash/"+hash, //from this website, with acquired hash? from http://master.openra.net/list_json.php's List
statusCode: { //if something throws a code
404: function() { //lets say a 404 not found
$('.map-'+hash).html('Unknown Map'); //set hash to unknown?
}
}
}).done(function(msg) { //when above code is completed
data[hash] = {}; //no idea what this does?
var reply = jQuery.parseJSON(msg); //variable reply is whatever jquery pulls? need help understanding what its pullling
if (!!reply[0]) // if what jquery pulled was empty then
data[hash] = reply[0]; //set hash value to 0
doMap(data[hash]); //no idea.
});
}
https://github.com/TechGeddon/openra.gi ... index.html
i'd like to know how to separate these variables so that i can declare them a different var to use in the row.append areas (so that i can successfully separate these values for a searchable/filterable data set.)
function initMapInfo(hash) {
var doMap = function(map) {
if ('title' in map) //if a 'title' exists from the searched hash
$('.map-'+hash).html(map['title']+'<br /><span class="gameSubline">'+map['map_type']+'& nbsp;('+map['players']+' Players)</span>'); //i'd love to know how to use the map_type, Players, and title outside of this function (say where the rows are appended)
};
if (hash in data) { //THIS
doMap(data[hash]); //THIS
return;
}
$.ajax({
type: "GET", //Get action
url: "http://resource.openra.net/map/hash/"+hash, //from this website, with acquired hash? from http://master.openra.net/list_json.php's List
statusCode: { //if something throws a code
404: function() { //lets say a 404 not found
$('.map-'+hash).html('Unknown Map'); //set hash to unknown?
}
}
}).done(function(msg) { //when above code is completed
data[hash] = {}; //no idea what this does?
var reply = jQuery.parseJSON(msg); //variable reply is whatever jquery pulls? need help understanding what its pullling
if (!!reply[0]) // if what jquery pulled was empty then
data[hash] = reply[0]; //set hash value to 0
doMap(data[hash]); //no idea.
});
}