This is actually a Coffeescript question. I don't think a Coffeescript thread exists, so this seems like the best place to ask. The Rails thread might be more appropriate. I'm building an account page with various tabbed navs that pull from our server using AJAX. I'm trying to make it kinda SPA-ey without actually introducing a whole framework, because it wouldn't fit with the rest of the site. Anyway I have a bunch of these ProfileTab sub classes that all have exactly the same `initialize` method. I tried to remove it and just keep it in the parent but ProfileTab doesn't know about the @render method of it's children. So I have a bunch of repetitive `def initialize return super(@render) end` methods smelling up my code. Any suggestions on ways to clean it up a bit? Here's the first twenty-five lines or so from my coffee file. CoffeeScript code:
|
|
# ? Jan 10, 2013 22:24 |
|
|
# ? Jun 8, 2024 07:41 |
|
A MIRACLE posted:I tried to remove it and just keep it in the parent but ProfileTab doesn't know about the @render method of it's children. CoffeeScript code:
|
# ? Jan 10, 2013 23:11 |
|
Can I use bookmarklets to fill out web forms that are themselves coded in javascript?
|
# ? Jan 11, 2013 20:08 |
Stoph posted:
Doing this oddly works for the VouchersTab class but breaks on OrdersTab, where the render method is undefined.
|
|
# ? Jan 11, 2013 20:19 |
|
gandlethorpe posted:Can I use bookmarklets to fill out web forms that are themselves coded in javascript? Yes
|
# ? Jan 11, 2013 20:29 |
|
Ok then, to expand, I'm trying to streamline data entry into a web-based database that has a JS interface. This particular database is for test subjects undergoing clinical trials. Here's the source for the first of many forms. It consists of three items. The first is a textbox (for initials), the second and third both consist of three dropdown boxes for entering dates. Since it's not html, I'm assuming document.getElementById isn't going to cut it. I need help deciphering all this to identify entry fields and populate them:code:
|
# ? Jan 11, 2013 20:48 |
|
gandlethorpe posted:Ok then, to expand, I'm trying to streamline data entry into a web-based database that has a JS interface. This particular database is for test subjects undergoing clinical trials. Here's the source for the first of many forms. It consists of three items. The first is a textbox (for initials), the second and third both consist of three dropdown boxes for entering dates. Since it's not html, I'm assuming document.getElementById isn't going to cut it. I need help deciphering all this to identify entry fields and populate them: Your code is obfuscated (I really, really hope so anyway), get the original source. If you don't have that what are you doing messing around with clinical trial data?
|
# ? Jan 11, 2013 21:39 |
|
Don't even try to do something based on that ofuscated piece of jibber jabber. Use your browser's development tools (Chrome: press F12, firefox: install firebug then F12, IE: install another browser since its devel tools are balls) and figure out a way to get at the inputs you want. Because filling in a form though js is primarily navigating the DOM tree I'd use jQuery to make that part way easier, but it's up to you.
|
# ? Jan 11, 2013 21:46 |
|
baquerd posted:Your code is obfuscated (I really, really hope so anyway), get the original source. If you don't have that what are you doing messing around with clinical trial data? The environment is created by an external company (Oracle Corp). My job, as a lowly data entry operator, is to assist with testing databases, usually by entering lots of test (fake) data. In the past, I've had to enter 100 identical subjects into a database, which I accomplished with a crude AutoHotkey script. I'd like to learn how to create a more sophisticated script. KARMA! posted:Don't even try to do something based on that ofuscated piece of jibber jabber. Use your browser's development tools (Chrome: press F12, firefox: install firebug then F12, IE: install another browser since its devel tools are balls) and figure out a way to get at the inputs you want. Might be tricky, since supposedly the interface is only supported by IE, although I think I was able to log in on Chrome in the past. Either way, I'll have to wait until I go home to try a different browser than IE. If I am able to, how would I go about de-obfuscating it?
|
# ? Jan 11, 2013 22:16 |
|
gandlethorpe, have you looked into iMacros? I've used it for some light automated form filling in the past, and it works well enough. There's an IE version.
|
# ? Jan 11, 2013 22:30 |
|
Sounds interesting, might give it a look. Can it work in the background (i.e. in a minimized browser)? Will the obfuscation be a problem?
|
# ? Jan 11, 2013 22:53 |
|
gandlethorpe posted:Sounds interesting, might give it a look. Can it work in the background (i.e. in a minimized browser)? Will the obfuscation be a problem? It works just fine when minimized, without any interaction. Just have it loop a macro however many hundred times. iMacros works directly with the DOM, so source obfuscation is no obstacle. The query language it uses to find elements is a little obtuse, but you don't need to write it yourself: instead, record yourself filling out the form then plug in the logic to load test data. It should just work as long as the form layout doesn't change too much.
|
# ? Jan 11, 2013 23:34 |
|
gandlethorpe posted:Since it's not html, I'm assuming document.getElementById isn't going to cut it. document.getElementById will work if the element has an id attribute. It doesn't matter if the element is created from html or dynamically through javascript.
|
# ? Jan 11, 2013 23:37 |
|
gandlethorpe posted:The environment is created by an external company (Oracle Corp). My job, as a lowly data entry operator, is to assist with testing databases, usually by entering lots of test (fake) data. In the past, I've had to enter 100 identical subjects into a database, which I accomplished with a crude AutoHotkey script. I'd like to learn how to create a more sophisticated script. Good! gandlethorpe posted:Might be tricky, since supposedly the interface is only supported by IE, although I think I was able to log in on Chrome in the past. Either way, I'll have to wait until I go home to try a different browser than IE. If I am able to, how would I go about de-obfuscating it? Don't worry about the existing javascript. Anything it does to change the site it has to go though the DOM (aka the site's structure), which your javascript has access to just the same. The biggest problem you're facing is viewing the DOM after the oracle js has its way with it. Doing a view > source just shows you the before picture, which is not useful in the least. IE's developer console is definitely the worst out of the bunch because it likes to go slow as balls and/or crash for no reason at all at random intervals, but it still enables you to view the DOM as it is right now. The HTML tab is where that information lies. The Console tab allows you to input (single) lines of javascript and see its results immediately. Also, if your external javascript has a console.log(PUT SOMETHING HERE); it will show its output in this tab. Very useful.
|
# ? Jan 12, 2013 00:13 |
|
Ironically, IE has the Javascript performance profiler with the most features.
|
# ? Jan 12, 2013 00:36 |
|
So it looks like I'm limited to IE7 or 8, but that's better than nothing. Please bear with me because I'm going to be asking a lot of newbie questions. Here's where I am so far (as well as a visual for what the page actually looks like): I used "Select element by click" to highlight the first textbox, which brought me to the highlighted part below. code:
Is this more on track to what I'm looking for? I'm guessing I can disregard all that script mess I posted before.
|
# ? Jan 14, 2013 05:27 |
|
All right, I figured out how to access and populate the form elements. Essentially, I'm navigating through the frames until I get to the element I want, then change the property. It's a lot easier than I first thought, even working with IE7's toolbar. To enter the initials, I did this: code:
Oh, and also how to make my code prettier and more professional. Since IE7's dev tool doesn't have a console, I'm just working in notepad then pasting my code into a bookmarklet. gandlethorpe fucked around with this message at 19:44 on Jan 14, 2013 |
# ? Jan 14, 2013 19:32 |
|
Dumb question: Do bookmarklets persist when loading a new page? If they don't, will I have to use some external script to run different bookmarklets for each page? So far, populating elements is pretty straightforward. The real annoying thing is that there are navigation and submission buttons I need to click often, and the only way I know how to access them is by their tag name A. Something tells me there's a more efficient method than counting each A element until I get to one I want.
|
# ? Jan 15, 2013 08:13 |
|
gandlethorpe posted:Dumb question: Do bookmarklets persist when loading a new page? If they don't, will I have to use some external script to run different bookmarklets for each page? What do you mean? Bookmarklets are short javascript snippets you run by selecting a bookmark in your browser. So in that case, they persist. Any variables you declare inside the bookmarklet do not persist, they will disappear when the page is reloaded. If you never cause the page to be reloaded, ou can use global variables to store data. If you want to store values between page loads, you can write them in a cookie and then read the value from the cookie when running your bookmarklet. gandlethorpe posted:So far, populating elements is pretty straightforward. The real annoying thing is that there are navigation and submission buttons I need to click often, and the only way I know how to access them is by their tag name A. Something tells me there's a more efficient method than counting each A element until I get to one I want. Probably not in IE7. With more modern browsers you might be able to use querySelectorAll / querySelector or even xpath. Or, if the page happens to be xml, you can use xpath in IE7 as well. You could try getting some parent element with first selecting some higher-level element with getElementById, then calling getElementsByTagName on that parent-element. so something like: JavaScript code:
|
# ? Jan 15, 2013 12:53 |
|
bartkusa posted:Ironically, IE has the Javascript performance profiler with the most features. IE also has built in deobfuscation/js formatting. F12 -> Script -> wrench looking icon -> "Format JavaScript"
|
# ? Jan 15, 2013 15:50 |
|
Factor Mystic posted:IE also has built in deobfuscation/js formatting. F12 -> Script -> wrench looking icon -> "Format JavaScript" Is this different than what's in Chrome?
|
# ? Jan 15, 2013 15:59 |
|
Wheany posted:What do you mean? One particular section of my project involves diary logs, which is just the same form done multiple times. I need to do 28 of those, so I have an array of strings for each log that determine how to fill out the form. There's a hub page that lists each completed form and has a button to start a new form, which loads a new page. I want to be able to start a new form, read the string to fill out the form, and submit (which brings me back to the hub page) then start the next form reading the next string, repeating until all the logs are done. Can I accomplish that using only one bookmarklet?
|
# ? Jan 15, 2013 16:49 |
|
gandlethorpe posted:One particular section of my project involves diary logs, which is just the same form done multiple times. I need to do 28 of those, so I have an array of strings for each log that determine how to fill out the form. There's a hub page that lists each completed form and has a button to start a new form, which loads a new page. I want to be able to start a new form, read the string to fill out the form, and submit (which brings me back to the hub page) then start the next form reading the next string, repeating until all the logs are done. Can I accomplish that using only one bookmarklet? I don't think so. That is more of a job for a user javascript, but for that you would need any other browser. User javascript runs automatically on page load, which means you could automate the process entirely. Does IE7 have a bookmarks toolbar built in? You could use that to simplify your task somewhat. Instead of having to open a menu to run your bookmarklet, you could just press a button on the toolbar. Also if you can add/replace an onclick handler on the hub page, you could append the current index in the array or even the data itself to be filled into the url of the form page, like so: "#firstname=John,initials=J.Q.P,lastname=Public" Then your bookmarklet could extract the data from the url (location.hash)
|
# ? Jan 15, 2013 17:53 |
|
I'm working on a Windows Store app the JS and I'm having problems with promises.code:
30 TO 50 FERAL HOG fucked around with this message at 18:35 on Jan 16, 2013 |
# ? Jan 16, 2013 18:32 |
|
Instead of ReturnValue = ResultOfAsyncAction; Try, thingImTryingToSet = ResultOfAsyncAction; Either thingImTryingToSet is a variable within scope or passed as a parameter. Blocking is a bad idea.
|
# ? Jan 16, 2013 18:49 |
|
It's gotta block. That action has to happen or the application might as well crash. There is no reason for the function to have even been written asyncronously, it will return the value in O(1) baring some catastrophic failure. In which case, go ahead and freeze up the UI. IDGAF
|
# ? Jan 16, 2013 18:56 |
|
That's not how async programming works. Your example is woefully incomplete and shows that you don't understand the concept, so more information about your actual problem would be appreciated.
|
# ? Jan 16, 2013 19:53 |
|
BiohazrD posted:I'm working on a Windows Store app the JS and I'm having problems with promises. code:
Stoph fucked around with this message at 00:18 on Jan 17, 2013 |
# ? Jan 17, 2013 00:12 |
|
If there's no synchronous API for what you're trying to do, the proper thing to do is to make your function asynchronous as well. There's nothing wrong with that, you just might need to restructure your code a little bit to accommodate it. There's generally no way in JavaScript to block execution while waiting for an asynchronous call to return.
|
# ? Jan 17, 2013 03:23 |
|
Asynchronous code can be a bit of a pain in the rear end, but that's how it is, so just get used to writing function (param, callback) all the time.
|
# ? Jan 17, 2013 13:41 |
|
Guess ill just have to rewrite a lot of code just for Windows 8. Win 7, Android, iOS required minimal changes. Good job, Microsoft.
|
# ? Jan 17, 2013 16:28 |
|
Uhhhh? You wrote an app for Windows 7, Android and iOS using JS? And it wasn't asynchronous?
|
# ? Jan 17, 2013 18:26 |
|
You could also, iunno, do an event emitter. When you have a result, listener.emit("TheshitIwaswaitingforisdone", results); then: code:
Wozbo fucked around with this message at 19:27 on Jan 17, 2013 |
# ? Jan 17, 2013 19:23 |
|
Suspicious Dish posted:Uhhhh? Of course it is. Just this one function in particular needs to be syncronous. WINJS is the only API that doesn't provide a syncronous method. Wozbo posted:You could also, iunno, do an event emitter. When you have a result, listener.emit("TheshitIwaswaitingforisdone", results); Oh my god. Not everything needs to be asyncronous. Do you write a thread and callback for every variable assignment? 30 TO 50 FERAL HOG fucked around with this message at 22:36 on Jan 17, 2013 |
# ? Jan 17, 2013 22:34 |
|
BiohazrD posted:Of course it is. Just this one function in particular needs to be syncronous. WINJS is the only API that doesn't provide a syncronous method. May I ask what function call this is? BiohazrD posted:Oh my god. Not everything needs to be asyncronous. Do you write a thread and callback for every variable assignment? The fact that you said "thread" there makes me think you don't understand the concept.
|
# ? Jan 17, 2013 22:42 |
|
Suspicious Dish posted:May I ask what function call this is? I'm not at work so I can't look at the code, and I don't remember off of the top of my head. I'm normally a C++/C# programmer. So when I think asyncronous programming, I think in threads. I am aware JS does not have threads.
|
# ? Jan 17, 2013 22:49 |
|
BiohazrD posted:I'm normally a C++/C# programmer. So when I think asyncronous programming, I think in threads. I am aware JS does not have threads. C# has async/await, which don't use threads either.
|
# ? Jan 17, 2013 22:57 |
|
Yeah but I usually don't use them in favor of threads or BackgroundWorkers if I'm doing something UI related.
|
# ? Jan 17, 2013 23:00 |
|
I pretty much async up everything (yes, everything). If you don't you risk being harvested/ manually stopped by whatever interpreter is running at the time (all of them can and will shut you down pretty fast).
|
# ? Jan 17, 2013 23:03 |
|
|
# ? Jun 8, 2024 07:41 |
|
Is there user script/bookmarklet thread? If not, is anyone else interested in such a thread?
|
# ? Jan 19, 2013 19:22 |