Edit the code in the opened tab - javascript

im doing a plugin to the cloud 9 sdk its basically a simple autocomplete for c language
my issue is that when i complete the name of the function the ide doesn't reserve the change meaning the next time he edit the line it will go back to before the line was edited
for example if i write pri then selected printf then pressed space it will be "pri " not "printf "
here is my code

modifying html inside ace won't work.
If you want to create a new completer, create a lnaguage handler
https://cloud9-sdk.readme.io/docs/customizing-code-completers
which will use built in completer popup

here is what i found
ace.scrollTo(row, column);
clipboard.clipboardData.setData("text/plain", "text to add");
clipboard.paste();
you will need to include clipboard and ace to consumes for that code to work

Related

wp editor settings array autosave function onchange

I'm trying to set up an autosave for dynamic wp editors in case my users forget to click save. (Currently set up with AJAX button to save.) Users can have 0 to 20 separate entries.
It seems that something should be added to the wp_editor settings array so it is added when tinymce is initialized. the The settings array is workinG. I can add or remove media buttons. However, I can't seem to get the right code inserted into the settings to get it to fire something when the active editor is changed.
Here is what I have.
$editorSettings =
array ( 'media_buttons' => false,
'resize' => false,
'wp_autoresize_on' => true,
'setup' => "function(ed) {
ed.onChange.add(function(ed, l) {
console.debug('Editor contents was modified. Contents: ' + l.content);
});
});"
);
Building editor with this code.
<?php wp_editor( stripslashes($j->journal_entry), 'journal-edit-'.$i , $editorSettings ); ?>
Ideally I would just run the AJAX save code I have already written. However, the change event does not appear to be firing.
Is this the best way to do this or should I create something outside of wp_editor functions. I can find lots of code to manually start tinymce and modify it but not when trying to go through Wordpress.
I've thought about setting up hidden fields to compare but this seems like a bad way to go. There should be some build in functionality to utilize instead of creating it from scratch.
Thank you for your help and suggestions!
So it looks like you do not want to do this through the settings array. Instead, add a filter to insert this code pre_init. The following code "clicks" a save button and prints to console on change event from tinymce in wordpress.
The setup js string needs to be minified or it will throw errors in console.
Add something like this to your functions.php file. NOTE: ' needed to be escaped in some of this code so it did not error out the functions file.
function mce_autosave_mod( $init ) {
$init['setup'] = 'function(a){a.on("change",function(b){jQuery(this).parent().find(\'#btnEditCharJournal\').trigger("click"),console.log("the event object ",b),console.log("the editor object ",a),console.log("the content ",a.getContent())})}';
return $init;
}
add_filter('tiny_mce_before_init', 'mce_autosave_mod');
All kinds of other code could be thrown in here. It is a good idea to also add logic to limit this to the specific editor on your site. You don't want this running for all of the instances of the editor.
If you have any suggestions to clean this up or do it a better way please let me know. I am fairly new to filters and wp_editor/tinymce.

Create a custom function for google sheets

I know it's possible to create a function in google sheets via the script editor, I used to be able to do it, now I'm struggling.
These functions should be accessible through a cell, and be able to use a cell.
How do I create a function, and how do I use it?
It's all described quite extensively in the docs:
https://developers.google.com/apps-script/guides/sheets/functions
To write a custom function:
function DOUBLE(input) {
return input * 2;
}
Create or open a spreadsheet in Google Sheets.
Select the menu item Tools > Script editor. If you are presented with a welcome screen, click Blank Project on the left to start a new project.
Delete any code in the script editor. For the DOUBLE function above, simply copy and paste the code into the script editor.
Select the menu item File > Save. Give the script project a name and click OK.
All done! Now you can use the custom function.
Using a custom function:
Click the cell where you want to use the function.
Type an equals sign (=) followed by the function name and any input value — for example, =DOUBLE(A1) — and press Enter.
The cell will momentarily display Loading..., then return the result.

