Prompt an input box in atom electron? - javascript

I am very new (couple of days) to HTML/JAVASCRIPT etc and I have started learning UI design with electron. I know how to create buttons and can handle what they do when pressed.
What I could not find is a way to input something in electron js.
For example I want an input field where I will type a number and a button next to it, that when clicked should save this number for other uses. In normal Javascript on a browser I know how to do this, in fact a simple "prompt" can also serve my purpose, but unfortunately even prompt doesn't work on electron ! What is the simplest way to achieve what I am trying to achieve here ?

Related

Hotlinks in JavaScript

I've been developing graphics in a graphics editor and I was able to add hot links to navigate through to different graphics, by entering the pathway to the graphic file. However there is now a new version of editor makes you publish the graphics online and view them from the web and the hotlink option is replaced with a button option. Instead of being able to enter the pathway of the graphic file I want to link to I have to enter a JavaScript script, that will run on click, and I have no clue how to get the JavaScript to work like the hotlink was working.
I have looked up tutorials on JavaScript but cant get any of the code to work on my button even simple things like alerts and prompts. If anyone has any idea how to these buttons work or if its possible for them to behave like the hotlinks from before that would be great.
Well it largely depends on your software, which you didn't mention here. However, if in the end it will be displayed in browser, you can try something like this:
For link, use javascript: alert('test'); and see if that gives you an alert box when you click it. If it does, problem solved.
If not, I am affraid you'll have to provide more information about your software before someone can offer some advice.

I want to add content from my website to the html permanently

I want to build a website in which users can add information, like craigslist. I want the website user to be able to click a button fill out a form and add another box. For instance, if there is a three by three grid and the user clicks on the add button, I want a form to appear, them to fill it out and one more box to be permanently added to the grid. Of course I could make it happen with Javascript and JQuery but it isn't permanent. Thanks:)
You can Implement this using server side languages like PHP /Node JS, ASP.net, Java, Ruby or you can use Local Storage of the browser (this gives limited storage capacity ). read this for more details. link
If you don't already know PHP, you will need to learn it for this. Also, you will need to make sure that you understand how to validate input because letting users add to your database can be a very dangerous thing to do if you don't understand how things like script injection works.

How to get text boxes to except text added through JavaScript (Twitch TV chat)

So, I am trying to write a simple command chat bot for Twitch.tv chat, but I cannot seem to be able to get it to actually submit the text I add. Although I can add text and "click" the send button with JavaScript, it will not actually submit it.
For example, I can use http://www.twitch.tv/example to test it. Apparently it is not good practice on Stack Overflow to link to sites, but I do not know what else to do. I cannot recreate the problem in JS Fiddle because I do not know exactly what the problem is.
I can get these elements to seemingly work by using the Chrome console:
//finding the textbox
var textbox = document.getElementsByClassName("chat_text_input mousetrap ember-view ember-text-area")[0];
//then assign some text to it.
textbox.value = "Hello, World.";
This works fine and the text appears.
//to send it I should merely find a way to click the "send" button
var send = document.getElementsByClassName("button primary float-right send-chat-button")[0];
send.click();
Well, this does not really work. It only actually submits the text if I physically either type or use a character (like shift) inside the textbox, or physically click the button myself. So, from what I understand there is some sort of event that is triggered when I physically type and click. Unfortunately, I do not understand how to find/trigger this event through the console. This is what I want to do.
Preferably I would like to do this in pure JavaScript, but I believe it may be simpler in jQuery. If it absolutely has to be jQuery that's OK and I will just have to suck it up and learn.
As a side note, I was able to successfully use this (with the elements changed of course), for YouTube live streaming chat. However, several other websites' chat react similarly to Twitch. These include web skype.
I've spent the last few hours poking around Ember and Javascript to figure this out. I too was running into an issue where I had to either click into the chat area or the send button itself.
I thought I had a lead with a script made for Twitch Plays Pokemon which would send preset messages into the chat. It used Jquery to input the value into the textarea and click on the send button, but that no longer works as Twitch now uses Emberjs 2
I am not too familiar with the Ember framework, but it seems Twitch utilizes a Textarea component(in Ember terms), which associates some framework specific API to the Textarea HTML element.
Since the Twitch webapp is written with Ember, it would seem that using vanilla javascript to set the value of the textbox would not notify the property change to whatever observers are registered internally to Ember
The workaround would then be to change the value property via Ember internal methods. Luckily poking around the views associated on the Textarea DOM element gives access to the set method.
http://www.ember-doc.com/classes/Ember.TextArea.html#method_set
Ember.view.views worked pre-Ember 2 but was deprecated and now requires lookup
App.__container__.lookup('-view-registry:main')[document.querySelector(".chat_text_input").id].set("value","test");
document.querySelector(".chat-interface__submit").click();

Programmatically trigger copy menu in iOS safari using javascript?

I'm trying to implement a user-friendly way to copy some text from a text input field to the clipboard on iOS/Safari. I understand there is no way to programmatically do it on this platform, but I was hoping I could guide the user experience as much as possible.
On iOS/Safari, when a user manually highlights some text, a contextual Copy menu pops up. I was hoping the same menu would pop up when the text is selected programmatically, but it doesn't. Is it even possible to do that?
If not, any advice on how to best implement a user-friendly experience to copy some text to the clipboard on iOS/Safari?
For reference, I'm selecting the text using the method described in this question:
Programmatically selecting text in an input field on iOS devices (mobile Safari)
It's not possible unfortunately. I'd include some informative text below the input, hopefully that will work out okay in terms of user-friendliness.
Another option would be to go native, e.g. by wrapping using PhoneGap, but I guess you are already well aware of that option. If so, something like this would work in native code:
[UIPasteboard generalPasteboard].string = #"your string";
From javascript it is possible with the help of iOS (objective C).
var getVal = $("#textid").val();
localStorage.setItem("getVal",getVal);
and then you can use your native code for getting this value from local storage.
I haven't knowledge of objective C but you can use that's method after js code.

How do I I create a simple javascript page, allowing the user to enter text & display it?

I took a web programming courses a while ago but I'm essentially relearning everything from scratch.
I just want to build a very simply page using html/javascript that has a box for the user to enter a question or a phrase and a submit button.
When the user presses the submit button, the question/phrase instantly shows up in a bubble below. Each question/phrase must show up in a separate bubble and you can enter multiple questions/phrases.
I'm looking for suggestions of ways to accomplish this task using javascript.
I suggest using jQuery, an awesome javascript library that makes things easier.
http://jquery.com/
They have great tutorials at http://docs.jquery.com/Tutorials
With ajax and forms at http://docs.jquery.com/Tutorials:Safer_Contact_Forms_Without_CAPTCHAs#Simple_Contact_Form:

Categories

Resources