Jump to content

dzhax

Members
  • Content count

    363
  • Joined

  • Last visited

Community Reputation

5 Neutral

About dzhax

  • Rank
    Member
  • Birthday 12/07/1989

Contact Methods

  • MSN
    dzhax@live.com
  • Website URL
    http://www.garrett-innovations.com
  • ICQ
    0

Profile Information

  • Location
    United States

Previous Fields

  • Languages
    php, html, sql, some js, basic css
  1. Thanks Ingolme that is working much better. didn't know you can call a function like that. speaking about the handleResponse call.
  2. I have a process that runs every 30 seconds and i want my script to check if it is finished. this way my user doesn't have to wait an arbitrary 30 seconds if the request is submitted closer to the 30 second mark (5 seconds to process instead of the max 30). I tried a while loop and sending $.post within it but from my console logging it doesn't appear to process the while loop as intended var iii = 1; while(iii < 30){ console.log("Checking rcon queue for " + characterID + " (" + iii + ")"); //Code to wait 1 second before continuing. var start = new Date().getTime(); var end = start; while(end < start + 1000) { end = new Date().getTime(); } //Code to $.post to check the the queue is cleared $.post('scripts/rcon_queue.php', {cID: characterID}, function(response){ if(response == "1"){ console.log("Queue is not cleared."); } else { console.log("Queue is clear."); iii = 30; } }); iii++; } console.log("Loading info for character: " + characterID); Now i would expect this to end the while loop response is anything but "1". Which happened after 7 attempts in my most recent test. But this is not happening:
  3. Ok bare with me because I have no idea what this is actually called. If someone knows I will update the title. I am working on a site that will act as an out-of-game marketplace for in-game items. I want to ensure that the player is within the zone of the market in-game so I need an easy way to generate an array of valid coordinates the player could be within to access the market. Ideally i would like to run a function with a parameter specifying the radius of a square and another of the player's current geoID. Basic geometry would help if the geoID's were, in my mind, easier to predict. here is problem: Going North: geoID's increase by 512 points Going East: geoID's increase by 1 Going South: geoID's decrease by 512 Going West geoID's decrease by 1 I realize this is more of a math question then PHP but I have no idea where to start to account for the odd increase. //Generate the exchangeArea array of a 5x5 square around the centeral id specified in param2. $exchangeArea = getExchangeArea(3,117053149); //if player geoID equals one of the values in the exchangeArea array return true else false function getExchangeArea(int radius, int geoID) { . . . } I have attached a graphic showing all the geoIDs for the above example. Ignore the geoAlt that is just they players Y axis. So there is no confusion, North on this diagram is the right side of the image. Making the top West. Any help on where to begin, even if its helping me identify keywords to search on for this kind of formula, algorithm, equation... what ever it's called, would be greatly appreciated.
  4. Ok I got it working. after changing tmpJSON to response. and parsing the JSON outside of the filter var destringify = JSON.parse(staticJSON); $.each(destringify, function(i, v) { rather than $(JSON.parse(staticJSON)).filter(function (i, n){ Not sure why this was a thing but it works and that's all that matters right now.
  5. i am destringifying it tmpJson = $(JSON.parse(staticJSON)).filter(function (i, n){
  6. I think I am getting somewhere but the filter is not actually working var tmp, tmpJSON, response; var staticJSON = JSON.stringify( [{ "id": 35, "commentText": "Hello World.", "createdBy": "Lou", "isImportant": false, "createdAt": "2016-07-29T18:36:39.044Z", "updatedAt": "2016-07-29T18:36:39.044Z" }, { "id": 36, "commentText": "This is all starting to come together", "createdBy": "Mark", "isImportant": false, "createdAt": "2016-07-29T19:13:54.538Z", "updatedAt": "2016-07-29T19:13:54.538Z" }, { "id": 37, "commentText": "I'm pretending to be Lou", "createdBy": "Lou", "isImportant": false, "createdAt": "2016-07-29T19:14:41.130Z", "updatedAt": "2016-07-29T19:14:41.130Z" }, { "id": 41, "commentText": "testing 123", "createdBy": "Mark", "isImportant": false, "createdAt": "2016-07-29T19:21:35.637Z", "updatedAt": "2016-07-29T19:21:35.637Z" }, { "id": 42, "commentText": "testing123456", "createdBy": "Mark", "isImportant": false, "createdAt": "2016-07-29T19:22:42.516Z", "updatedAt": "2016-07-29T19:22:42.516Z" }, { "id": 44, "commentText": "This is not important", "createdBy": "Mark", "isImportant": false, "createdAt": "2016-07-29T19:33:54.805Z", "updatedAt": "2016-07-29T19:33:54.805Z" }, { "id": 51, "commentText": "New functionality", "createdBy": "Lou", "isImportant": true, "createdAt": "2016-08-03T14:38:54.724Z", "updatedAt": "2016-08-11T21:16:05.261Z" }, { "id": 92, "commentText": "Another test", "createdBy": "Lou", "isImportant": false, "createdAt": "2016-08-11T22:18:06.022Z", "updatedAt": "2016-08-11T22:18:06.022Z" }, { "id": 29, "commentText": "hot garbage 2.0", "createdBy": "Kevin", "isImportant": true, "createdAt": "2016-07-28T21:59:35.145Z", "updatedAt": "2016-08-04T21:41:16.361Z" }, { "id": 54, "commentText": "please work", "createdBy": "Dana", "isImportant": false, "createdAt": "2016-08-04T23:24:02.682Z", "updatedAt": "2016-08-04T23:24:02.682Z" }, { "id": 93, "commentText": "test comment", "createdBy": "mark", "isImportant": false, "createdAt": "2016-08-11T22:32:00.067Z", "updatedAt": "2016-08-11T22:32:00.067Z" }, { "id": 78, "commentText": "Testing modal dialog", "createdBy": "Lou", "isImportant": false, "createdAt": "2016-08-10T01:22:10.015Z", "updatedAt": "2016-08-10T01:22:10.015Z" }, { "id": 94, "commentText": "test comment", "createdBy": "mark", "isImportant": true, "createdAt": "2016-08-11T22:32:24.534Z", "updatedAt": "2016-08-11T22:32:24.534Z" }, { "id": 61, "commentText": "wooo", "createdBy": "yes", "isImportant": false, "createdAt": "2016-08-09T22:04:42.671Z", "updatedAt": "2016-08-11T15:51:51.448Z" }, { "id": 81, "commentText": "Deleted files. Just checking if it still works", "createdBy": "Mark", "isImportant": false, "createdAt": "2016-08-11T19:26:36.869Z", "updatedAt": "2016-08-11T19:26:36.869Z" }, { "id": 83, "commentText": "Trying it again", "createdBy": "Mark", "isImportant": false, "createdAt": "2016-08-11T20:29:41.439Z", "updatedAt": "2016-08-11T20:29:41.439Z" }, { "id": 107, "commentText": "New!", "createdBy": "Dana", "isImportant": false, "createdAt": "2016-08-11T23:03:50.597Z", "updatedAt": "2016-08-11T23:03:50.597Z" }, { "id": 112, "commentText": "One more time", "createdBy": "Dana", "isImportant": false, "createdAt": "2016-08-11T23:23:49.398Z", "updatedAt": "2016-08-11T23:23:49.398Z" }, { "id": 115, "commentText": "Try this", "createdBy": "Dana", "isImportant": false, "createdAt": "2016-08-11T23:32:54.382Z", "updatedAt": "2016-08-11T23:32:54.382Z" }] ); console.log(staticJSON); console.log(" "); console.log(" "); console.log(" "); console.log(" "); tmpJson = $(JSON.parse(staticJSON)).filter(function (i, n){ return n.isimportant !== false; }); tmp = "["; $.each(tmpJson, function(i) { tmp += '{'; tmp += '"commentText": "' + tmpJson[i].commentText + '", '; tmp += '"createdAt": "' + tmpJson[i].createdAt + '", '; tmp += '"createdBy": "' + tmpJson[i].createdBy + '", '; tmp += '"id": ' + tmpJson[i].id + ', '; tmp += '"isImportant": ' + tmpJson[i].isImportant + ', '; tmp += '"updatedAt": "' + tmpJson[i].updatedAt + '"'; tmp += '},'; }); tmp = tmp.substring(0, tmp.length - 1); tmp += ']'; console.log(tmp); response = tmp; Sorry for changing up the array but this is live code I am trying to work with. Console Log [{ "id": 35, "commentText": "Hello World.", "createdBy": "Lou", "isImportant": false, "createdAt": "2016-07-29T18:36:39.044Z", "updatedAt": "2016-07-29T18:36:39.044Z" }, { "id": 36, "commentText": "This is all starting to come together", "createdBy": "Mark", "isImportant": false, "createdAt": "2016-07-29T19:13:54.538Z", "updatedAt": "2016-07-29T19:13:54.538Z" }, { "id": 37, "commentText": "I'm pretending to be Lou", "createdBy": "Lou", "isImportant": false, "createdAt": "2016-07-29T19:14:41.130Z", "updatedAt": "2016-07-29T19:14:41.130Z" }, { "id": 41, "commentText": "testing 123", "createdBy": "Mark", "isImportant": false, "createdAt": "2016-07-29T19:21:35.637Z", "updatedAt": "2016-07-29T19:21:35.637Z" }, { "id": 42, "commentText": "testing123456", "createdBy": "Mark", "isImportant": false, "createdAt": "2016-07-29T19:22:42.516Z", "updatedAt": "2016-07-29T19:22:42.516Z" }, { "id": 44, "commentText": "This is not important", "createdBy": "Mark", "isImportant": false, "createdAt": "2016-07-29T19:33:54.805Z", "updatedAt": "2016-07-29T19:33:54.805Z" }, { "id": 51, "commentText": "New functionality", "createdBy": "Lou", "isImportant": true, "createdAt": "2016-08-03T14:38:54.724Z", "updatedAt": "2016-08-11T21:16:05.261Z" }, { "id": 92, "commentText": "Another test", "createdBy": "Lou", "isImportant": false, "createdAt": "2016-08-11T22:18:06.022Z", "updatedAt": "2016-08-11T22:18:06.022Z" }, { "id": 29, "commentText": "hot garbage 2.0", "createdBy": "Kevin", "isImportant": true, "createdAt": "2016-07-28T21:59:35.145Z", "updatedAt": "2016-08-04T21:41:16.361Z" }, { "id": 54, "commentText": "please work", "createdBy": "Dana", "isImportant": false, "createdAt": "2016-08-04T23:24:02.682Z", "updatedAt": "2016-08-04T23:24:02.682Z" }, { "id": 93, "commentText": "test comment", "createdBy": "mark", "isImportant": false, "createdAt": "2016-08-11T22:32:00.067Z", "updatedAt": "2016-08-11T22:32:00.067Z" }, { "id": 78, "commentText": "Testing modal dialog", "createdBy": "Lou", "isImportant": false, "createdAt": "2016-08-10T01:22:10.015Z", "updatedAt": "2016-08-10T01:22:10.015Z" }, { "id": 94, "commentText": "test comment", "createdBy": "mark", "isImportant": true, "createdAt": "2016-08-11T22:32:24.534Z", "updatedAt": "2016-08-11T22:32:24.534Z" }, { "id": 61, "commentText": "wooo", "createdBy": "yes", "isImportant": false, "createdAt": "2016-08-09T22:04:42.671Z", "updatedAt": "2016-08-11T15:51:51.448Z" }, { "id": 81, "commentText": "Deleted files. Just checking if it still works", "createdBy": "Mark", "isImportant": false, "createdAt": "2016-08-11T19:26:36.869Z", "updatedAt": "2016-08-11T19:26:36.869Z" }, { "id": 83, "commentText": "Trying it again", "createdBy": "Mark", "isImportant": false, "createdAt": "2016-08-11T20:29:41.439Z", "updatedAt": "2016-08-11T20:29:41.439Z" }, { "id": 107, "commentText": "New!", "createdBy": "Dana", "isImportant": false, "createdAt": "2016-08-11T23:03:50.597Z", "updatedAt": "2016-08-11T23:03:50.597Z" }, { "id": 112, "commentText": "One more time", "createdBy": "Dana", "isImportant": false, "createdAt": "2016-08-11T23:23:49.398Z", "updatedAt": "2016-08-11T23:23:49.398Z" }, { "id": 115, "commentText": "Try this", "createdBy": "Dana", "isImportant": false, "createdAt": "2016-08-11T23:32:54.382Z", "updatedAt": "2016-08-11T23:32:54.382Z" }] [{ "commentText": "Hello World.", "createdAt": "2016-07-29T18:36:39.044Z", "createdBy": "Lou", "id": 35, "isImportant": false, "updatedAt": "2016-07-29T18:36:39.044Z" }, { "commentText": "This is all starting to come together", "createdAt": "2016-07-29T19:13:54.538Z", "createdBy": "Mark", "id": 36, "isImportant": false, "updatedAt": "2016-07-29T19:13:54.538Z" }, { "commentText": "I'm pretending to be Lou", "createdAt": "2016-07-29T19:14:41.130Z", "createdBy": "Lou", "id": 37, "isImportant": false, "updatedAt": "2016-07-29T19:14:41.130Z" }, { "commentText": "testing 123", "createdAt": "2016-07-29T19:21:35.637Z", "createdBy": "Mark", "id": 41, "isImportant": false, "updatedAt": "2016-07-29T19:21:35.637Z" }, { "commentText": "testing123456", "createdAt": "2016-07-29T19:22:42.516Z", "createdBy": "Mark", "id": 42, "isImportant": false, "updatedAt": "2016-07-29T19:22:42.516Z" }, { "commentText": "This is not important", "createdAt": "2016-07-29T19:33:54.805Z", "createdBy": "Mark", "id": 44, "isImportant": false, "updatedAt": "2016-07-29T19:33:54.805Z" }, { "commentText": "New functionality", "createdAt": "2016-08-03T14:38:54.724Z", "createdBy": "Lou", "id": 51, "isImportant": true, "updatedAt": "2016-08-11T21:16:05.261Z" }, { "commentText": "Another test", "createdAt": "2016-08-11T22:18:06.022Z", "createdBy": "Lou", "id": 92, "isImportant": false, "updatedAt": "2016-08-11T22:18:06.022Z" }, { "commentText": "hot garbage 2.0", "createdAt": "2016-07-28T21:59:35.145Z", "createdBy": "Kevin", "id": 29, "isImportant": true, "updatedAt": "2016-08-04T21:41:16.361Z" }, { "commentText": "please work", "createdAt": "2016-08-04T23:24:02.682Z", "createdBy": "Dana", "id": 54, "isImportant": false, "updatedAt": "2016-08-04T23:24:02.682Z" }, { "commentText": "test comment", "createdAt": "2016-08-11T22:32:00.067Z", "createdBy": "mark", "id": 93, "isImportant": false, "updatedAt": "2016-08-11T22:32:00.067Z" }, { "commentText": "Testing modal dialog", "createdAt": "2016-08-10T01:22:10.015Z", "createdBy": "Lou", "id": 78, "isImportant": false, "updatedAt": "2016-08-10T01:22:10.015Z" }, { "commentText": "test comment", "createdAt": "2016-08-11T22:32:24.534Z", "createdBy": "mark", "id": 94, "isImportant": true, "updatedAt": "2016-08-11T22:32:24.534Z" }, { "commentText": "wooo", "createdAt": "2016-08-09T22:04:42.671Z", "createdBy": "yes", "id": 61, "isImportant": false, "updatedAt": "2016-08-11T15:51:51.448Z" }, { "commentText": "Deleted files. Just checking if it still works", "createdAt": "2016-08-11T19:26:36.869Z", "createdBy": "Mark", "id": 81, "isImportant": false, "updatedAt": "2016-08-11T19:26:36.869Z" }, { "commentText": "Trying it again", "createdAt": "2016-08-11T20:29:41.439Z", "createdBy": "Mark", "id": 83, "isImportant": false, "updatedAt": "2016-08-11T20:29:41.439Z" }, { "commentText": "New!", "createdAt": "2016-08-11T23:03:50.597Z", "createdBy": "Dana", "id": 107, "isImportant": false, "updatedAt": "2016-08-11T23:03:50.597Z" }, { "commentText": "One more time", "createdAt": "2016-08-11T23:23:49.398Z", "createdBy": "Dana", "id": 112, "isImportant": false, "updatedAt": "2016-08-11T23:23:49.398Z" }, { "commentText": "Try this", "createdAt": "2016-08-11T23:32:54.382Z", "createdBy": "Dana", "id": 115, "isImportant": false, "updatedAt": "2016-08-11T23:32:54.382Z" }]
  7. What I want to do is rebuild the jsonSample filtering out the isImportant false. So what is returned is: [ { "id":1, "commentText":"Hello World", "createdBy":"User2", "isImportant":true }, { "id":3, "commentText":"This is another one", "createdBy":"User2", "isImportant":true }, { "id":4, "commentText":"Hello World!", "createdBy":"User2", "isImportant":true } ]
  8. Hello All, I am stuck trying to filter results of a json response. I have a sample json response: [ { "id":0, "commentText":"Test", "createdBy":"User1", "isImportant":false }, { "id":1, "commentText":"Hello World", "createdBy":"User2", "isImportant":true }, { "id":2, "commentText":"Testing", "createdBy":"User2", "isImportant":false }, { "id":3, "commentText":"This is another one", "createdBy":"User2", "isImportant":true }, { "id":4, "commentText":"Hello World!", "createdBy":"User2", "isImportant":true } ] I am attempting to filter out results that "isImportant" are not true. I have tried multiple ways of doing it with no luck. IE. var response = $(jsonSample).filter(function (i,n){ return n.isImportant===true }); var response2 = $.grep(Object(jsonSample), function(j){ return j.isImportant !== false; }); var response3 = $.map(jsonSample, function (n,i){ $.each(n, function(j){ return n.isImportant !== false; }) }); console.log(response); //jquery-2.2.4.min.js:2 Uncaught Error: Syntax error, unrecognized expression: ... console.log(response2); //logs every individual character in the jsonSample ["[", "{", """, "i", "d", """, ":", "1", ... console.log(response3); //jquery-2.2.4.min.js:2 Uncaught TypeError: Cannot use 'in' operator to search for 'length' in ...
  9. that's what i figured. but the error log begs to differ.
  10. Hello All,I am working on a new project and getting an error that is driving me nuts.Error:PHP Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /../example.php on Line 215Here is my code around that line count. require '../SourceQuery/SourceQuery.class.php'; define('SQ_SERVER_ADDR', 'localhost');define('SQ_SERVER_PORT', 27015);define('SQ_TIMEOUT', 3);define('SQ_ENGINE', SourceQuery :: SOURCE); $ServerQuery = new SourceQuery(); $ServerInfo = Array(); try{ $ServerQuery->Connect(SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE); $ServerInfo = $ServerQuery->GetInfo();} catch(Exception $e){ $Exception = $e;} $ServerQuery->Disconnect();if($ServerInfo['Players'] > 0){ $output = "Failed to restart server. The Server is not empty."; mail($from, "Response: Restart", $output, 'From: noreply@domain.name' . "rn" . 'Reply-To: noreply@domain.name' . "rn" . 'X-Mailer: PHP/' . phpversion());} else { restartServer(); $output = "Server has been restarted. It Should be up shortly."; mail($from, "Response: Restart", $output, 'From: noreply@domain.name' . "rn" . 'Reply-To: noreply@domain.name' . "rn" . 'X-Mailer: PHP/' . phpversion());}Throughout my search this issue seems to come up around the quotations being incorrectly used. Most help posts were PHP MySQL related and they were not putting quotes around their string values. This does not appear to be the case. At least from what I can gather.Any insight would be grateful.
  11. dzhax

    Bootstrap Nav Vertical Align Text Bottom?

    Update: I have been playing around in chrome with different css on elements I have added .navbar{ min-height:150px;}.navbar-brand{ vertical-align:bottom;}.navbar-brand>img{ display:inline-block;} I am not keen on defining the height of the navbar manually but it works for now. So now the navbar is taller than my image, the title is on the same line, and the title is bottom aligned. I am still unable to get the navbar links to move down. If anyone knows a dynamic way to set the height of the navbar, and if anyone knows how to move the right navbar links to the bottom of the re-sized navbar please throw me a bone. I just realized that changing the min-height of the navbar bleeds over the content below. This is so frustrating.
  12. dzhax

    3 Divs Left Center Middle behaving wierdly

    you can also display: inline-block; to make them print on the same line.
  13. dzhax

    Rule @face font

    @font-face{ font-family:"Avenir-n; src: url('fonts/AEBL.ttf');}@font-face{ font-family:"Avenir;src: url('fonts/AEM.ttf');} That should work assuming your font files are not messed up. To be safe with browser compatibility, I normally use a service such as FontSquirrel to convert my fonts. Then I use css like Tezzo's first post and I have never had issues with it.
  14. dzhax

    Need help aligning divs next to each other with CSS

    #wrapper{ position:relative; max-width: 800px; min-width: 400px; margin-left: auto; margin-right: auto;} #top{ positon:absolute; top:0px; left:0px; right:0px; height:100px; background-color: green; line-height: 100px; text-align: center;} #left{ position:absolute; top:100px; left:0px; width: 150px; background-color: red; height: 800px;} #right{ position:absolute; top:100px; left:150px; right:0px; background-color: blue; height: 800px;} This works for me.
  15. dzhax

    How to position a text area field

    Can you post some of the HTML that makes up the form so we can better assist with a CSS Solution?
×