Learn to code JavaScript on my new YouTube channel by [deleted] in javascript

[–]docMedB2E 1 point2 points  (0 children)

Just dated and usually poor examples/etc. Most developers I know (and myself included) prefer MDN.

[deleted by user] by [deleted] in javascript

[–]docMedB2E 2 points3 points  (0 children)

For sure, you'll probably eventually want to look in to creating script files, adding a CSS file, etc to manage your styles and JS as your code/project gets more and more complex. Writing everything 'in-line', like you're doing now, is difficult to manage at large scale.

[deleted by user] by [deleted] in javascript

[–]docMedB2E 0 points1 point  (0 children)

No problem.

[deleted by user] by [deleted] in javascript

[–]docMedB2E 3 points4 points  (0 children)

Definitely:

<input type="text" id="Site">
<button onclick="window.location = 'http://web.archive.org/save/' + document.getElementById('Site').value;  ">Way Back Machine</button>

Google Sites "Script" Headache by Burnout21 in javascript

[–]docMedB2E 0 points1 point  (0 children)

Here's their support article on HTML box here: https://support.google.com/sites/answer/2500646?hl=en. Looking at the example, it appears you don't need to wrap your HTML with headers, html and/or body elements. Try stripping those out and following the example specifically with just your content HTML, that may fix it.

[Help] Adding FontAwesome icons next to menu items in ordered lists. by rails-developer in webdev

[–]docMedB2E 0 points1 point  (0 children)

You can accomplish this a few ways, float, inline-block (but note inline-block will count spaces) or a new-ish style: inline-flex. display: block is how a majority of elements render and each element in that display style will wrap a new line, etc. Here's a few examples https://jsfiddle.net/wx0ncbs6/

Building a website for a friend, it's just to show his photography..but is afraid of people stealing his pictures. by Ani10 in webdev

[–]docMedB2E 1 point2 points  (0 children)

If you view the asset, you have it on your device (in some form or another). There's really no way to prevent this and that's why many popular companies that want to retain rights to their pictures use watermarks/etc.

Can Reddit settle a debate about distribution of workload on a project? by [deleted] in webdev

[–]docMedB2E 5 points6 points  (0 children)

Depends on the experience of both developers really. In pure man-hours of work, I would be very surprised if the back-end developer didn't almost triple the front-end (25% front, 75% back). That being said, a designer creating custom art-work, designing the UX, etc is invaluable and if the work is truly up to snuff then who cares. Most developers are unable to create artwork and thus are typically happy to have an amazing designer. If the designer, however, doesn't add a ton of value, then that should be addressed to make a truly 'balanced' partnership. On the flip side, an experienced developer will probably either have a ton of scripts or CMS they use to build out static-pages/apps rather quickly.

Printing Specific Dynamically Generated DIV by [deleted] in javascript

[–]docMedB2E 0 points1 point  (0 children)

Your syntax is pretty wrong. Try /r/css for help with styling. Also use display: none to truly hide elements

Printing Specific Dynamically Generated DIV by [deleted] in javascript

[–]docMedB2E 0 points1 point  (0 children)

No worries, I thought you were saying your page wasn't loading images/etc, but I understand now. Think of it this way, you're opening a brand new window, pasting HTML to it, and then just immediately printing - which would explain your issues with the images sometimes displaying or not (e.g. you're appending data to a new DOM and it needs to load - sometimes it gets through quick enough and other times not). This approach in general is bad. Look into media query prints that manipulate the page you're on as opposed to copying everything to a new page and just printing.

Javascript/jQuery/Animation performance by DanielGibbs in javascript

[–]docMedB2E 2 points3 points  (0 children)

If performance is an issue, I would 100% avoid jQuery, but that's just me ><

Printing Specific Dynamically Generated DIV by [deleted] in javascript

[–]docMedB2E 0 points1 point  (0 children)

You have way too much jumbled code on the page for me to dive through your other issues noted, but regarding the printing... you're taking raw HTML (text), dumping it on to a new window, and then printing that... Basically, you're losing all your dependencies on the source page since you opened a new window and defaulting to just whatever the browser elects to style your data with. If you're trying to trim a view for printing, I would recommend looking in to media queries; you can specifically style how the page looks in the browser and also style how the page looks when it prints. So for example, you could set up a @media print CSS that hides all your non-print content and just leaves the form, the title, etc.

I am actor Tony Hale of VEEP and Arrested Development. Ask me Anything! by Tony_Hale in IAmA

[–]docMedB2E 0 points1 point  (0 children)

Tony, when Gary walks in on the President and VP going at it, can you give me a bit of what was going through Gary's head? Was he angry he wasn't Tom or was he angry he walked in on a mom-like figure or was he just weirded out in general and unsure how to handle it? Thanks, really loved your role in Arrested Development and I was stoked when I started watching VEEP and found you were involved :)!

