Search Results

Search found 18 results on 1 pages for 'sonofdelphi'.

Page 1/1 | 1 

  • ContentEditable DIV - disabling drag and drop

    - by sonofdelphi
    Is it possible to disable the drag-and-drop functionality on elements which have the contentEditable attribute set to true. I have the following HTML page. <!DOCTYPE html> <html><meta charset="utf-8"><head><title>ContentEditable</title></head> <body> <div contenteditable="true">This is editable content</div> <span>This is not editable content</span> <img src="bookmark.png" title="Click to do foo" onclick= "foo()"> </span> </body> </html> The main problem I'm facing is that it is possible to drag and drop the image into the DIV and it gets copied (along with the title and the click handler)

    Read the article

  • Writing UTF8 text to file

    - by sonofdelphi
    I am using the following function to save text to a file (on IE-8 w/ActiveX). function saveFile(strFullPath, strContent) { var fso = new ActiveXObject( "Scripting.FileSystemObject" ); var flOutput = fso.CreateTextFile( strFullPath, true ); //true for overwrite flOutput.Write( strContent ); flOutput.Close(); } The code works fine if the text is fully Latin-9 but when the text contains even a single UTF-8 encoded character, the write fails. The ActiveX FileSystemObject does not support UTF-8, it seems. I tried UTF-16 encoding the text first but the result was garbled. What is a workaround?

    Read the article

  • Editing Div Text At Click Position

    - by sonofdelphi
    I have a DIV which contains some text. When a user clicks on some content in the DIV, I want to enable him to edit the content at that position. <div id='Note'> Lorem ipsum dolor sit amet, consectetur adipisicing elit, <br /> sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. <br /> Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip <br /> ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse <br /> cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, <br /> sunt in culpa qui officia deserunt mollit anim id est laborum.<br /> </div>

    Read the article

  • Disable JavaScript on window.open

    - by sonofdelphi
    I have a set of (X)HTML files that I need to open with window.open() from an application homepage. I am able to open these files and read the data within them. function openFiles() { var files = document.querySelectorAll('td a'); //The list of files to scan is stored as links in an HTML table for(var i = 0; i<files.length; i++){ //Open each file in a browser window win = window.open(files[i].href); //Can I prevent the JavaScript in these files from executing? } } But the problem is that the scripts within the HTML files also get executed when opened like this. This is rather time-consuming and unnecessary; also, the scripts within those files may have side-effects. Is there a way to prevent JavaScript from executing on load?

    Read the article

  • Accelerator UI in JavaScript

    - by sonofdelphi
    Can I create something like an Internet Explorer accelerator using JavaScript on the client-side? I want a clickable icon to show up when the user selects some text on the page. What is the event I should wait on?

    Read the article

  • Ordering DOM elements

    - by sonofdelphi
    Given two DOM elements, say a and b, how can we determine which comes first in the document? I'm implementing drag and drop for a set of elements. And the elements can be selected in any order, but when they are dragged, these elements need to be moved in the "correct" order.

    Read the article

  • jQuery internals: Organization of the jQuery Object

    - by sonofdelphi
    I was going through the source code of jQuery. I'm having trouble understanding the wrapping strategy for the jQuery object. (function( window, undefined ) { // Define a local copy of jQuery var jQuery = function( selector, context ) { // The jQuery object is actually just the init constructor 'enhanced' return new jQuery.fn.init( selector, context ); }, .... .... .... // Expose jQuery to the global object window.jQuery = window.$ = jQuery; })(window); Specifically, what I'm not able to understand stems from the first line. What is the outermost unnamed container function? Why is it required? Why is the container function anonymous? What is the need for the outermost '(' parantheses ?

    Read the article

  • Collect DOM elements from external HTML documents

    - by sonofdelphi
    I am trying to write a report-generator to collect user-comments from a list of external HTML files. User-comments are wrapped in < span elements. Can this be done using JavaScript? Here's my attempt: function generateCommentReport() { var files = document.querySelectorAll('td a'); //Files to scan are links in an HTML table var outputWindow = window.open(); //Output browser window for report for(var i = 0; i<files.length; i++){ //Open each file in a browser window win = window.open(); win.location.href = files[i].href; //Scan opened window for 'comment's comments = win.document.getElementsByName('comment'); for(var j=0;j<comments.length;j++){ //Add to output report outputWindow.document.write(comment[i].innerHTML); } } }

    Read the article

  • accessing and modifying tab opened using window.open in google chrome

    - by sonofdelphi
    I used to be able to this to create an exported HTML page containing some data. But the code is not working with the latest version of Google Chrome (It works alright with Chrome 5.0.307.11 beta and all other major browsers). function createExport(text) { var target = window.open(); target.title = 'Memonaut - Exported View'; target.document.open(); target.document.write(text); target.document.close(); } Chrome now complains that the domains don't match and disallows the Javascript calls as unsafe. How can I access and modify the document of a newly opened browser-tab in such a scenario?

    Read the article

  • Detecting regular expression in content during parse

    - by sonofdelphi
    I am writing a parser for C. I was just running it with some other language files (for fun, to see the extent C-likeness). It breaks down if the code being parsed contains regular expressions... Case 1: For example, while parsing the JavaScript code snippet, var phone="(304)434-5454" phone=phone.replace(/[\(\)-]/g, "") //Returns "3044345454" (removes "(", ")", and "-") The '(', '[' etc get matched as starters of new scopes, which may never be closed. Case 2: And, for the Perl code snippet, # Replace backslashes with two forward slashes # Any character can be used to delimit the regex $FILE_PATH =~ s@\\@//@g; The // gets matched as a comment... How can I detect a regular expression within the content text of a "C-like" program-file?

    Read the article

  • Reading long lines from text file

    - by sonofdelphi
    I am using the following code for reading lines from a text-file. What is the best method for handling the case where the line is greater than the limit SIZE_MAX_LINE? void TextFileReader::read(string inFilename) { ifstream xInFile(inFilename.c_str()); if(!xInFile){ return; } char acLine[SIZE_MAX_LINE + 1]; while(xInFile){ xInFile.getline(acLine, SIZE_MAX_LINE); if(xInFile){ m_sStream.append(acLine); //Appending read line to string } } xInFile.close(); }

    Read the article

  • Determining the order of DOM elements

    - by sonofdelphi
    Given two DOM elements, say a and b, how can we determine which comes first in the document? I'm implementing drag and drop for a set of elements. And the elements can be selected in any order, but when they are dragged, these elements need to be moved in the "correct" order.

    Read the article

  • Undo implementation - DOM manipulations

    - by sonofdelphi
    Is there a library that can be used for implementing undo/redo functionality for DOM element manipulations in JavaScript? I'm writing an app that moves around DOM elements, enables editing and deletion of those elements. There are event-handlers and other objects associated with each element operated upon. Not sure whether I need to roll my own implementation of the Command pattern for this. Surely, there must be something available? If not, suggestions and pointers would be a great help.

    Read the article

  • C++ map performance - Linux (30 sec) vs Windows (30 mins) !!!

    - by sonofdelphi
    I need to process a list of files. The processing action should not be repeated for the same file. The code I am using for this is - using namespace std; vector<File*> gInputFileList; //Can contain duplicates, File has member sFilename map<string, File*> gProcessedFileList; //Using map to avoid linear search costs void processFile(File* pFile) { File* pProcessedFile = gProcessedFileList[pFile->sFilename]; if(pProcessedFile != NULL) return; //Already processed foo(pFile); //foo() is the action to do for each file gProcessedFileList[pFile->sFilename] = pFile; } void main() { size_t n= gInputFileList.size(); //Using array syntax (iterator syntax also gives identical performance) for(size_t i=0; i<n; i++){ processFile(gInputFileList[i]); } } The code works correctly, but... My problem is that when the input size is 1000, it takes 30 minutes - HALF AN HOUR - on Windows/Visual Studio 2008 Express (both Debug and Release builds). For the same input, it takes only 40 seconds to run on Linux/gcc! What could be the problem? The action foo() takes only a very short time to execute, when used separately. Should I be using something like vector::reserve for the map?

    Read the article

  • How do I read long lines from a text file in C++?

    - by sonofdelphi
    I am using the following code for reading lines from a text-file. What is the best method for handling the case where the line is greater than the limit SIZE_MAX_LINE? void TextFileReader::read(string inFilename) { ifstream xInFile(inFilename.c_str()); if(!xInFile){ return; } char acLine[SIZE_MAX_LINE + 1]; while(xInFile){ xInFile.getline(acLine, SIZE_MAX_LINE); if(xInFile){ m_sStream.append(acLine); //Appending read line to string } } xInFile.close(); }

    Read the article

  • Thread-safe get (accessor method)

    - by sonofdelphi
    I'm currently using the following code for thread-safe access of a variable. int gnVariable; void getVariableValue(int *pnValue) { acquireLock(); //Acquires the protection mechanism *pnValue = gnVariable; releaseLock(); //Releasing the protection mechanism } I would like to change my API signature to a more user-friendly int getVariableValue(void); How should I rewrite the function - such that the users of the API don't have to bother about the locking/unlocking details?

    Read the article

1