Use code pasted in Chrome developer console to Auto Enter information in joomla form

I'm updating a bunch of Joomla sites and need to enter the same information through the admin console in each site. There are 25 individual fields in a specific module that need to be updated in each site. What I need is some type of code that I can paste into the developer console in Chrome that will fill in the 25 fields, each field holding different information.
Right now I copy and past text from a document into each of the 25 fields in the form. Very time consuming.
Not sure what type of code is easiest. Any help would be really appreciated.
The easiest way would not to copy and paste the code every time but to have the code in a javascript file on your server to add this code in a random page you can add a bookmark with the following content:
javascript:void(function(doc){
var s= document.createElement('script');
s.src='myrul';
document.head.appendChild(s);
})(document);
I've added whitespace so it's easier to read but this should be all on one line. The value for myurl should be the location of your script.
Your script can then make an XMLHttpRequest to the server that reads the parameters needed for the current page and sets them in the needed text boxes.
To start the script you can just open the bookmark when viewing the page.
[UPDATE]
As for the script to set the values of the inputs you can get all the inputs and set them with values from an array like so:
var myInputs=[0,1,2,3,5],//skip inputs[4] because it's a button
var myValues=["hello","how","are","you","today"];
inputs=document.getElementsByTagName("input"),i
for(i=0;i<myInputs.length;i++){
inputs[myInputs[i]].value=myValues[i];
}
//you can repeat this with textareas or checkboxes
//by re setting inputs: inputs=document.getElementsById("textarea");
//then re set values and if needed myInputs (if you need to skip some textareas)
You can use the JavaScript Console from Google Chrome.
Go on Chrome and Press the key sequence:
CTRL + SHIFT + J for Windows
or CMD + OPT + J for Mac.
Paste (CTRL + V) your code an press ENTER

How do I access changed (via GridDropDownListColumnEditor) values of a Telerik RadGrid server-side?

