Posts

Share:

Create Simple Custom TextBox in HTML | Saatody | Amit Padhiyar

<div id="textbox" contenteditable="true">This is a paragraph. It is editable. Try to change this text.</div> <script> var textbox = document.getElementById("textbox"); textbox.addEventListener("keydown",function(event){ if(event.keyCode == 13){ var enterChar = String.fromCharCode(13); var regExp = new RegExp(enterChar,"g"); textbox.innerHTML = textbox.textContent.replace(regExp,""); } }); </script>

How to 'href' to the element even to the top margin of each div?

The following is html code I have written to store some of my favorite gradients and I wanted to link anchor to 'id="grad1"' and 'id="grad2"' even including the margin at the top. I thought the ':target:before' would work to provide the margin when those 'id's were targeted but that does not work for me somehow. When I link to the below html, it only links to the top of the content, not to the top of the margin of each div. we should add scroll-margin-top to each of your grads that is equal to the margin you apply. Example: #grad1 { margin-top: 200px; scroll-margin-top: 200px; } This way, anchors will scroll to the offset specified by the scroll-margin-top instead of the element border.

How do I check if an array includes a value in JavaScript?

What is the most concise and efficient way to find out if a JavaScript array contains a value? Modern browsers have Array#includes, which does exactly that and is widely supported by everyone except IE: console.log(['joe', 'jane', 'mary'].includes('jane')); //true You can also use Array#indexOf, which is less direct, but doesn't require polyfills for outdated browsers. Many frameworks also offer similar methods: jQuery: $.inArray(value, array, [fromIndex]) Underscore.js: _.contains(array, value) (also aliased as _.include and _.includes) Dojo Toolkit: dojo.indexOf(array, value, [fromIndex, findLast]) Prototype: array.indexOf(value) MooTools: array.indexOf(value) MochiKit: findValue(array, value) MS Ajax: array.indexOf(value) Ext: Ext.Array.contains(array, value) Lodash: _.includes(array, value, [from]) (is _.contains prior 4.0.0) Ramda: R.includes(value, array) Notice that some frameworks implement this as a function, while others add the function to

How to highlight a word in an HTML list form a string with JavaScript?

for(let i = 0; i < mostrarString.length; i++) { //break each sentence down to its own array of words let splitString = mostrarString[i].split(" "); let rebuiltString = ''; for(let j = 0; j < splitString.length; j++) { //if the word matches palabra variable and is the first occurrence in the sentence if(splitString[j] === palabra && splitString.indexOf(splitString[j]) === j){ //wrap it in a span tag rebuiltString += `<span style="color:red">${splitString[j]}</span>` } else { //otherwise add to new string as is rebuiltString += splitString[j] } //add a space except after last word if(i !== splitString.length - 1) { rebuiltString += " " } } const newItem = document.createElement('li'); //set the string as the innerhtml so the span tag renders newItem.innerHTML = rebuiltS

Find Rectangle Path WPF | Saatody | Amit Padhiyar

using Core.Converter; using Core.UI; using System.Collections.Generic; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Shapes; namespace Shape { public class PRectangle { public void CreateNewOne(Grid Parent) { Rectangle Rectangle = new Rectangle(); Rectangle.HorizontalAlignment = HorizontalAlignment.Stretch; Rectangle.VerticalAlignment = VerticalAlignment.Stretch; Rectangle.Margin = new Thickness(10, 10, 10, 10); Rectangle.Stroke = Brushes.Orange; Rectangle.StrokeThickness = 1; Parent.Children.Add(Rectangle); MyRectangle = Rectangle; Rectangle.Loaded += (sender, e) => { UpdatePoints(); }; CompositionTarget.Rendering += (sender, e) => { UpdatePoints(); //if (UIEvent.IsBusy == true) //{

Create Virtual RowView WPF | Saatody | Amit Padhiyar

XAML <Window x:Class="WpfApp23.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WpfApp23" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="3*"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <ScrollViewer Grid.Column="0

DevExpress DockLayoutManager

using DevExpress.Xpf.Docking; using DevExpress.Xpf.Layout.Core; using System.Windows; using System.Windows.Controls; using System.Windows.Media; namespace Saatody.Module.Startup { public partial class SaatodyApplication : Window { private StartPage StartPage = new StartPage(); public SaatodyApplication() { InitializeComponent(); Event(); } private LayoutGroup Root = new LayoutGroup(); private LayoutGroup LG = new LayoutGroup(); private DocumentGroup DG = new DocumentGroup(); private TabbedGroup TG = new TabbedGroup(); private LayoutPanel LP = new LayoutPanel(); private DocumentPanel DP = new DocumentPanel(); private DocumentPanel TDP = new DocumentPanel(); private LayoutPanel TP = new LayoutPanel(); private void Event() { Dock.ShowingDockHints += (sender, e) => { if ((e.DraggingSource).GetType() == typeof(Do