How to integrate ACE Code Editor to develop PHP Editor - code-editor

I am working on an e-learning website and developing code editors for php.
I just want it to be like the Code Editor of W3Schools "Try IT Now".
I want to enter the code in the left side and want to get output in the right side.
As per my analysis, "ACE Code Editor" is the best one for this task, but I am unable to integrate that in my website.
I am trying to explain my problem.
I have created two text area with same CSS property
One is hidden and one is visible
When user type code then both text area get the entered code.
Post getting the PHP code, it need to send to server using AJAX..
Now I am having problem with AJAX. I don't know how to send PHP code to server using Ajax and how to get output in return.
I take reference from here

Related

Pulling data into Excel from multiple pages

I’m currently trying to pull data from an internal website. However, a few challenges stand in my way. For clarity, I’ve attached a screenshot of the interface I’m working with. I’ve removed all of the text and added my own references for confidentiality purposes.
The data I need to pull is in Tab1 > TabD. I then apply a filter to it (not sure if that’s relevant here). In this example, there are 16 pages and it is these 16 pages of data (headers 1 to 5) that I need to pull into an excel sheet.
There’s no API for this and the page number doesn’t change in the URL so it can’t be used (to my knowledge).
With all these conditions, is this even feasible with VBA?
Thank you all for your time.
I WOULD just comment on this. But I don't have enough reputation to do so. Come on StackOverflow, I want to help people! I'll leave an answer instead, though I may need more information.
I am assuming this is done in Internet Explorer. In which case if you press Ctrl+U you can bring up the source for a page. Bring up the source to the page shown in your screenshot. You'll need to look for a javascript button that changes the page, which is the tricky part. The syntax for such a button in javascript looks like this:
<button onclick="functionToRun()">Button Text</button>
The button in the example above runs the function "functionToRun." Once you find the function that changes the page, insert it into the VBA line below, once you have IE properly initialized in your script:
Call IE.document.parentWindow.execScript("functionToRun()", "JavaScript")
The line above runs the JavaScript function in IE, effectively changing the page.

How to validate HTML Reports using Watir

We are trying to validate the HTML reports generated by our application. We have planned the below approach to do this
Capture that data related to the report from application
Generate the report
Identify the report’s elements and compare the data captured from application against the data/elements in report.
We started with identification of elements of the report and found that using 'Developers tool' we are able get some of the object properties where the Object ID is missing from these properties.
Can anyone please let us know the possibility of capturing the report elements and comparing them with the application data.
Frankly if you are just trying to parse HTML, and not trying to drive a browser, you'd probably be better off using something like Nokogiri, or another library aimed specifically at parsing HTML See https://www.ruby-toolbox.com/categories/html_parsing for a selection of such tools
Watir is 'Web Application Testing In Ruby" it is designed to drive web-browsers, in order to test websites and webapps. Validation that portions of the HTML are as expected is a part of that, but not the core functionality of Watir.
For what you are trying to do, if I understand you right, you could use watir to do that, in somewhat the same way you can use excel for word processing and page layout, which is to say it can be done, but may not be the most preferred tool or easiest way to go about it.

Web scraping from a Google Chrome extension

I've started to develop a Chrome extension to navigate and perform actions on a website. Until now the extension is able to receive a couple of parameters and check a set of radio-buttons, fill in a few inputs of a form and then submit it.
What I want to do now is to repeat the process, but I'm stuck when the page is reloaded. And I don't know how can I do to make the script react to the finish of the request.
The workflow I want to achieve is the following (is for automatically copying a certain object):
Popup side
Enter the number of the Master object to copy
Enter the base name of the copies (example Mod, so the I can iterate and add mod1, mod2, modn)
Enter the number of copies
Background side
Select master
Select standard options
Fill in inputs
Submit form
Wait for the page to complete the request and continue to the next copy. (here I need help)
The problem is on the repetition, the rest is taking care of. I assume that must be a way of dealing with requests. Any ideas?
By the way I'm doing it all with the extension and tabs methods of Google Chrome plus JavaScript and jQuery.
Ok, i´m going to answer the question myself based on Matthew Getner´s comment. The chrome.webRequest.onCompleted was the solution to the problem. With this method I was able to wait for the request to be completed and start over with the process. And with the messegaes methods I´ve achieved the comunication between the background and the extension itself. So I finally was able to filled a form, send it, and repeat. This way I´ve made a kind of robot to help a co-worker with a lame repetitive task on a aged web plataform.

How to add text to any html element?

I want to add text to body element but I don't know how. Which method will work on the body tag?
Sorry for my english and thanks for replies.
In Watir, you can manipulate a web page (DOM) using JS, just like that:
browser.execute_script("document.getElementById('pageContent').appendChild(document.createTextNode('Great Success!'));")
I assume that the point of the question is:
All users are not just interacting by just clicking buttons and links on the web app, some of them are doing nasty things like altering http requests to make your system do something that it is not supposed to do... or to just have some fun.
To mimic this behavior, you could write a ui-test that alters forms on the web page, so that for example, one could type in anything into any field instead of a limited dropdown.
To do that, ui test has to:
manipulate DOM to set form inputs free of limitations (replace select's with input's, etc.)
ui test has to know, which values to use, in many cases it's pointless to enter random values. Your webapp has to provide some good "unwanted" options.
Why would you want to modify the webpage in Watir? It's for automated testing, not DOM manipulation.
If you want to add something to the DOM element in javascript, you can do it like that:
var txt = document.createTextNode(" This text was added to the DIV.");
document.getElementById('myDiv').appendChild(txt);
Or use some DOM manipulation library, like jQuery.
If you have not worked your way though the watir tutorial, I would suggest you do so. It deals with things like filling in text fields etc.
Learn to use the developer tools for your browser, Firebug for Firefox, or the built in tools for IE and CHrome. They will let you look at things as you interact with the site.
If the element is not a normal HTML input field of some sort, then you are dealing with a custom control. Many exist and they are varied and there is no one set solution for dealing with them. Without knowing which control you are using, and being able ourselves to interact with a sample of it, or at least see the HTML, it is very very difficult to advise you, we basically have to just guess (which is often a waste of everyone's time)
Odds are if you have a place you can enter text, then it is some form of input control, it might not start out that way, you may need to click on some other element, to make the input area appear, but without a sample of HTML all we can do is guess.
If this is a commercial control, see if you can find a demo site that shows the control in action. Try googling things like class names for the elements and often you get lucky

One of X number of colums must contain data

HI all,
I am creating a timesheep app and I have five colums that can contain hours worked. When the user enters a new form how do I check to see if at least one of the columns contains data. I must admit I am not a developer just a Sharepoint/Sharepoint designer hack so be nice. Thanks
Glenn Thibeault
The only bullet-proof way would be to create a SharePoint event receiver using C# (lots of examples on the web).
I'm not really sure how you could accomplish this with SPD.
If you don't want to write any C# code, that really only leaves JavaScript. It will still take development work (this is a programming site after all). You could probably take advantage of SPUtility.js (full disclosure, this is a library I maintain).
The basic steps would be:
Edit your NewForm.aspx and add a Content Editor web part
Inside the Content Editor web part, write your JavaScript:
Attach a new onClick handler to the NewForm.aspx's "OK" buttons
Use SPUtility's GetValue method to get the value of your 5 fields, validate one has a value, and display a message if invalid

Resources