I'm not a developer myself and even though html and css are kinda familiar to me, php and more advanced languages are not so please bear with me 😉
I want to have a simple html page (or php or whatever is necessary for this case) with 2 text fields and a button
What I want is to paste text into Field 1 and when I hit the Convert button, it will convert certain characters and show it in Field 2.
Example: I paste "I wanna go for a walk in the park" in Field 1. Hit Convert and Field 2 will show me "I w#nn# go for # w#lk in the p#rk"
(I know this is a silly example, but just so you can understand what I want to achieve).
I just need it to convert 1 single character at this point, so basically there's only 1 "variable".
Hope it makes and you guys can help me with it.
Thanks and stay safe!
Tiago 😊
html file
<input id="input_data" type="text">
<button id="convert">Convert</button>
<div>
<h1>Output</h1>
<p id="output"></p>
</div>
<script type="text/javascript">
document.getElementById("convert").onclick = function(){
var input = document.getElementById("input_data").value;
// your choice
var convert_from = "a";
var convert_to = "o";
var finalString = (input.split(convert_from.toUpperCase()).join(convert_to.toUpperCase())).split(convert_from).join(convert_to);
document.getElementById("output").textContent = finalString;
copyToClipboard(finalString);
}
// You can copy some text to clipboard only by selecting an element
function copyToClipboard(content){
// Create a textarea
var textHolder = document.createElement('textarea');
// Assign the value
textHolder.value = content;
// Appent the textarea to body
document.body.appendChild(textHolder);
// "Focus the action" on the textHolder
textHolder.select();
textHolder.setSelectionRange(0, 99999); /*For mobile devices*/
// Copy the content from selected element
document.execCommand('copy');
// Remove the textarea from body
document.body.removeChild(textHolder);
}
</script>
I hope it helps! ^_&
Related
Apologies for another question re this, but I've tried so hard to get this working (I'm fairly new to SharePoint, don't have extensive coding knowledge, but know HTML and generally alright at trouble shooting).
We are using SharePoint online and we have SharePoint Tiles. We have recently added a few more tiles and it's obviously not wrapping these tiles, thus having to scroll right to access some.
I have found the code for wrapping the tiles here and when editing the page source, it appears to be working... until I save it. The code I put in is stripped out when I next go to the content editor.
I've read a few pages on it and have tried things such as the content editor web part, but for the life of me cannot get it to work.
If anyone would know if there's a step to step guide to ensure wrapped tiles are saved, I may be able to get it to work.
Any help is greatly appreciated.
If it changes anything, we use SharePoint online that is part of our Office 365 account.
Add the following code into script editor web part in the page.
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
// Update this value to the number of links you want to show per row
var numberOfLinksPerRow = 6;
// local variables
var pre = "<tr><td><div class='ms-promlink-body' id='promlink_row_";
var post = "'></div></td></tr>";
var numberOfLinksInCurrentRow = numberOfLinksPerRow;
var currentRow = 1
// find the number of promoted links we're displaying
var numberOfPromotedLinks = $('.ms-promlink-body > .ms-tileview-tile-root').length;
// if we have more links then we want in a row, let's continue
if (numberOfPromotedLinks > numberOfLinksPerRow) {
// we don't need the header anymore, no cycling through links
$('.ms-promlink-root > .ms-promlink-header').empty();
// let's iterate through all the links after the maximum displayed link
for (i = numberOfLinksPerRow + 1; i <= numberOfPromotedLinks; i++) {
// if we're reached the maximum number of links to show per row, add a new row
// this happens the first time, with the values set initially
if (numberOfLinksInCurrentRow == numberOfLinksPerRow) {
// i just want the 2nd row to
currentRow++;
// create a new row of links
$('.ms-promlink-root > table > tbody:last').append(pre + currentRow + post);
// reset the number of links for the current row
numberOfLinksInCurrentRow = 0;
}
// move the Nth (numberOfLinksPerRow + 1) div to the current table row
$('#promlink_row_' + currentRow).append($('.ms-promlink-body > .ms-tileview-tile-root:eq(' + (numberOfLinksPerRow) + ')'));
// increment the number of links in the current row
numberOfLinksInCurrentRow++;
}
}
});
</script>
We can also use CSS style below in script editor web part in the page to achieve it.
<style>
.ms-promlink-body {
width: 960px;
}
</style>
I have a task here when I need some assistance. what I am trying to accomplish is the follow..
Hide some fields on the newform, editform and dispform with in SharePoint (2013)
The field I am trying to hide is ONLY the input/textbox field not the whole column/heading associated with it. Basically I have a form with a heading and an associated textbox(single line of text) next to it, what I would like to do is hide the textbox only.
I have used the F12 IE tools to select the text box to which displays the following souce code:
<input title="Travel" class="ms-long ms-spellcheck-true" id="Travel_f6801fb9-c4ff-4109-acb9-f7dd63c1d98a_$TextField" type="text" maxlength="255" value="">
(the textbox is associated with my "Travel" column)
Now when I use the F12 tools while selecting this, I added some css(from that I can tell) under the "inline Style" top heading which was "display=none" and bingo it works!.
Now what I cant do here is add this to the forms permanently. I have tried to google this by adding a Content web part to the form and try some CSS/Java script but I simply do not have the skills in this area.. does this make sense?
examples:
any help would be great
Cheers!
In SharePoint 2013 was introduced Client Side Rendering (aka CSR) which is used for rendering list views, list forms and search results. For a more details follow SharePoint 2013 Client Side Rendering: List Forms article.
The following JavaScript template demonstrates how to hide field controls in List Form pages:
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
OnPostRender: hideFieldControls
});
});
function getFieldControlId(field){
return field.Name + '_' + field.Id + '_$' + field.Type + 'Field';
}
function hideFieldControl(field){
var fieldControlId = getFieldControlId(field);
var fieldControl = document.getElementById(fieldControlId);
fieldControl.style.display = "none";
}
function hideFieldControls(ctx){
var fieldNamesToHide = ['JobTitle','WorkPhone']; //<- set field names to hide here
if(fieldNamesToHide.indexOf(ctx.ListSchema.Field[0].Name) > -1) {
hideFieldControl(ctx.ListSchema.Field[0]);
}
}
How to apply changes
Open List Form page in edit mode
Add Script Editor web part on the page
Insert the specified JavaScript template by enclosing it using
script tag Note: specify field names to hide via fieldNamesToHide variable
Save page
Results
Pic 1. Original New Form page
Pic. 2 Customized New Form (field controls for Job Title and Business Phone are hidden)
As the title says, I need to list the content of all child-pages on the parent-page, after its own content. Or the thing I really need is, one page with content and and a menu which links to the different headers of the content. e.g. athe parent-page with content:
**Parent Head**
parent text
*first subhead*
first subtext
*second subhead*
second subtext
and the menu should look like:
Parent
-first subhead
-second subhead
I thought it would be easier if the parent-page "collects" the content of the child-pages.
The other solution was, that the child-pages would be links to extern URLs, to the specific c-IDs of the different contents of the parent-page. But I think this isn't that easy for the website owner, who doesn't know anything about where he can find the right c-ID in the web-page-source-code.
So how would You make that? Or how can I realize the thing with the child-page-content?
EDIT: Have a solution now. Just have to fix, that the submenu will be displayed without childpages.
Here is the code:
temp.contentnav = CONTENT
temp.contentnav {
table = tt_content
select {
pidInList = 7
orderBy = sorting
where = colPos=0
languageField=sys_language_uid
}
renderObj = TEXT
renderObj {
field = header
wrap= <li>|</li>
typolink.parameter.field=pid
typolink.parameter.dataWrap=|#{field:uid}
typolink.ATagParams = class="linkClass"
if.isTrue.field=header
}
wrap = <ul id="submenuClass"> | </ul>
}
page.10.marks.MENU.2.NO.after.cObject < temp.contentnav
Try something like this
temp.pageIds = HMENU
temp.pageIds.entryLevel = 1
temp.pageIds.1 = TMENU
temp.pageIds.1 {
NO.stdWrap.field = uid
NO.allWrap = |,
NO.doNotLinkIt = 1
}
lib.container = CONTENT
lib.container.table = tt_content
lib.container.select {
pidInList.cObject < temp.pageIds
}
There is a content element "Menu/Sitemap" with has an option to render subpages with content.
If you want to do it via TypoScript, render the menu, and then replace the menu items with content of them.
# Pseudocode on menuitem
# assuming you are using css_styled_content
1.allStdWrap.cObject < styles.content.get
# Set pid for CONTENT object from styles.content.get to the uid of the page
# which gets rendered
1.allStdWrap.cObject.select.pidInList.data = uid
Can't provide you with an working snippets atm.
How to change attr width on object, I'm trying with this, but seems does not work...
jQuery('.big').click(function(){
jQuery('#flvPlayer').attr("width", "100");
});
Here is code where I need change height and width on click
<a class="big">100</a>
<textarea><object id="flvPlayer" height="665" width="425"></object></textarea>
Use .css instead of .attr.
jQuery('.big').click(function(){
jQuery('#flvPlayer').css("width", "100");
});
width is a CSS property.
Edit: In textarea you have text. Your <object> is not a HTML element. It is text in your text area.
So, just change the text in textarea.
$('.big').click(function(){
var text = "<object id=\"flvPlayer\" height=\"665\" width=\"100\"></object>"
$("textarea").val(text);
});
Also, I suggest you to use $ instead of jQuery. It's easier and faster to write.
I've been playing around with this for a couple of weeks now with no success...
In a CKEditor dialog, text input fields are renamed with a unique number - e.g. id: 'txtUrl' will become something like id='27_textinput'.
How do I reference this?
// I feel it should be something like:
var myfield = CKEDITOR.instances.myElement.document.$.body.getId('txtUrl');
// or maybe:
var myfield = CKEDITOR.dialog.getContentElement('info','txtUrl');
// and then:
myfield.value = 'myvalue';
But these don't work. Please help! Thanks in advance, R
This was the final solution:
var dialog = CKEDITOR.dialog.getCurrent();
dialog.setValueOf('info','txtUrl',"http://google.com");
return false;
within an onchange part of an element I now use
dialog = this.getDialog();
alert(dialog.getContentElement('info', 'grootte').getInputElement().$.id);
and it gives 'cke_117_select' as a result. (It's a selectbox)
alert(dialog.getContentElement('info', 'txtUrl').getInputElement().$.id);
gives 'cke_107_textInput'.
I think this is what you (or other visitors to this page) are looking for.
You have a page containing the CKEditor 3 and a dialog pop up. You open from this dialog, another pop up window, that is a JSP page. In order to set a value to a field in the dialog of CKEditor's parent window, you do the following:
window.opener.CKEDITOR.dialog.getCurrent().getContentElement('dialogTabId', 'dialogTabFieldId').setValue('yourValue');
This applies to CKEditor 3.
Look at the api dialog sample:
// Get a reference to the "Link Info" tab.
var infoTab = dialogDefinition.getContents( 'info' );
// Set the default value for the URL field.
var urlField = infoTab.get( 'url' );
urlField['default'] = 'www.example.com';
get
var ckValue = CKEDITOR.instances['txtUrl'].getData();
and set
CKEDITOR.instances['txtUrl'].setData(ckValue);