|
I set my name properly. I am at second phase of development of my first javascript. I'm ready to start factoring out some good stuff I've done and package it off nicely.
So I need to read all this
RequireJS
And I presume I then useMinify
Edit: No, there's a thing called uglify in requirejs.
Basically the answer to my question is "yes there is, we're all using requirejs. go learn".
modified 14-Apr-15 7:15am.
|
|
|
|
|
My solution to this exact problem is I created my own function to do it. RequireJS or CommonJS required you to modify your code into their module/package model. I just want to load any js file dynamically and where it is needed. It is cruel but satisfied my need.
The idea is inject the required file into the header of the page and let browser load the file and evaluate it. It works for js and css files.
var ServiceUrl = function() {
var src = document.currentScript.src;
var idx = src.indexOf("/scripts");
if (idx > 0)
src = src.substring(0, idx);
else
src = "";
return src;
}();
if (!getServiceUrl) {
function getServiceUrl() {
return ServiceUrl;
}
}
if (typeof (include) == "undefined") {
function include(url, type, cb, asIs) {
asIs = asIs || false;
cb = cb || null;
if (!url) {
console.log("No file specified to be loaded.");
return;
}
if (!asIs)
url = getServiceUrl() + url;
var alreadyLoaded = false;
if (type.indexOf("javascript") > 0) {
var sc = document.scripts;
var scExists = false;
for (var i = 0, len = sc.length; i < len; i++) {
var src = /src="(.*?)"/.exec(sc[i].outerHTML);
if (src && src.length > 0) {
if (src[1] == url) {
scExists = true;
break;
}
}
}
if (!scExists) {
var el = document.createElement('script');
el.type = type;
el.src = url;
}
else
alreadyLoaded = true;
}
else {
var ss = document.styleSheets;
var cssExists = false;
for (var i = 0, max = ss.length; i < max; i++) {
if (ss[i].href == url) {
cssExists = true;
break;
}
}
if (!cssExists) {
var el = document.createElement("link");
el.href = url;
el.type = type;
el.rel = "stylesheet";
}
else
alreadyLoaded = true;
}
if (el) {
if (typeof (cb) == "function") {
el.onload = cb;
}
var head = document.getElementsByTagName('head')[0];
head.appendChild(el);
}
if (alreadyLoaded) {
if (typeof (cb) == "function") {
cb();
}
}
}
};
|
|
|
|
|
|
Need a lot more info.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I have an application deployed on one server and from this server I want to pop up a new window, which will open a asp.net page deployed on any other server, using window.open() and I want to pass parameters to this pop up window. I don't want to pass parameters through URL. Need some way to pass parameter in a hidden or more secure way.
Can anyone suggest how this can be done.
Thanks in advance.
|
|
|
|
|
|
first we r finding the grid
like this
var grd=document.getElementById("GridView1");
after how can we get a selected row value in grid using javascript
|
|
|
|
|
|
hi everyone can anybody help me for below functionality
i have button and grid on webform1 and i need to transfer data from gridview(seleted row) to webform2 using javascript.
|
|
|
|
|
You can use Ajax[^]... Web Sockets[^]... LocalStorage[^] and many other options to share your data from one form to another.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
- On click of your button, call a javascript function.
- Get the gridview row data in Javascript variable (probably from dom attribute).
- Put the data in Webform2 url query string.
- In your webform2, read the data from query string.
Hope this helps.
Life is a computer program and everyone is the programmer of his own life.
|
|
|
|
|
i have a file,file format is CMYK(Cyan,Magenta,Yellow,Black),file have 7 layer include background,i want to multiply layer by Formula,
layer 1(cmyk)---C1,M1,M1,K1
layer 2(cmyk)---C2,M2,M2,K2
Merge all layers ways:
Layer 1 (C1, M1, Y1, K1) and layer 2 (C2, M2, Y2, K2) and Layer 3 (C3, M3, Y3, K3), ......
1.
Layer 1 and Layer 2 identical coordinate positions, with C for example
A. If C1>= C2, C = C1 + C2-2 * C1 * C2 / 100 + C1 * C1 * C2 / 10000
B. If C2 > C1, C = C1 + C2-2 * C1 * C2 / 100 + C2 * C2 * C1 / 10000
then Layer 1 and Layer 2 merged into layer 1
2.
Layer 1 and Layer 2 identical coordinate positions, with C for example
A. If C1 >= C3, C = C1 + C3-2 * C1 * C3 / 100 + C1 * C1 * C3 / 10000
B. If C3 > C1, C = C1 + C3-2 * C1 * C3 / 100 + C3 * C3 * C1 / 10000
then Layer 1 and Layer 3 merged into layer 1
3.
Layer 1 and Layer 4 identical coordinate positions, with C for example
A. If C1 >= C4, C = C1 + C4-2 * C1 * C4 / 100 + C1 * C1 * C4 / 10000
B. If C4 > C1, C = C1 + C4-2 * C1 * C4 / 100 + C4 * C4 * C1 / 10000
then Layer 1 and Layer 4 merged into layer 1
........
pls help
|
|
|
|
|
I have a html page where I am loading PDF file using Div.
I need to refresh that Div only once without refreshing whole page using javascript or jquery.
Need urgent help.
Thanks.
|
|
|
|
|
jQuery provides the load method[^]:
Load data from the server and place the returned HTML into the matched element.
$("#result").load("ajax/test.html");
However, you cannot display a PDF file directly within a <div> tag. You would need to use an <iframe> , or some other PDF viewer control.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
+5
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
How to make a Content Slider in JavaScript with all the function eg play, pause, replay, seek on the slider for moving back and front, sync slider with audio and contents
|
|
|
|
|
Content slider and play pause buttons are totally different things. You are combining a media player with a content slider.
Do it yourself, using jQuery players[^], and a content slider[^].
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
|
Then remove the jQuery from search box, and search for JavaScript version. What prevents you from doing so?
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Normally JSON data is fetched in the following form from Web API etc.
[
{"name" : "Steve", "Age": 76}, {"name": "Jeremy", "Age": 43}
]
You can see that "name" and "Age" is repeating with every column. But I've seen a service getting data in this fashion. Which really shorten the JSON object something like that.
[
columns: {"name", "age"}
data: {"Steve",76},{"Jeremy",43}
]
How to do it?
|
|
|
|
|
well, you can tweak the Json a little,
{
"name" : ["Steve", "Jeremy"],
"Age": [76,43]
}
looks greatly shortened..
|
|
|
|
|
But you lost all the good in JSON...
I would say that compressing the traffic will do better...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Is there a good tutorial on compressing the traffic on JSON data.
|
|
|
|
|
|
I'm trying to connect the hotel amount with the amount per day. For instance, if you select two days staying at the Economy hotel, it doubles the amount rather than doubling the amount for they the stay at the hotel alone. I've created a variable for days and added it to my if statements to retrieve the value. It was retrieving the amount for a single day correctly, but once I added that variable it began doubling everthing else.
When the user submits their form, a cost estimate for their trip should appear in an alert box with all the options: Quote: Arrival City: Use a radio button. Choices should be Omaha ($200), Nashville ($250), Detroit ($150)
Number of days as a select box with options from 2 through 6
Select box for ‘Extra Baggage ($30 each)’. Options should be ‘No Extra Bags’, ‘1 Extra Bag’, ‘2 Extra Bags’, ‘3 Extra Bags’
Have a checkbox for the following: Bringing a pet ($60)
A radio button to select the type of hotel: Economy Hotel ($140), Standard Hotel ($220), Upscale Hotel ($300)
This what I have so far.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script type="text/Javascript">
function arrivalCity ()
{
var cost = 0;
var days;
var radHotel;
days = document.reservation.selDay.value;
if (document.reservation.radCity[0].checked)
{
cost = 200;
}
if (document.reservation.radCity[1].checked )
{
cost = 250;
}
if (document.reservation.radCity[2].checked)
{
cost = 150;
}
if (document.reservation.chkYes.checked)
{
cost = cost + 60;
}
if (document.reservation.radHotel[0].checked)
{
cost = cost + 140;
}
if (document.reservation.radHotel[1].checked)
{
cost = cost + 220;
}
if (document.reservation.radHotel[2].checked)
{
cost = cost + 300;
}
if ( days == "two")
{
cost = cost * 2 ;
}
alert (cost) ;
}
</script>
</head>
<body>
<div id="header">
<form name="reservation">
<p>Where are you traveling to? <br/>
Omaha <input type ="radio" name="radCity"> <br>
Nashville <input type="radio" name="radCity"><br>
Detroit <input type="radio" name="radCity"> </p>
<p>How many days are you staying?<br>
<select name="selDay">
<option value="two"> 2 </option>
<option value="three"> 3 </option>
<option value"four"> 4 </option>
<option value="five"> 5 </option>
<option value="six"> 6 </option>
</select></p>
<p>Extra Baggage ($30 each): <br>
<select name="selBag">
<option value="noBag"> No Extra Bags</option>
<option value="oneBag"> 1 Extra Bag</option>
<option value="twoBag">2 Extra Bags</option>
<option value="threeBag"> 3 Extra Bags</option>
</select> </p>
<p>Bringing a pet ($60):<br>
Yes <input type="checkbox" name="chkYes"><br>
No <input type="checkbox" name="chkNo"> <br> </p>
<p>Select the name of the hotel:<br>
Economy Hotel <input type="radio" name="radHotel" value="$140"><br>
Standard Hotel <input type="radio" name="radHotel" value="$220"><br>
Upscale Hotel <input type="radio" name="radHotel" value="$300"><br>
</select></p>
<p><input type="button" value="Book My Ticket" onclick="arrivalCity ()"> </p>
</body>
</html><pre lang="Javascript">
modified 13-Mar-15 17:19pm.
|
|
|
|