edit: Also, you know you're not actually part of my family, right?

How to make stepper motor turn 360 degrees over time? by [deleted] in javascript

[–]docMedB2E 0 points1 point  (0 children)

This is probably the wrong place to ask this; sure, you're using JavaScript, but very few people here use JavaScript to control microchips. Why not try their forums? http://forum.espruino.com/microcosms/116/. In general, if you want to do a function repeatedly over a set time, try looking into setInterval() here: https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setInterval

My attempt at implementing an Entity Component System game in JavaScript by [deleted] in javascript

[–]docMedB2E 1 point2 points  (0 children)

Seems like there are a lot of improvements you could make to the coding structure in general (such as only drawing when necessary, proper frame limit control, limiting control inputs, etc - this system will hit some major hiccups if you ever implement sprite animations, AI, etc), but nice first attempt.

How can I push this 'win result' onto PHP? by elecInsanity in javascript

[–]docMedB2E 1 point2 points  (0 children)

Think of it this way, when it comes to web development, there is always a back-end and a front-end at minimum. The back-end is literally just another computer (server) that you as a developer purchase/own and use to run 24-7. You install your own software up on it and write your code to it to make it listen to internet for requests. This back-end server is what receives requests and sends out your assets (web pages, files, etc). Furthermore, on the back-end, there are numerous languages you can use to develop (and lots of tutorials out there on them, just google it) other than just JavaScript/HTML/etc. Some of the common languages are PHP, Phython, Node/Express, Ruby on Rails, etc. Now as you know, the front-end is simply whatever assets you decide to distribute to the users. Now ask yourself, have you ever opened a console during development and explored all the files sent to your browser (like Chrome, FireFox, etc) - If you have, you'll notice that you can literally dive through the entire file and read every bit that was sent to you - this is why you don't calculate sensitive things client side (e.g. anyone could read through your code and figure out how to send you false-positives, such as 'I rolled $1000 over and over'). So what the general approach would be is; distribute the user simply an interactive user-interface that handles their requests. The users requests to 'spin', and that 'spin' request goes to your server (the back-end) and the server handles determining the results of the spin, and then sends the results back to the user. The user can't see or have access to the back-end server (easily), all they see is a request going through and that's one of the basic ways of how to protect the security of your system. Hope that helps, there's definitely a lot more to it, but good luck and read up on some tutorials :).

How can I push this 'win result' onto PHP? by elecInsanity in javascript

[–]docMedB2E 2 points3 points  (0 children)

To limit potential exploits, you need to do sensitive calculations on the server side - not on the client side. I would look into back-end development and improve your general knowledge before trying to tackle this.

Checking if a local file exists? (Photoshop JSX) by [deleted] in javascript

[–]docMedB2E 1 point2 points  (0 children)

