In my .jslib file I have multiple functions which returns string. Instead of writing the lines that convert the value to string over and over again, I tried to put that code in another function, and call it from other functions whenever needed, but I am getting an error "ConvertToStr is not defined". I couldn't figure out how to do it in this context. Or is it not possible at all and every function needs to be standalone and they cannot "see" each other? I tried a couple of ways but failed to use ConvertToStr method from other methods.
var BrowserHelperPlugin =
{
ConvertToStr : function (thing)
{
var bufferSize = lengthBytesUTF8(thing) + 1;
var buffer = _malloc(bufferSize);
stringToUTF8(thing, buffer, bufferSize);
return buffer;
},
GetDocumentReferrer : function ()
{
var result;
result = document.referrer;
return ConvertToStr(result);
//var bufferSize = lengthBytesUTF8(result) + 1;
//var buffer = _malloc(bufferSize);
//stringToUTF8(result, buffer, bufferSize);
//return buffer;
},
GetDocumentLocationHost : function ()
{
var result;
result = document.location.host;
return ConvertToStrl(result);
//var bufferSize = lengthBytesUTF8(result) + 1;
//var buffer = _malloc(bufferSize);
//stringToUTF8(result, buffer, bufferSize);
//return buffer;
},
};
mergeInto(LibraryManager.library, BrowserHelperPlugin);
↧