CKEditor : Defining Configuration in Page - javascript

I have a ASP.net user control with the below CKEditor
<%# Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>
<CKEditor:CKEditorControl ID="txtHtmlText" BasePath="~/Scripts/ckeditor/"
Toolbar="Bold|Italic|Underline|Strike|Subscript|Superscript|- |TextColor|BGColor|Font|FontSize
JustifyLeft|JustifyCenter|JustifyRight|Justify|-|Outdent|Indent|- |NumberedList|BulletedList
Cut|Copy|Paste|PasteText|PasteFromWord|-|HorizontalRule|Link|Unlink|- |Source|About"runat="server"></CKEditor:CKEditorControl>
I'm trying to override word count limit defined in config.js of CKEditor. I used the below code int the .ascx file and is getting the Error
"Uncaught ReferenceError: CKEDITOR is not defined". Please help
<script type="text/javascript">
CKEDITOR.replace('txtHtmlText',
{
wordcount: {
// Whether or not you want to show the Paragraphs Count
showParagraphs: false,
// Whether or not you want to show the Word Count
showWordCount: false,
// Whether or not you want to show the Char Count
showCharCount: true,
// Whether or not you want to count Spaces as Chars
countSpacesAsChars: false,
// Whether or not to include Html chars in the Char Count
countHTML: false,
// Maximum allowed Word Count, -1 is default for unlimited
maxWordCount: 500,
// Maximum allowed Char Count, -1 is default for unlimited
maxCharCount: 500
}
});
</script>