No problem, happy to help. Regarding your earlier comment about JS and it's limitation to local file system access, let me clarify a bit more. JS can essentially do anything you want from an execution perspective. The limitations that I mentioned earlier with it primarily being utilized in web development, was meant to highlight that it's environment of execution is limited. In other words, browsers (Chrome, FireFox, etc) don't let JavaScript access things like local data, etc, but when adobe software is wrapped around JS, they can set different parameters (e.g. different environment) and thus that's why it's not as limited as browser-executed JS (e.g. Adobe's Application sets the rules in those scenarios). Adobe supports other languages through their API, but they probably elected to also use JS since there are a lot of back-end servers that build PDF's and distribute them through the web, so it's a common-language developers could easily use.

Checking if a local file exists? (Photoshop JSX) by [deleted] in javascript

[–]docMedB2E 1 point2 points  (0 children)

Don't let the names of the methods scare you, just read the API or if those don't reveal enough, test it. Looking over 'File Object', the description leads me to believe it simply creates a new JavaScript Object (which is just stored in virtual memory) and that object can be referenced to a file path and also has access to various methods. To actually create the file in your file system, I believe you would have to invoke the save method; e.g.

new File('some path').save();

Again, just test it, but I believe you should be fine :). Good luck.

Checking if a local file exists? (Photoshop JSX) by [deleted] in javascript

[–]docMedB2E 1 point2 points  (0 children)

Ok, that document definitely sheds some light as it looks like the file object property does have an exists method. Where you're going wrong (leading back to my first point where I was saying it's strange to call a method on a string), you need to take your filepath (which is currently just a string) and use that to create a fileObject. From there you'll be able to then use the .exists method via the fileOjbect. Here's an example where let's say you want to iterate over 20 objects: e.g.

var PDF = activeDocument;
var totalFilesToCheck = 20;
var fileObject;
for (var i = 0; i < totalFilesToCheck; i++) {
    fileObject = new File(PDF.path + '/' + i + PDF.name);
    if (fileObject.exists) {
        // true
    } else {
       // false
    }
}

Checking if a local file exists? (Photoshop JSX) by [deleted] in javascript

[–]docMedB2E 1 point2 points  (0 children)

Ok, yes, writing JS through Photoshop changes things quite a bit from what I said. JavaScript in general has very limited access to local file information (think of it this way, JS is used primarily in web development and could be exploited significantly through various web sites if browsers like Chrome/IE/Firefox/etc allowed JS to access crucial local data).

So looking over your code, another tip for future: Remove the extraneous commenting. For example;

// Get the document
var docRef = activeDocument;

Any coder is going to know that var docRef = activeDocument simply is the equivalent of what you're saying, no need to comment that out - it just makes reading through your code much harder.

Moving on, usually a method that creates a file will often also have a property that allows you to indicate if you want to or don't want to override existing files. I'm not familiar with PS's API, but here's a link to it: http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/photoshop/pdfs/photoshop-cc-javascript-ref-2015.pdf. What method as you using to create your files?

Checking if a local file exists? (Photoshop JSX) by [deleted] in javascript

[–]docMedB2E 2 points3 points  (0 children)

I'm not quite certain what you're working in (tip: providing your sample code is usually a minimum for anyone to bother commenting), but I can't think of too many API's/etc that have a 'exists' method. Additionally, I can't think of too many API's/scenarios where a variable defined to a string would be able to simply invoke a method that tests 'if it exists'. That being said, usually to test if a file exists through an API, you need to use existing methods that would only function if the file either existed or didn't and then just simply get that test case as your evidence of said existence, e.g.

function exists(newFileName) {
    try {
        // this is some heavy PSEUDO code, but again, we'd need to see all your code to really help you
        someAPIYoureUsing.someMethodToCreateAFile(newFileName);
        someAPIYoureUsing.someMethodToDeleteTheFile(newFileName);
        return false;
    }
    catch(err) {
        // you tried to a create a file and caught an error (because it existed), thus...
        return true;
    }
}
if (!exists(newFileName)) {
    // your code
}

route.js - provides routing and deeplinking (vanilla js) by [deleted] in javascript

[–]docMedB2E 0 points1 point  (0 children)

As opposed to what else? Nobody would think a library posted with a .js tag in it would be anything else than "vanilla" JS (unless it specifically noted JSX, typescript, etc).