Jump to content

Mad_Griffith

Members
  • Posts

    146
  • Joined

  • Last visited

Everything posted by Mad_Griffith

  1. Still stuck with this... don't know how to get those 2 variables out of the onLoad scope...
  2. On an app I am coding here: http://bit.ly/1Z7fajP
  3. I have a file input that reads a profile image. When the profile image is loaded the user can perform actions such as dragging and resizing (such functionalities are described in profileImgAnimation(). I need to pass those two variables, profileImgX and profileImgY, from the onload to the profileImgAnimation().
  4. Hi, yes. I cleaned up the code above, it should be clearer now.
  5. Hi, I don't understand how to pass the value of profileImgX and profileImgY to the spot indicated below: function drawProfileImg() { profileImg = new Image(); profileImg.onload = function() { profileImg.x = canvas.width - distanceFromRightSide - ((profileImg.width - 183) / 2); profileImg.y = canvas.height - distanceFromBottomSide - ((profileImg.height - 242) / 2); profileImgAnimation(); } } function profileImgAnimation() { setInterval(function() { // I would like to pass the value of profileImgX and profileImgY here context.drawImage(profileImg, profileImgX, profileImgY, profileImg.width, profileImg.height); } } Thank you
  6. I managed to have it working with the following: var canvasImg = canvas.toDataURL() $.ajax({ url: './twitter/twitter.php', type: 'POST', data: { canvasImg: canvasImg }, success: function(canvasImg) { console.log('success', canvasImg) $('#twitter').addClass('twitter-success'); setTimeout( function() { $('#twitter').removeClass('twitter-success'); }, 3000); } }); } <?php require "twitteroauth/autoload.php"; use Abraham\TwitterOAuth\TwitterOAuth; $connection = new TwitterOAuth('x', 'x', 'x', 'x'); $msg = 'My custom text here'; $media = $connection->upload('media/upload', ['media' => $_POST['canvasImg']]); $parameters = [ 'status' => $msg, 'media_ids' => $media->media_id_string ]; $result = $connection->post('statuses/update', $parameters); ?>
  7. I get this error when sending the data (it's a base64 canvas)... but data I am passing is there... <br /> <b>Warning</b>: file_get_contents(): Filename cannot be empty in <b>/web/htdocs/mywebsite.com/home/demos/projectname/twitter/twitteroauth/src/TwitterOAuth.php</b> on line <b>249</b><br />
  8. Hi all, I would like to understand how JS/jQuery can interact with PHP to upload a status and a picture from the HTML5 canvas to Twitter. I set up a similar thing for FB and it works. I don't get how to do it for Twitter and I haven't found much about it. Could you explain to me how it works? I currently have this JS/jQuery code as a starting point: var formData = new FormData(), mimetype = canvas.toDataURL().substring(canvas.toDataURL().lastIndexOf(":") + 1, canvas.toDataURL().lastIndexOf(";")), blob = dataURItoBlob(canvas.toDataURL().split(',')[1], mimetype); formData.append('source', blob); $('#twitter').click( function() { $.ajax({ url: '', type: 'POST', data: formData, processData: false, contentType: false, cache: false, success: function() { $('#twitter').addClass('twitter-success'); setTimeout( function() { $('#twitter').removeClass('twitter-success'); }, 3000); } }); } ); Thank you!
  9. Hey guys thanks a lot. As I was saying above, I am saving the values in variables, but for the purpose of letting you understand what I was doing in a shorter way, I omitted all the variables.
  10. I see your point, what would you suggest to do instead? thank you!
  11. Ok, I achieved something by creating a separate loop and adding it before the one shown in the code above: for (var i = 0; i < querySelectorAll('.tooltip').length; i++) { if (querySelectorAll('.tooltip')[i].contains(target)) { return false; } } Now return false works for both!
  12. Yes I am storing both in their own variable. I omitted the variables to shorten the code (thus explained the fact I left the "section" variable by mistake). The logic is I am manipulating the sections' CSS in the for loop (this part is in the code where // perform some stuff is, but again I omitted it to ease the reading) when the mouse wheel is used. But this manipulation shouldn't happen when I am mousewheeling on any of the tooltips (which happen to come in the same amount as the sections - could it be my mistake is actually here? using the same for loop for the sections and for the tooltips, even though all the tooltips belong to only one of the sections). No errors in JS! I've been running these tests: console.log('Tooltip ', querySelectorAll('.tooltip')[i], 'and target ', target) console.log('Tooltip contains target?', querySelectorAll('.tooltip')[i].contains(target)); console.log("Was preventDefault() called: " + e.defaultPrevented); And the second tooltip (the one that doesn't work) returns the same values as the first tooltip (that works correctly)
  13. I am trying to stop a mousewheel event from occurring when mousewheeling on a tooltip. Why something like this doesn't work (it only works on the first of the tooltips)... document.body.onwheel = function(e) { e = e || window.event; var target = e.target || e.srcElement; for (var i = 0; i < document.querySelectorAll('.searchPageSections').length; i++) { if (document.querySelectorAll('.tooltip')[i].contains(target)) { return false } // perform some stuff } }; But this does? document.body.onwheel = function(e) { e = e || window.event; var target = e.target || e.srcElement; if (document.querySelectorAll('.tooltip')[0].contains(target) || document.querySelectorAll('.tooltip')[1].contains(target)) { return false } for (var i = 0; i < document.querySelectorAll('.searchPageSections').length; i++) { // perform some stuff } }; Please note I am using return false because e.preventDefault() doesn't seem to work at all either!
  14. Thanks! I had it work with this nested loop, too for (var j in RegEx[i]) { return RegEx[i][j] }
  15. I don't get the notation I should use... I am doing some tests but I am stuck, e.g., at Object.keys(RegEx["tagClass"]) and cannot proceed...
  16. Ah, I see the second param should be a callback func. Is there any way to have the Object.values bit evaluated as a func? edit: @justsomeguy, thanks! Could you suggest an alternative solution?
  17. I don't seem to get my head around the reason why the following returns TypeError: Object.values is not a function var input = '[a docs/my_pdf.pdf|here§my_class#my_id][img imgs/myimg.jpg|Alt title][g Artificial Languages][lang]HTML, CSS, Sass, SMACSS, SVG[y]7[/y][/lang][/g][p]Yes[/p]'; var RegEx = { 'tagClass': { '\§\s*(.+?)\s*[\§\|\]\#]': ' class="$1"' }, 'tagId': { '\#\s*(.+?)\s*[\§\|\]\#]': ' id="$1"' }, 'tagAlt': { '\[img.+?\|\s*(.+?)\s*[\§\|\]\#]': ' alt="$1"' }, 'tagTitle': { '\[a.+?\|\s*(.+?)\s*[\§\|\]\#]': ' title="$1"' }, 'tagSrc': { '\[img\s*(.+?)\s*[\§\|\]\#]': ' src="$1"' }, 'tagHref': { '\[a\s*(.+?)\s*[\§\|\]\#]': ' href="$1"' }, 'tagAngleBrackets': { '\[(\/?)(.+?(?=[\]]))\]?': '<$1$2>' } }; for (var tag in RegEx) { input.replace(new RegExp(Object.keys(RegEx[tag])[0], 'g'), Object.values(RegEx[tag])[0]); }
  18. Hello, I am learning Angular and I am trying to create a more complex filter that replaces BBCode with the html tags, which works like this: {{app.text|BBCode}} With no parameter, show the text with the BBCode converted to HTML tags. {{app.otherText|BBCode:remove}} If parameter "remove" is specified, then actually strip BBCode from text. I use both at the same time in my html. This is the simple code, but it doesn't work: the first IF is skipped. When I log 'isRemoved' it shows up as 'undefined' for all the occurrences of the expressions, including those with the 'remove' parameter specified. portfolio.filter('BBCode', function() { return function(input, isRemoved) { input = input || ''; var output; if (angular.isDefined(isRemoved) && angular.equals(isRemoved, 'remove')) { output = input.replace(/\[(.*?)\]/g, ''); } else { output = input.replace(/\[(.*?)\]/g, '<$1>'); } return output; }; }); Thank you for your help!
  19. Could it be that the ajax URL is pointing to a Drupal .module file (which indeed contains PHP code)? edit: Ok justsomeguy, I will give it a try.
  20. The response is the content of the whole PHP file... how can I actually execute, through AJAX, a PHP function that is inside such PHP file?
  21. I redownloaded the db and it imported just fine... don't know what the issue was...
  22. The only occurrence of FOREIGN_KEY_CHECKS is actually: /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; What to do?
×
×
  • Create New...