JQuery :: Text Undo Redo Machanism Like Googledocs/MS Word
Sep 6, 2010
I find most rich internet text editors, developers put in the product many many features but fail to make a decent undo redo mechanism, I pressed crtl+z they deleted my whole paragraph. Unlike googledocs's one, it knows exactly what to undo.
If anyone can let me know what the logic of google docs/Ms word machanism is, maybe I can give it shot building one.
I'm working on an undo-redo function. Couldnt really find anything useful in the internet. So I have a try. Guess it could be quite useful for a lot of people out there.
Wonder if the concept is any good?
Please critizise hard! Try it out if you dare! Any feedback is welcome! All suggestions are appreciated!
Yours
Axinya
--> <html> <head> <style type="text/css"> <!-- #wisiwig { overflow: auto; position: relative; height: 300px; width: 600px; margin-top: 5px; padding: 5px; border: thin groove #999999; } --> </style> <script language="JavaScript"> <!-- var b_ackup = new Array(); //Store data in Array var undo_pos= 0;//Position of undo var flag = false;// shall we start new undo thread and delete obsolete items? var w_isiwig;//editor interface
} else{//write to backup array b_ackup[b_ackup.length] = w_isiwig.innerHTML; undo_pos = b_ackup.length - 1; flag = false; w_isiwig.focus(); } }
function undo(){
if (b_ackup.length){//
if(undo_pos==0){w_isiwig.focus();return;}// beginning of backup items
if(flag == false){BACKUP();}// save last state of document
w_isiwig.innerHTML=b_ackup[undo_pos -1];
undo_pos=undo_pos - 1;
flag = undo_pos +1;
look();
w_isiwig.focus(); } }
function redo(){ if(undo_pos == b_ackup.length -1){w_isiwig.focus();return;} //end of backup array
w_isiwig.innerHTML=b_ackup[undo_pos +1];
undo_pos=undo_pos + 1;
flag = undo_pos +1; look(); w_isiwig.focus();
}
function look(){// monitor our Array data var e='flag:'+flag+' undo_pos:'+undo_pos+' ' e+='b_ackup.length:'+b_ackup.length+' ' for (i=0; i<b_ackup.length; i++){
I am working on a UI that, when you click on a menu option, a div opens and show three divs inside. These divs all have different heights. The heights are based on the divs content.The problem I'm having is... how do I measure what the divs height should be? IE, how do I grab the height for a div BEFORE it has had any style applied to it.
I am using IE 6.0. On a page, I have placed a contenteditable div which I want to use as a Rich Text Area. I am using the execCommand method of the document to control bold, italics, underlining, and undo for this div.
I have placed an input element on the page to. All but the undo, are restricted to working only on the div. How can I restrict the undo to working on only the div?
Below is the complete page so you can see what I am talking about. Just paste it into an htm file and traverse to it via your browser. Type something in the div and the input and then try the buttons. Code:
I have a web form. I use a simple function to generate a letter ouput based on the form fields and populate them into a word doc for printing. Below is a basic example, but you get the idea.
Note this is only intended to be used on IE8. As it stands, the ouput generates and formats exactly as I want bar two things:
1) Does anyone know how I can get some of the text to bold? I've tried everything I can think of (html tags, escape characters etc etc). Is there a way to open a word window in rtf perhaps?
2) Does anyone know how I can insert a small image (a signature in gif or jpg) into the document?
I can use a browser window instead of word, which formats, bolds, images etc, however I then get the issue of headers/footers when printing. I cannot disable headers everytime I want to print a letter, it's not practical.
I have been practicing using canvas to make designs. My current code below will load the word the user inputs and makes it bounce around the canvas as well as a text spinner. However, whenever the user inputs a second word, the bounce below stops to start a new one and the text spinner messes up. so when the user inputs another word, that it either reloads a new textspinner or adds another one, as well as just add the word to the canvas without stopped the old one.
I have a long paragraph and I have been asked to display words in red and green in such a way that that fist word should be red, 2nd word should be green, 3rd word should be red and 4th word should be green and so on. For example: this is just a sample.
I am having no luck with my post form to mysql. It is only posting the first letter of the word/phrase for the text input fields to the mysql database. It is a photo and text post form. The photo and only first letter of text are posting to database. I am using Jqtouch, jquery, and phonegap.
I have a div with some content in it, within the content there's an anchor and when you click it all the content but the anchor itself should fadeTo('slow', 0.2);
Let me explain the issue which I'm facing with an example.My URL is http://localhost/~gaurav/dstreetmantra/register.php.One of the anchor tags in my navigation bar is <a href="register.php">Register</a>.The code needs to be able to check whether the value in this very anchor tag's href attribute is present in the URL.If it is present, the word 'Register' register would be highlighted. If not, some other link would be highlighted.As I said, I'm doing this for the navigation bar. This way, it'll check which of the links' 'href' value is present in the URL, and thus highlight that link.I'm assuming this can be done using Regex, but I do not know how to use it.
I have a client, let's call them "BuyNow." They would like for every instance of their name throughout the copy of their site to be stylized like "BuyNow," where the second half of their name is in bold.
I'd really hate to spend a day adding <strong> tags to all the copy. Is there a good way to do this using jQuery?
I am wanting to add a style (bold and blue for example) to every instance of a word or words on my website. Is this possible with jQuery? And how would I write it?
I'm trying to have a sentence change a single word every 2 seconds, and i have little experience using jQuery, but I'm trying, I've spent a while looking all over and the closest I came was to cycle through a list.[code]....
I'm trying to have only the word (blue) change to (red) after 2 seconds and then to (green) after 2 seconds, but all with either a scroll, or a fade in/out.
I'm wondering if anyone could point me in the right direction?
I'm using the Quicksearch plug-in and it does everything I need except for one thing. If I have two rows, for example: "Blood oranges" and "Green apples" And I search for "a", it's going to match both rows because it matches the "a" in "oranges". What I need to is to match only the beginning of each word, so that typing "a" in this case would only give me "Green apples". Is this possible?
If I have an 'dynamic' Div that sometimes contains the word Red or sometimes contains the word Green, i would like to replace (or something) the ID to something else.If the word inside the div is Green I need to use a green background, but if the word is red in the div, i need to have it in a red background.
Can method replaceWith() be used to replace just ONE WORD in body of a tag (i.e., element.html()?) with another word? I have li's with "tab one", "tab two", "tab three" etc.. I have to replace dynamically ONLY the word "tab" with another word..