|
Once again, there may not be an image extension. You will have to use the content type.
It looks like it is possible to request extra permissions to your extension to bypass CORS restrictions for certain domains:
permissions - Mozilla | MDN[^]
But it may be easier to intercept the network requests from your extension:
Intercept HTTP requests - Mozilla | MDN[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: But it may be easier to intercept the network requests from your extension:
Intercept HTTP requests - Mozilla | MDN[^]
I'll try this and see if I manage to make something using it. I first thought this whole thing will be something easy. 
|
|
|
|
|
Hello all,
I would like to ask you for a help. I would like make a function for add a class. For interactive map. It means there will be a few segments and ONCLICK will be ADD CLASS.
I used this code:
function myFunction() {
document.getElementById("praha").className = "show";
} It works, but only for 1st segment.
I would like to use something like OR. I tried this:
function myFunction() {
document.getElementById("praha").className = "show"; ||
document.getElementById("stredniCechy").className = "show";
} or
function myFunction() {
document.getElementById("praha"||"stredniCechy").className = "show";
} But both of them doesnt works... Could someone give me an advice and help me with it ?
Many thanks
|
|
|
|
|
Those statements do not make sense, as there is no condition test. You first need to add a test to decid which one is required, somthing like:
eltname = (<condition test goes here>) ? "praha" : "stredniCechy";
document.getElementById(eltname).className = "show";
The condition test is whatever you use to decide which name to use.
|
|
|
|
|
Hi, I've created a small library for declaring Maps, WeakMaps or maps-like arrays. Maybe someone will find it useful.
https://www.npmjs.com/package/jsman
https://github.com/mothgears/jsman
|
|
|
|
|
This is a Javascript based Q&A forum. In case you want to share your work, would suggest you to submit it as Your GitHub Project on CodeProject with details about how it is useful and can be used. Follow the guidelines and submit, it will showcase as other articles for people to read.
With current message, most will not be able find what you want to share and will be lost. Thanks!
|
|
|
|
|
This alghoritm i want to use to create shape for cnc foam cutter ... so a one line need to pass all countour paths
for example:
i have 4 path with x,y points coordonates
path1=[[5,3][3,2][8,9][8,8][7,3]]
path2=[[1,9][8,4][3,6]]
path3=[[8,3][4,7][1,2][2,7][4,2][7,5]]
path4=[[4,3][1,7][9,7][8,0]]
Alghoritm need to find in primis a most low value apropriate to 0 in this case [1,2] that is in path3 point 3
After find this point...compare all points of path3 with points of all paths and find most appropiate value ... in this case [8,4] from path2 that is closest to [8,2] from path3
after find most apropiate value ...join the path3 with path 2 in pointers find
result_path=[[0,0]->[1,2][2,7][4,2][7,5]->[8,3]->[8,4][3,6]->[1,9]->[4,7]]
And after join path2 with path3 in this mode ... compare all points of result_path with points of remainder paths (path1,path4) ... and insert path find in result_path in same mode
I dont know how explain better!
|
|
|
|
|
Is this a Javascript question or are you just looking for a generic algorithm? If the latter then please use the correct forum at Algorithms Discussion Boards[^].
|
|
|
|
|
i put this post also in algoritms ... but ... message closed!!!
|
|
|
|
|
You should post it in one place only.
|
|
|
|
|
I am trying to make an add-on for Mozilla Firefox that will convert an image (from a given direct link) to another format and then give the user the save file pop-up.
I have tried to use JavaScript to turn the image into a canvas, and then the canvas to an image with the format wanted, but I run into the problem with canvas.toDataURL, that doesn't allow to use an image from another origin, and I get Uncaught DOMException: The operation is insecure. How else can I do this image conversion? I know it is possible to do it, because there are other add-ons that do this, but my add-on will have other specific functions for our work beside only image conversion, and we can't use those because of that.
I'm doing the testing in straight HTML, because it is easier to do it this way, then keep refreshing the add-on in browser.
Here is the code:
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
</head>
<body>
<script>
window.onload = function() {
var image = new Image();
image.addEventListener("load", imageLoaded, false);
image.src = "theLinkToAnImage";
};
function imageLoaded() {
var canvas = document.createElement("canvas");
canvas.width = this.width;
canvas.height = this.height;
canvas.getContext("2d").drawImage(this, 0, 0);
var image = new Image();
image.crossOrigin = "Anonymous";
image.src = canvas.toDataURL("image/jpg");
document.body.appendChild(image);
}
</script>
</body>
</html>
modified 27-Oct-20 6:59am.
|
|
|
|
|
Thank you for taking the time to review my question.
I am using Google Maps API and custom JScript to be able to calculate snow loads in Tahoe Basin.
This all works as expected except for one county...El Dorado, which does not work and I have not been able to isolate the issue.
Working Page Here: http:
***NOTE: works perfectly except for Eldorado County (South Shore Lake Tahoe) Click and you will see this error:
ERROR: The address provided appears to be in El_Dorado County county (only Placer, Washoe, Nevada, El Dorado, and Douglas counties are supported)
This is the catch-all error for when someone clicks outside of the supported area.
I can upload the JScript file if helpful...
Thanks Again, I am stumped as to how to address this error. matt
|
|
|
|
|
I'm trying to read multiple matching values of an xpath expression from an xml file in an array in Nashorn Javascript. I'm using javax.xml.xpath classes inside Nashorn to parse xml data. I'm able to read the first matching value just fine when I pass, XPathConstants.STRING to the evaluate function.
alist = xpath.evaluate(exp, input, XPathConstants.NODESET); System.out.println(alist.item[0].getNodeValue());
Its throwing this error - javax.script.ScriptException: TypeError: Cannot read property "getNodeValue" from undefined in
Any ideas why the list would have all null valued elements?
|
|
|
|
|
That sounds more like Java than Javascript. And the error message is telling you that alist is most likely null because the evaluate call did not return anything.
|
|
|
|
|
Yes. I'm using Java inside Nashorn Javascript. Here's my xml and xpath.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <triggers count="1"> <trigger id="TRIGGER_6" type="buildDependencyTrigger"> <properties count="2"> <property name="branchFilter" value="+:<default>"/> <property name="dependsOn" value="Project1_BuildConfig1"/> </properties> </trigger> <trigger id="TRIGGER_7" type="buildDependencyTrigger"> <properties count="2"> <property name="branchFilter" value="+:<default>"/> <property name="dependsOn" value="Project1_BuildConfig1"/> </properties> </trigger> </triggers>
/triggers/trigger[@type='buildDependencyTrigger']/properties/property[@name='dependsOn']/@value
As I mentioned, when I use XPathConstants.STRING, I do get the value from the first 'trigger' node with same xpath.
modified 25-Oct-20 12:21pm.
|
|
|
|
|
shampoo72 wrote: Not sure why You need to use your debugger to try and find out.
|
|
|
|
|
Issue was item[0]. Needs to be item(0). 
|
|
|
|
|
Please note that I am no way a experienced programmer. So, I am using webrtc to create webm videos. This works fine. Now I need to convert the webm files to MP4 so they can be viewed from a webpage. I assume I have to get the file to the server then do the convert there using ffmpeg. I manually put a webm file on the server and ran the ffmpeg via the cli and it works to create an mp4. I now need to automate this process. The webm files that will be created can be quite large. Some > 100mb. I am using RecordRTC.js for recording and creating the blob.
Any ideas how I can accomplish this?
Note that the html and javascript for the webrtc is located on the same machine as the node server, if that makes any difference.
Appreciate your response as I am really racking my brain trying to figure this out.
Ray
|
|
|
|
|
I searched around on this, and can't figure out what the module is.
I wrote this for that PHP project. A file called js_undefinedValue.js. The idea is to write my undefined value to local storage and read it back when I need it.
Overall, I can't reference and use the functions.
ReferenceError: writeUndefinedValue is not defined
export class UndefinedValue {
projectNumber;
variableContingencyValue;
actualCost;
varibleContingencyCost;
actualPlusContingencyCost;
}
export function writeUndefinedValue(projectNumber, variConRate, actualCost, variConCost, actualPlusCost) {
let uVo = new UndefinedValue();
uVo.projectNumber = projectNumber;
uVo.variableContingencyValue = variConRate;
uVo.actualCost = actualCost;
uVo.varibleContingencyCost = variConCost;
uVo.actualPlusContingencyCost = actualPlusCost;
localStorage.setItem('undefinedValue', JSON.stringify(uVo));
}
export function readUndefinedValue(projectNumber) {
let uVo = JSON.Parse(localStorage.getItem('undefinedValue'));
if (uVo !== undefined || uVo !== null) {
return uVo;
}
return null;
}
And in the top of the frame code, added this.
<script type="text/javascript">
import { readUndefinedValue, writeUndefinedValue, UndefinedValue } from './source/js_undefinedValue.js';
</script>
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Got it to work
module literately meant module.
So instead of type="javascript", it's type="module"
my file remains the same
export class UndefinedValue {
projectNumber;
variableContingencyValue;
actualCost;
varibleContingencyCost;
actualPlusContingencyCost;
}
export function writeUndefinedValue(projectNumber, variConRate, actualCost, variConCost, actualPlusCost) {
let uVo = new UndefinedValue();
uVo.projectNumber = projectNumber;
uVo.variableContingencyValue = variConRate;
uVo.actualCost = actualCost;
uVo.varibleContingencyCost = variConCost;
uVo.actualPlusContingencyCost = actualPlusCost;
localStorage.setItem('undefinedValue', JSON.stringify(uVo));
}
export function readUndefinedValue(projectNumber) {
let uVo = JSON.Parse(localStorage.getItem('undefinedValue'));
if (uVo !== undefined || uVo !== null) {
return uVo;
}
return null;
}
But the script ended up like this
echo "
<script type='module' scr='./source/js_undefinedValue.js'></script>
<script language='JavaScript' type='module'>
import { readUndefinedValue, writeUndefinedValue, UndefinedValue } from './source/js_undefinedValue.js';
writeUndefinedValue (
$sess_proj_no,
$vari_contingency_rate,
$actual_cost,
$vari_contingency_cost,
$actualPlusContingency_cost
);
</script>";
So far no complaints from the browser, the console is clean and I got a clean write of the class in string format in local storage.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I know nothing about frames, or just forgot from 17 years ago.
I have this PHP project, original authors used frames.
I need to store a calculated value in child frame, and store it in a textbox in the parent frame.
Can't seem to grab the frame, undefined.
The HTML
<frameset rows="45, 75%" FRAMEBORDER="0" BORDER="0" FRAMESPACING="0" onUnload="logout()">
<frameset cols="*, 450" FRAMEBORDER="0" BORDER="0" FRAMESPACING="0">
<frame id="basicFrame" name="basic" src="page_top.phtml" marginheight="0" marginwidth="0" noresize border="0" scrolling="yes" >
<frame id="msrpFrame" name="msrp" src="page_blank.html" marginheight="0" marginwidth="0" noresize border="0">
</frameset>
<frame id="mainFrame" name="main" src="page_main.phtml" marginheight="0" marginwidth="0" noresize border="0">
</frameset>
My textbox is in a frame called mainFrame, and my script and calculated value is in a iframe called msrpFrame.
<script language='JavaScript' type='text/javascript'>
var mFrame = document.getElementById('mainFrame');
if (mFrame !== null || mFrame !== undefined) {
var contentDoc = mFrame.contentDocument || mFrame.contentWindow.document;
var txtUV = contentDoc.getElementById('undefinedValue');
if (txtUV !== null) {
txtUV.value = " . $GLOBALS[undefinedValue] . "
}
}
</script>
I thought I was pretty good with JavaScript but this eludes me. I'm not a big fan of how this project was authored either. And this seems to be the best solution at the moment. Unless I try to make the global var work in PHP across multiple frames and multiple PHP pages.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I'm gonna abandon this idea.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
jkirkerx wrote: var mFrame = document.getElementById('mainFrame'); is looking for mainframe in the current (subframed) document, so won't find it there. You need to go up a level, since the IFRAME called mainframe is in the top-level document:
var mFrame = window.top.document.getElementById('mainframe'); (Haven't tested that but I think it's right - should put you on the right track anyway).
|
|
|
|
|
But I get the idea. Climb up a level out of the child frame first.
Thanks, will play around with it.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Hey,
I am trying to implement a virtual populate in my js between two models I created.
reviewModel:
const reviewSchema = new mongoose.Schema({
review: {
type: String,
required: [true, 'Review can not be empty!']
},
rating: {
type: Number,
min: 1,
max: 5
},
createdAt: {
type: Date,
default: Date.now(),
},
tour: [
{
type: mongoose.Schema.ObjectId,
ref: 'Tour',
required: [true, 'Review must be belong to a tour.']
}
],
user: [
{
type: mongoose.Schema.ObjectId,
ref: 'User',
required: [true, 'Review must be belong to a user.']
}
]
},
{
toJSON: { virtuals: true },
toObject: { virtuals: true },
}
);
and my tourModel:
const tourSchema = new mongoose.Schema({
name: {
type: String,
required: [true, 'A tour must have a name'],
unique: true,
trim: true,
maxlength: [40, 'A tour name must have less or equal then 40 characters'],
minlength: [10, 'A tour name must have at least 10 character']
},
slug: {
type: String
},
duration: {
type: Number,
required: [true, 'A tour must have a duration']
},
maxGroupSize: {
type: Number,
required: [true, 'A tour must have a group size']
},
difficulty: {
type: String,
required: [true, 'A tour must have a difficuulty level'],
enum: {
values: ['easy', 'medium', 'difficult'],
message: 'Difficulty is either "easy", "medium" or "difficult"'
}
},
ratingsAverage: {
type: Number,
default: 4.5,
min: [1, 'Rating must be above 1'],
max: [5, 'Rating must be below 5']
},
ratingsQuantaity: {
type: Number,
default: 0
},
price: {
type: Number,
required: [true, 'A tour must have a price']
},
priceDiscount: {
type: Number,
validate: {
validator: function (val) {
return val < this.price;
},
message: 'Discount price ({VALUE}) shoulld be below the regular price'
}
},
summary: {
type: String,
trim: true,
},
description: {
type: String,
trim: true,
required: [true, 'A tour must have a description']
},
imageCover: {
type: String,
required: [true, 'A tour must have a image cover']
},
images: [String],
createdAt: {
type: Date,
default: Date.now(),
select: false
},
startDates: [Date],
secretTour: {
type: Boolean,
default: false
},
startLocation: {
type: {
type: String,
default: 'Point',
enum: ['Point']
},
coordinates: [Number],
address: String,
description: String
},
locations: [
{
type: {
type: String,
default: 'Point',
enum: ['Point']
},
coordinates: [Number],
address: String,
description: String,
day: Number
}
],
guides: [
{
type: mongoose.Schema.ObjectId,
ref: 'User'
}
]
},
{
toJSON: { virtuals: true },
toObject: { virtuals: true }
}
);
in tour model I virtual true for JSON and Object as you can see.
i want to use them to populate tour from review using the id:
tourSchema.virtual('reviews', {
ref: 'review',
foreignField: 'tour',
localField: '_id'
});
I tried to go to mongoose documentation and everything seems to be fine in the virtual function but it doesn't work and i can't see the reviews on the tour when I use the route for seeing tour by id (can't see review field).
|
|
|
|
|