OLE ERROR 805303E in delphi? - javascript

hello
I am testing a function to load an html code in a geckobrowser (gecko component in Delphi).
Here the function
procédure TCustomGeckoBrowser.LoadHTML (htmlCode: string);
var
domwindow: nsIDOMWindow;
domdoc: nsIDOMDocument;
domhtmldoc: nsIDOMHTMLDocument;
nsstr: IInterfacedString;
begin
domwindow: = GetContentWindow;
domdoc: = GetContentDocument;
domhtmldoc: = domdoc que nsIDOMHTMLDocument;
nsstr: = nouvelleChaine;
nsstr.Assign (htmlCode);
domhtmldoc.Write (nsstr.AString);
end;
but the programme show an error of type "OLE ERROR 805303E8". I traced execution and found that the problem is in the line: domhtmldoc.Write (nsstr.AString)
the function "write" is declared in the interface of my component:
nsIDOMHTMLDocument = interface(nsIDOMDocument)
procedure Writeln(const text: nsAString); safecall;
.....
end;
Have you encountered such an error?

I used a temporary solution that needs to create a temporary file and then load do with the gecko. but with this solution, I can not make a step backwards.
that's why I seek another solution that allows me to make change on the webpage.
thancks for your help

Related

Lunr: multilanguage setting needed also when loading an index?

I create and save my lunr index this way:
require("lunr-languages/lunr.stemmer.support")(lunr);
require("lunr-languages/lunr.multi")(lunr);
require("lunr-languages/lunr.it")(lunr);
const englishItalianSupport = lunr.multiLanguage("en", "it");
let fullTextIndex = lunr(function() {
this.use(englishItalianSupport);
this.pipeline.add(improvedTrimmer); // I think this does not matter
this.ref("id");
this.field("body");
this.metadataWhitelist = ["position"];
this.add({...});
...
}
Then I save it to be reused in the following sessions.
In the lunr-languages/README.md there is this line:
If you serialize the index and load it in another script, you'll have
to initialize the multi-language support in that script, too, like
this:
lunr.multiLanguage('en', 'it');
var idx = lunr.Index.load(serializedIndex);
Is this needed? This line generates the warning: Overwriting existing registered function: lunr-multi-trimmer-en-it. Remember, this warning was generated by the this.use() call during the index generation before moving it outside the lunr() call.
Also, should I reference my improvedTrimmer when loading the index? If yes, how?
Thanks for clarifying!

My JSLink script will not work

I am attempting to use JSLink ..finally.. and I am having some trouble that I cannot seem to straighten out. For my first venture down the rabbit hole I chose something super simple for use as proof of concept. So I looked up a tutorial and came up with a simple script to draw a box around the Title field of each entry and style the text. I cannot get this to work. Is there any chance you can take a look at this code for me? I used the following tokens in the JSLink box.
~sitecollection/site/folder/folder/file.js
And
~site/folder/folder/file.js
The .js file is stored on the same site as the List View WebPart I am attempting to modify. The list only has the default “Title” column.
(function () {
var overrideContext = {};
overrideContext.Templates = {};
overrideContext.Templates.Item = overrideTemplate;
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext);
}) ();
function overrideTemplate(ctx) {
return “<div style=’font-size:40px;border:solid 3px black;margin-bottom:6px;padding:4px;width:200px;’>” + ctx.CurrentItem.Title + “</div>”;
}
It looks as though you are attempting to override the context (ctx) item itself, where you actually just want to override the list field and the list view in which the field is displayed. Make sense?
Firstly, change overrideContext.Templates.Item to overrideContext.Templates.Fields :
(function () {
var overrideContext = {};
overrideContext.Templates = {};
overrideContext.Templates.Fields = {
// Add field and point it to your rendering function
"Title": { "View": overrideTemplate },
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext);
}) ();
Then when the JSLink runs the renderer looks for the Title field in the List view, and applies your overrideTemplate function.
function overrideTemplate(ctx) {
return “<div style=’font-size:40px;border:solid 3px black;margin-bottom:6px;padding:4px;width:200px;’>” + ctx.CurrentItem.Title + “</div>”;
}
In terms of running multiple JSLinks on a SharePoint page, it is quite possible to run multiple JSLink scripts, they just need to be separated by the pipe '|' symbol. I use SharePoint Online a lot and I see the following formatting working all the time (sorry Sascha!).
~site/yourassetfolder/yourfilename.js | ~site/yourassetfolder/anotherfilename.js
You can run as many scripts concurrently as you want, just keep separating them with the pipe. I've seen this on prem also, however you might want to swap out '~sites' for '~sitecollection' and make sure the js files you are accessing are at the top level site in the site collection if you do so!
I have noticed when running multiple JSLinks on a list or page because they are all doing Client Side Rendering, too many will slow your page down. If this happens, you might want to consider combining them into one JSLink script so that the server only has to call one file to return to the client to do all the rendering needed for your list.
Hope this helps.