I tried today for my requirement and I was able to successfully add the feature.
If I would have been in your place, I would have checked couple of things
Is the reference to CKEditor is added (I know its obvious)
Add extraPlugins : 'wordcount', just above wordcount: {
Check developer console for any further investigation.
This link helped me solve my problem # https://github.com/w8tcha/CKEditor-WordCount-Plugin/blob/master/wordcount/samples/wordcountWithMaxCount.html

#Vinayak Prabha,
Try as suggested by Vikram. However a question ?
CKEditor ID "txtHtmlText" is server id, if you have to use in java script you should use client Id.
Try like this
var ckEditorClientID = "#<%=txtHtmlText.ClientID %>";
CKEDITOR.replace(ckEditorClientID,

Related

Pysimplegui is not changing application icon/taskbar icon

I am running a code with PYSIMPLEGUI, and I have followed all the instructions to set application icon but it seems to be not working, instead the the icon I see is python,
any suggestions?
below is my code:
###################### GUI
sg.theme('LightGrey1')
layout = [
[sg.Text("Input Serial:")],
[sg.Multiline(enter_submits=False,key='serial',size=(13,20))], # serial numbers
[sg.Text("Name outfile file:"),sg.Input(key='filename')],
[sg.CalendarButton("Date From:", format=('%m/%d/%Y')),sg.Input(key='datefrom',size=10)],
[sg.CalendarButton("Date To:",format=('%m/%d/%Y')),sg.Input(key='dateto',size=10)], # date from
[sg.FolderBrowse(button_text="Select Folder",key='file_save_path'),sg.Button("Save File")],# file name input
[sg.Button('Copy Command',button_color='#097969'), sg.Button('Exit',button_color='#9A2A2A')],
]
window = sg.Window('Name of Application',icon='interstate.ico',layout=layout)
window()
while True:
event, values = window.read()
print(event, values) # runs the window
if event in (None, 'Exit'):
break # if exit breaks
if event == 'Copy Command':
mile_state_command()
if event =="Save File":
file_creator()
'''
if event =='Copy':
copy()
'''
window.close()
Answer, I reserached but could not find

How can I make NextJS save my changes in VSCode?

I have tried changing all .js extensions to .jsx, enabled Prettier to format on save, set it as a default formatter, reloaded, restarted the editor, but saving is still not working. I would appreciate any ideas how to make this work.
Hit Control + Shift + P (On Mac you would want to hit the Command key instead of Control) and search for >Format Document With.... Check if that work.
If it works, then maybe your setting is overridden. Open your settings.json file (Use Control + ,, then on the top right corner you would see the open settings.json). Check the javascriptreact section.
Here is the example: this setting turns on formatOnSave for all the document type, but with .jsx extension, the formatOnSave is disabled, instead the files are formatted using eslint
{
// Other settings, don't mind it
// ...
"editor.formatOnSave": true,
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.formatOnSave": false
},
// Other settings, don't mind it
// ...
}
You may want to update the settings based on your need.

Odd Javascript behavior - porting to WordPress

I'm currently making my first effort into porting a webpage to Wordpress, so forgive my inexperience on the subject.
In my page, I have the following code:
function workLoad() {
$.ajaxSetup({ cache: false });
$('.thumb-unit').click(function() {
var $this = $(this),
newTitle = $this.find('strong').text(),
newFolder = $this.data('folder'),
spinner = 'Loading...',
newHTML = 'work/'+ newFolder +'.html';
$('.project-load').html(spinner).load(newHTML);
$('.project-title').text(newTitle);
});
}
In the past, this has worked fine hosted both locally and on Github. However, running my wordpress build locally through MAMP gives me the following error:
jquery-2.1.1.min.js:4 GET http://localhost/work/proj-1.html?_=1485348127113 404 (Not Found)
The URL should be fine, except for the part where it adds the ?_=(number). I'm not familiar with this behavior or what causes it. I tried changing work/ to /work/, since the dir is in the root folder, but that didn't solve it. I also have tried changing the variable to
newHTML = '< ?php bloginfo('template_directory')' + '/work/'+ newFolder +'.html';without the space after the opening bracket but to no avail. I also tried putting that bit in its own var, but it keeps adding ?_=1485348127113 to the URL of the html file I want to load, resulting in a 404 error.
What causes this? Thanks in advance for any advice you could share.
This timestamp is added for You to obtain the latest version of the file using ajax load.
If You want to disable this behaviour, You should set
$.ajaxSetup({
cache: true
});
This will enable caching and Your request would not contain the ?_=1485348127113 part anymore. This parameter should not cause the 404 not found error. Please check your path.

Javascript "value=..." returns blank page

Follow the following steps.
Steps 1:
Go to google.
Open the javascript console.
Enter the command: document.all.q.value = "hello"
As expected the element with a name of "q" (the search field) is set to "hello").
Steps 2:
Go to google.
In the address bar type javascript: document.all.q.value = "hello!"
Press Enter
If your browser is either Internet Explorer, or Google Chrome, the javascript will have replaced the google website with an entirely blank page, with the exception of the word "Hello".
Finally
Now that you've bugged out your browser, go back to Google.com and repeat Steps 1. You should receive an error message "Uncaught ReferenceError: document is not defined (...) VM83:1
Question:
Am I doing something wrong? And is there another method which works, while still using the address bar for JS input?
The purpose of a javascript: scheme URL is to generate a new page using JavaScript. Modifying the existing page with it is something of a hack.
document.all.q.value = "hello!"; evalues as "hello!", so when you visit that URL, a new HTML document consisting solely of the text hello! is generated and loaded in place of the existing page.
To avoid this: Make sure the JS does not return a string. You can do this by using void.
javascript:void(document.all.q.value = "hello!");
When messing around with javascript: in the adressbar some (if not the most) browsers handle it as a new page, so you have to add a window.history.back(); at the end
javascript: document.all.q.value = "hello!"; window.history.back();

Track error 404 on google analytics with javascript

I want to track on google analytics the 404 errors. Each time there is a 404 a specific part of my page has "404" string as content. So, I create a Universal analytics tag.
Then I create a custom javascript macro
function() {
var viewcontainer = document.getElementsByClassName("view-container");
var content = viewcontainer[0].childNodes[3].innerHTML;
var error404 = parseInt(content);
//if there is an error page it returns 404, else it returns NaN
return error404;
}
The macro reads the contents of the part of my page on which the 404 should appear and returns it. If it is an error it will return 404 otherwise it will return some other content.
Then I create a rule to fire the tag each time the macro is equals to 404
I create the version of google tags and publish it. Then by adding some random string on my url I can trigger a 404 error page. But on the google analytics nothing is tracked. Any idea what I am doing wrong? Is this the right way of using custom macros? Is there any problem on my macro or is something that I forget to do?
Add an additional condition to your rule, like {{event}} equals gtm.dom.

Categories

Resources