Sure, just use an object:
myAA = {}; function setKeyValuePair(key, val, AA) { AA[key]=val; } function deleteKeyValuePair(key, AA) { AA[key] = undefined; } function getValue(key, AA) { return AA[key]; }
Offline
Yeah. Create a canvas, paste the image onto it, get the imagedata, and upload it as a string. On the server-side, get the contents of that image.
var c = document.createElement("canvas") var ctx = c.getContext("2d") var i = new Image(); i.src = "image-source-here"; i.onload=function() { ctx.drawImage(i); d = c.toDataURL(); // send d via AJAX }
# python client-side # ...get contents of POST request, store it in variable d here... import urllib img = urllib.urlopen(d).read() # do something with img!
Offline
rias wrote:
is there a script to another page,
if "?" behind the url of the page?
Yes, but that isn't Javascript, that's PHP.
Offline
Have you guys ever used this?:
javascript:document.body.contentEditable = 'true'; document.designMode='on'; void 0
Offline
Hardmath123 wrote:
Yeah. Create a canvas, paste the image onto it, get the imagedata, and upload it as a string. On the server-side, get the contents of that image.
Code:
var c = document.createElement("canvas") var ctx = c.getContext("2d") var i = new Image(); i.src = "image-source-here"; i.onload=function() { ctx.drawImage(i); d = c.toDataURL(); // send d via AJAX }Code:
# python client-side # ...get contents of POST request, store it in variable d here... import urllib img = urllib.urlopen(d).read() # do something with img!
Thank you. A lot.
Offline
Recently I've been fiddling with the Google Apps Script JavaScript API, pretty useful for messing with documents and making web apps. Anyone here heard of it? Still figuring out some aspects of it, though it's pretty simple.
Last edited by technoguyx (2012-10-07 22:55:31)
Offline
trinary wrote:
transparent wrote:
Have you guys ever used this?:
Code:
javascript:document.body.contentEditable = 'true'; document.designMode='on'; void 0It can be occasionally useful.
i prefer inspect element
Offline
veggieman001 wrote:
trinary wrote:
transparent wrote:
Have you guys ever used this?:
Code:
javascript:document.body.contentEditable = 'true'; document.designMode='on'; void 0It can be occasionally useful.
i prefer inspect element
Inspect element is better.
just summing your post :3
Offline
veggieman001 wrote:
trinary wrote:
transparent wrote:
Have you guys ever used this?:
Code:
javascript:document.body.contentEditable = 'true'; document.designMode='on'; void 0It can be occasionally useful.
i prefer inspect element
I prefer Firebug.
Offline
jji7skyline wrote:
veggieman001 wrote:
trinary wrote:
It can be occasionally useful.
i prefer inspect element
Inspect element is better.
just summing your post :3
:@@@@
so what you're saying is what i prefer is the best
Offline
Hardmath123 wrote:
Sure, just use an object:
Code:
myAA = {}; function setKeyValuePair(key, val, AA) { AA[key]=val; } function deleteKeyValuePair(key, AA) { AA[key] = undefined; } function getValue(key, AA) { return AA[key]; }
erm whats wrong with delete AA[key] ? its more logical [ unless you use the strict mode ]
Offline
trinary wrote:
Is there any way images can be uploaded in an AJAX-like fashion (without reloading the page) without using jQuery?
Check out the new api called fileSystem API its awesome and wont need to use canvas its very very simple aswell here is what i do
1. Open the file as filestream <input type="file"> or drag and drop api
2. Create a new FormData();
3. Append that file to the form data and "post" it to the server via xhr..
in older days a file type input used to do this. but file API Rocks , you can even read file on client side as binary stream and do binary magic with it
why is this better ??
To data url is base64 and depending on the encoding used for transporting it its size can be n times larger then the actual file , which we dont need .. esp when we can directly send files!
Offline
Hardmath123 wrote:
Sure, just use an object:
Code:
myAA = {}; function setKeyValuePair(key, val, AA) { AA[key]=val; } function deleteKeyValuePair(key, AA) { AA[key] = undefined; } function getValue(key, AA) { return AA[key]; }
JavaScript array's are associative by default why even do that ?? I mean seriously
..
var arr = new Array(); arr['foo'] = 'bar'; delete arr['foo'];
but if we go in depth javascript arrays are just objects with some prototype methods for length push and pop shift and unshift so well depends really on what he wanna choose by the way @Hardmath here is a trick..
function AssocArray(){ if( !(this instanceof AssocArray)){ return new AssocArray(); // good old trick to save pain we got from forgetting a new } var arr = {}; this.setKeyValue = function(key,value){ arr[key] = value; } this.unsetKeyValue = function(key){ if(arr[key]) delete arr[key]; } this.getKeyValue = function(key){ return arr[key] } }
Last edited by fanofcena (2012-10-08 00:17:46)
Offline
veggieman001 wrote:
jji7skyline wrote:
veggieman001 wrote:
i prefer inspect elementInspect element is better.
just summing your post :3:@@@@
so what you're saying is what i prefer is the best
What you prefer isn't automatically the best, but in this case, it is.
Offline
fanofcena wrote:
Hardmath123 wrote:
Sure, just use an object:
Code:
myAA = {}; function setKeyValuePair(key, val, AA) { AA[key]=val; } function deleteKeyValuePair(key, AA) { AA[key] = undefined; } function getValue(key, AA) { return AA[key]; }JavaScript array's are associative by default why even do that ?? I mean seriously
..Code:
var arr = new Array(); arr['foo'] = 'bar'; delete arr['foo'];but if we go in depth javascript arrays are just objects with some prototype methods for length push and pop shift and unshift so well depends really on what he wanna choose by the way @Hardmath here is a trick..
Code:
function AssocArray(){ if( !(this instanceof AssocArray)){ return new AssocArray(); // good old trick to save pain we got from forgetting a new } var arr = {}; this.setKeyValue = function(key,value){ arr[key] = value; } this.unsetKeyValue = function(key){ if(arr[key]) delete arr[key]; } this.getKeyValue = function(key){ return arr[key] } }
Thank you.
I did not know that.
Offline
fanofcena wrote:
Hardmath123 wrote:
Sure, just use an object:
Code:
myAA = {}; function setKeyValuePair(key, val, AA) { AA[key]=val; } function deleteKeyValuePair(key, AA) { AA[key] = undefined; } function getValue(key, AA) { return AA[key]; }JavaScript array's are associative by default why even do that ?? I mean seriously
..Code:
var arr = new Array(); arr['foo'] = 'bar'; delete arr['foo'];but if we go in depth javascript arrays are just objects with some prototype methods for length push and pop shift and unshift so well depends really on what he wanna choose by the way @Hardmath here is a trick..
Code:
function AssocArray(){ if( !(this instanceof AssocArray)){ return new AssocArray(); // good old trick to save pain we got from forgetting a new } var arr = {}; this.setKeyValue = function(key,value){ arr[key] = value; } this.unsetKeyValue = function(key){ if(arr[key]) delete arr[key]; } this.getKeyValue = function(key){ return arr[key] } }
I just posted my example functions as a demo to show how the JS objects syntax works. I wouldn't use those functions myself, they're ugly (especially the delete one! thanks for that tip), but it suffices to show what I meant. Also, I don't think you really need a separate class for associative arrays, the traditional syntax is good enough.
@trinary also, you should know what JSON is. JSON (JS Object Notation) is used to basically build an anonymous associative array (object in JS lingo, and dictionary in other languages). It's a lot like XML:
{"key":"value"} {"key":{"nested":"value"}} {"key":["array", "with", "four", "objects"]} ...
Offline
trinary wrote:
transparent wrote:
Have you guys ever used this?:
Code:
javascript:document.body.contentEditable = 'true'; document.designMode='on'; void 0It can be occasionally useful.
Well, I never use it because of inspect, but I always thought it was cool when I was first learning it.
Offline
transparent wrote:
trinary wrote:
transparent wrote:
Have you guys ever used this?:
Code:
javascript:document.body.contentEditable = 'true'; document.designMode='on'; void 0It can be occasionally useful.
Well, I never use it because of inspect, but I always thought it was cool when I was first learning it.
I have used the contenteditable attribute though to create custom facebook like inputs :-) its cool.. allows u to do things that a normal textbox or input cant [ rich input ]
Offline