What does "uncaught exception: out of memory" mean and how do you track the cause? [duplicate]

I am debugging a javascript/html5 web app that uses a lot of memory. Occasionally I get an error message in the console window saying
"uncaught exception: out of memory".
Is there a way for me to gracefully handle this error inside the app?
Ultimately I need to re-write parts of this to prevent this from happening in the first place.
You should calclulate size of your localStorage,
window.localStorage is full
as a solution is to try to add something
var localStorageSpace = function(){
var allStrings = '';
for(var key in window.localStorage){
if(window.localStorage.hasOwnProperty(key)){
allStrings += window.localStorage[key];
}
}
return allStrings ? 3 + ((allStrings.length*16)/(8*1024)) + ' KB' : 'Empty (0 KB)';
};
var storageIsFull = function () {
var size = localStorageSpace(); // old size
// try to add data
var er;
try {
window.localStorage.setItem("test-size", "1");
} catch(er) {}
// check if data added
var isFull = (size === localStorageSpace());
window.localStorage.removeItem("test-size");
return isFull;
}
I also got the same error message recently when working on a project having lots of JS and sending Json, but the solution which I found was to update input type="submit" attribute to input type="button". I know there are limitations of using input type="button"..> and the solution looks weird, but if your application has ajax with JS,Json data, you can give it a try. Thanks.
Faced the same problem in Firefox then later I came to know I was trying to reload a HTML page even before setting up some data into local-storage inside if loop. So you need to take care of that one and also check somewhere ID is repeating or not.
But same thing was working great in Chrome. Maybe Chrome is more Intelligent.

duino bleep code not running

I am trying to run the following nodejs code, based on the duino module found here: https://github.com/ecto/duino
bleep.js:
var arduino = require("duino");
var board = new arduino.Board();
var led = new arduino.Led({
board: board,
pin: 13
});
var bleep = function() {
led.on();
setTimeout(function() {
led.off();
}, 100);
}
setInterval( bleep, 1000 );
EDIT
Based on zmo's suggestion, I am now running du.ino (found under duino/src/) on my arduino board and bleep.js on my laptop.
Whilst compiling bleep.js, I get the following error:
Error: Cannot open /dev/
I was trying to trace back to where the path is being set.
I have traced this error to duino/node_modules/serialport/serialport.js
May I know how the following line (found in serialport.js) works?
function SerialPort(path, options, openImmediately, callback) {
Before this function is called on line 49, the 'path' variable is [object Object].
But after, it becomes /dev/
where does the change take place?
Thank you.
uhuh... where to start.
It looks like you're trying to compile your js code as an arduino sketch .ino files using the arduino ide. That can't work, it should be C++ code.

DocsList Functions Not Working in Sheets Script

I'm a beginner at this, so this error might be on account of faulty coding, but this is why I'm here! lol.
I have written a Sheets function that (in theory) would go through all the files in a particular folder and find all the instances of a particular word and then return the number of instances of that word. Here is the code I wrote:
function commentCount(name) {
var files = DocsList.getFolderById('FOLDER ID GOES HERE').getFiles();
var counter = 0;
for(i in files) {
var doc = DocumentApp.openById(files[i].getId());
var text = doc.getText();
text = text.replace( /\./g, "" );
var textArray = text.split(" ");
for(w in textArray){
if(textArray[w] == name){
counter++;
}
}
}
return counter;
}
When I call the function in Sheets, an error reads - Error: You do not have permission to call getFolderById (line 3, file "commentCount")
I've tried using getFolder("Folder name"), and getFolder(path), and the same error occurs. It seems that the DocList functions are not working correctly.
Not sure what the issue is because everything seems fine when I debug the function.
I won't be able to figure out if the rest of my code is sound until I figure out this error. Any help would be greatly appreciated!
Phil Bozak clarified that formulas in Spreadsheets that call scripts functions do not get full permissions, which makes it impossible to use getFolderByID function in this case.

Categories