Details:
I'm basically trying to implement the functionality of the example here (http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/editondblclick/defaultvb.aspx) on my own site, but instead of using a data source control located in the page markup (like in the example: SessionDataSource), I'm using a dataset that I get from some server code-behind. I am able to successfully get my double-clicked row into edit mode with my dropdowns successfully populated, however when clicking onto another row to update the one in edit mode, no-dice.
I've discovered that apparently the client-side JavaScript function updateItem() does not initiate an AJAX callback like I originally thought, so I've been trying to work my way around that. Currently I'm using my RadAjaxManager to perform an AJAX callback with the row index number like so:
function RowClick(sender,eventArgs)
{
if(editedRow && hasChanges)
{
hasChanges = false;
$find("<%= RAM.ClientID %>").ajaxRequest(editedRow);
}
}
This gets me to my server code. Awesome. But,
Problem: I must be accessing something wrong, because the GridDataItem cell text that I'm trying to obtain for the edited row all has the value " ".
Dim gdi As GridDataItem = FieldOpsScheduler.Items(rowIndex)
Dim d As DateTime = DateTime.Parse(gdi.Item("EndDate").Text) //<--FAIL
I've been scouring the Internet for hours now trying to find how I can pull off what I'm trying to do, but to no avail.
Additional Info: I'm using GridDropDownListColumnEditors on the front-side to do the editing for my table, declared like so:
<telerik:GridDropDownListColumnEditor ID="ddlce_SunAct" runat="server" DropDownStyle-Width="60px"></telerik:GridDropDownListColumnEditor>
So does anybody have any ideas on what I have to do to access the values that have been changed in my RadGrid?? Is the problem that I somehow need to rebind my RadGrid when clicking on a new row? If so how do I do that? Any solutions or ideas would be greatly appreciated. (Also although I'm doing this in VB.NET, feel free to write responses in C# if you wish as I understand that too. :-) ) Thank you in advance.
With manual binding updateItem() should still raised the UpdateCommand server event of the grid, but you will have to update the grid source by hand. Modify the local version of the online demo where you Telerik AJAX controls installation is and go from there.
Dick
http://www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html
If anyone else has the same problem as I did, go to the above link and scroll down to the section titled "Accessing the value of cells in edit mode".

Using breakpoints to debug Javascript in IE and VS2008

I am not able to use the breakpoint in Studio with Javascript. I'm able to debug if I use the debugger;
I've seen this Breakpoint not hooked up when debugging in VS.Net 2005 question already. I tried the answer and it didn't work.
Looking in the Modules window, V.Mvc.Jobtrakt.PDB is loaded properly, but it points to a temp folder
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\dbc0c0c5\f64a99b3\assembly\dl3\9de055b3\eb1303b1_9760c901\V.Mvc.Jobtrak.pdb: Symbols loaded.
I would have thought that it would point to:
\JobTrak\Website\V.Mvc.Jobtrak\V.Mvc.Jobtrak\obj\Debug ( this is within the project directory)
But regardless of the location I closed VS 2008 and then blew away the temp folder (listed above), the bin and obj folders.
Opened VS 2008 and did a clean. I set a break point in the js and it seemed like it would work now ( The breakpoint was filled in)
Started to debug and it never breaks on the breakpoint. Look at the break point and it now is a red circle with a red dot and a warning indicator. Hovering over the breakpoint gives me this useful information: The breakpoint will not currently be hit. The location could not be mapped to a client side script. See help for ASPX Breakpoint mapping. I am not being redirected, the breakpoint is with in a function. blah blah blah this should be working.
So I was wondering if anyone has any ideas?
Is anyone able to set breakpoints in VS2008 and have them work?
try typing "debugger" in the source where you want to break
Make sure you are attached to the correct process. For example, once you have your page loaded in IE,
Switch to Visual Studio and go to the Debug menu.
Choose "Attach to Process"
Find iexplore in the list and select it.
Click the "Select..." button.
In the dialog, choose "Debug these code types:" and select only "Script".
Click "OK"
Click "Attach"
See if that helps get you debugging javascript.
this happened to me also. The breakpoints stopped to work in some functions. In my case, the problem was that I used <%=..%> inside the script. As far as I could figure out reading MSDN, this happens because Visual Studio maps the breakpoint lines from the .ASPX to the resulting HTML based on line content, so when you put a <%=..> your resulting script will be different from the one in the .ASPX file.
You shouldn't have to put debugger in the javascript. I had this happen and the reason was there was an error in the script in a try catch block in terms of syntax. As soon as I fixed the syntax, breakpoints mapped correctly again.
Greg answered the question, however just to add some more value to answer -
Put debugger in the java script code.
As well make sure you have debugger enabled in the internet explorer > Tools > Internet Options > Advance
the check boxes for disabled debugging should not be checked.
In my case, was due I was using
$.ajax({
type: "GET",
instead
$.ajax({
type: "POST",...
Just type alert function in script for each line or any line, if the alert is not triggered then we can identify the line where its through the error
<script type="text/javascript">
$(function() {
//event handler to the checkbox selection change event
$("input[type=checkbox]").change(function() {
//variables to store the total price of selected rows
//and to hold the reference to the current checkbox control
var totalPrice = 0, ctlPrice;
//iterate through all the rows of the gridview
$('#Grid2 tr').each(function() {
//if the checkbox in that rows is checked, add price to our total proce
alert("Hi")
if ($(this).find('input:checkbox').attr("checked")) {
ctlPrice = $(this).find('[id$= lblPackAmount]');
//since it is a currency column, we need to remove the $ sign and then convert it
//to a number before adding it to the total
totalPrice += parseFloat(ctlPrice.text().replace(/[^\d\.]/g, ''));
}
});
//finally set the total price (rounded to 2 decimals) to the total paragraph control.
//alert(totalPrice);
$('#lblAmount').text(totalPrice);
});
});
</script>

Categories

Resources