Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 02 Sep 2014, 09:07
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Web Programming
Post new topic   Reply to topic View previous topic :: View next topic
Page 3 of 5 [66 Posts]   Goto page: Previous 1, 2, 3, 4, 5 Next
Author Message
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Thu 29 Nov 2012, 23:23    Post subject:  

an example using the (now deprecated) twitter search api
Code:
<html><head><title>Twitter Search</title>
<style>
.box{width:25%;top:65px;height:75%;overflow:auto}.sbox,.box{position:absolute;border:5px solid gray;padding:5px}.sbox,#l{left:5%}#c{left:35%}#r{left:65%}
</style>
<script>
var termsl,termsc,termsr
function foo(data){var term=document.getElementById("term").value
var l=document.getElementById("l"),c=document.getElementById("c"),r=document.getElementById("r")
if((termsc != term)&&(termsl != term)){termsr=termsc
r.innerHTML=c.innerHTML}if(termsl != term){termsc=termsl
c.innerHTML=l.innerHTML}termsl=term
l.innerHTML=term+"<br><hr>"
for (var i=0;i<data.results.length;i++){var result=data.results[i]
l.innerHTML+='<span><a href="http://twitter.com/#!/'+result.from_user+'/status/'+result.id_str+'"> <img width="24" height="24" src="'+result.profile_image_url+'"> '+result.from_user+'<a>: '+result.text+'</span><br>'}}
srch=function(){var term=document.getElementById("term").value,script=document.createElement("script");
script.src="http://search.twitter.com/search.json?q="+term+"&callback=foo"
document.body.appendChild(script)}
</script>
</head>
<body><form class="sbox" action="javascript:srch()">
<input id="term" name="term" type="textbox"/><input type="submit" value="Twitter Search"/></form>
<div id="l" class="box"></div><div id="c" class="box"></div><div id="r" class="box"></div>
</body></html>

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Fri 30 Nov 2012, 11:35    Post subject:  

technosaurus wrote:
an example using the (now deprecated) twitter search api

technosaurus out now Question
twitter.png
 Description   
 Filesize   49.58 KB
 Viewed   1033 Time(s)

twitter.png

Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Wed 05 Dec 2012, 16:00    Post subject:  

Here is a drag and drop example:

(tested on IE 5.5, 6, 8 & 9 using IETester and Seamonkey-2.14 - so should verify for Firefox too, as well as Chrome and Opera, but drag/drop is broken in safari-5.1.7 for windows/wine, so use 5.0.6 - I think apple intentionally broke things for the windows client)

here are functions
Code:
function drag(ev){ //we will just store the inner html of our drag tag - it could be id, class or something else
   ev.dataTransfer.setData("Text",ev.target?ev.target.innerHTML:event.srcElement.innerHTML) //IE needs "Text" and others are fine with it
}
function drop(ev){
   if(ev.preventDefault){ev.preventDefault();  //or mozilla will navigate to the url.com of the text
      ev.target.innerHTML=ev.dataTransfer.getData("Text") //we are replacing the inner html of our drop with our drag
   }else{event.returnValue=false //ie workaround does not have preventDefault or target
      event.srcElement.style.backgroundColor=ev.dataTransfer.getData("Text")
   }
}


Notes on the html:
older versions of _some_ browsers only support dragging "a" or link tags, so use it with a blank href
we need to set draggable to true for the items we want to be able to drag
we also need to get the draggable, so we set ondragstart to our drag function and pass it the event
we also need to override the default function of ondragover - return false will do this nicely (or you _could_ use a function to preventDefault, but it is not browser independent)
and finally we need to do something with our drop event, so we set ondrop to pass the drop event to our drop function
Code:
<a href="#" id="dragme" draggable="true" ondragstart="drag(event)">content to drag</a>
<div id="drophere" ondrop="drop(event)" ondragover="return false">a place to drop</div>


but since we used <a> tags, it will look like a link, so we need to add some css to fix that
Code:
#dragme,#drophere{text-decoration:none;color:black}

note the link is href="#", a non-existent nav point, so that clicking on it instead of dragging doesn't cause a page reload (as href="" would)

All of the above css and html can be created dynamically in your script, but I split out as much as possible to show the basic principals


and the example:

Code:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head><title>dragable colors</title><meta http-equiv="content-type" content="text/html;charset=utf-8" />
<style>
#drop{left:15%;width:70%;top:65px;height:75%;overflow:auto}
#drop,#y,#r,#b{position:absolute;border:5px solid gray;padding:5px}
#r{left:35%;color:red}#b{left:45%;color:blue}#y{left:55%;color:yellow}
#r,#y,#b{width:5%;text-align:center;background:lightgray;text-decoration:none}
</style>

<script>
function allowDrag(event){
   if(event.preventDefault){
      event.preventDefault();
   }else{
      event.returnValue=false;
   }
   return false
}
function drag(ev){
   ev.dataTransfer.setData("Text",ev.target?ev.target.innerHTML:event.srcElement.innerHTML)
}
function drop(ev){alert;
   if(ev.preventDefault){ev.preventDefault();
      ev.target.style.backgroundColor=ev.dataTransfer.getData("Text")
   }else{event.returnValue=false //ie workaround
      event.srcElement.style.backgroundColor=ev.dataTransfer.getData("Text")
   }
}
</script>

</head>

<body>
<a href="#" id="y" draggable="true" ondragstart="drag(event)">yellow</a>
<a href="#" id="r" draggable="true" ondragstart="drag(event)">red</a>
<a href="#" id="b" draggable="true" ondragstart="drag(event)">blue</a>
<div id="drop" ondrop="drop(event)" ondragover="allowDrag(event)">drag a color to this box</div>
</body>

</html>

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Fri 22 Feb 2013, 04:41    Post subject:  

I've been thinking about writing my own javascript library designed for "static" compiles, but though I was pretty certain it is needed, I figured I would scope out the top libraries and see how they compared with fully optimized compiles.

I did my little bloat comparison of javascript libraries to see how well they "statically" compile using the closure compiler service at http://closure-compiler.appspot.com/home

My method:
include 1 and only 1 javascript library and a simple hello world alert function that doesn't use any code from the library and build with full optimization

turns out they really are horrible for dead code elimination, except google's base.js (which is horrible for other reasons)

The library that I am working on (a.js... a reference to static archives) compiles down to zero if the code isn't used. The idea is to only add functions that aren't so complex that they prevent optimization (for example no functions that take a function as an argument)
comparison.png
 Description   
 Filesize   5.7 KB
 Viewed   813 Time(s)

comparison.png

Book1.html.gz
Description 
gz

 Download 
Filename  Book1.html.gz 
Filesize  771 Bytes 
Downloaded  375 Time(s) 

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Mon 04 Mar 2013, 01:30    Post subject:  

for debugging:

Code:
/*@const*/
DEBUG=2
if(DEBUG){

/*@const @constructor*/
Object.defineProperty(window,'__stack__',{get:function(){
   try{_ფ_()}catch(e){return e.stack.split(":")}
}})

/*@const @constructor*/
Object.defineProperty(window,'__file__',{get:function(){
   var s=__stack__,l=s.length
   return (isNaN(s[l-2]))?s[l-2]:s[l-3]
}})

/*@const @constructor*/
Object.defineProperty(window,'__line__',{get:function(){
   var s=__stack__,l=s.length
   return (isNaN(s[l-2]))?s[l-1]:s[l-2]
}})

/*@const @constructor*/
Object.defineProperty(window,'__col__',{get:function(){
   var s=__stack__,l=s.length
   return (isNaN(s[l-2]))?"NA":s[l-1]
}})

/*@const @constructor*/
Object.defineProperty(window,'LOG',{
   get:function(){return out},
   set:function(msg){if(DEBUG>1)out=msg+"\t-\t"+__stack__
      else out=msg+" in file:"+__file__+" @ Line:"+__line__+", Column:"+__col__
      console.log(out)}
})
}//end if(DEBUG)

usage:
LOG="hello world"

or:
alert("my message at line:"+__line__)

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Thu 07 Mar 2013, 22:16    Post subject:  

this is some server side javascript for node.js, it takes any url and wraps the response in a callback. In other words it is a helper that converts JSON to JSONP for cross site scripting.

example that will get imdb json and wrap it in a callback called hello
localhost:8080/?callback=hello&host=www.imdb.com&path=/xml/find?json=1&nr=1&nm=on&q=jackson

Code:
var http = require('http');
http.createServer(function (req, res) {
   res.writeHead(200, {'Content-Type': 'application/javascript'});
   var q=req.url.split('?'),p,i,h,f
   if(q.length>1)p=q[1].split('&'),i=p.length;else return;
   
   while(i--){
      if(p[i].split('=')[0]=="callback"){res.write(p[i].split('=')[1]+'(')}
      if(p[i].split('=')[0]=="host"){h=p[i].split('=')[1]}
      if(p[i].split('=')[0]=="path"){f=p[i].split('=')[1]}
   }
   if(h&&f&&q[2])http.get({host:h,port:80,path:f+'?'+q[2]},function(r){
      r.on('data', function(d){res.write(d.toString())})
      r.on('end', function(){res.write(')');res.end()})
   }).on('error',function(e){console.log(e.stack)})
}).listen(8080, '127.0.0.1');
console.log('Server running at http://127.0.0.1:8080/');


Oh, what the hell, here is a simple puppy-ish alternative that can run with only busybox.

Code:
#!/bin/sh
CB="${QUERY_STRING%%&*}"
case "$CB" in
   callback=*)
      printf "Content-type: application/javascript

${CB##*=}("
      wget -O - ${QUERY_STRING#*&}
      printf ")"
   ;;
   *)
      exit
   ;;
esac

Note: busybox would need to be configured to enable httpd with cgi support, wget and either ash or hush (should be ~100kb binary)

Edit: I made the shell version output gzipped data

Code:
#!/bin/sh
CB="${QUERY_STRING%%&*}"
case "$CB" in
   callback=*)
      printf "Content-Encoding: gzip
Content-type: application/javascript

" #todo clean up this while loop hack
      while ([ ! "$ONCE" ]);   do
         printf "${CB##*=}("
         wget -O - ${QUERY_STRING#*&}
         printf ")"
         ONCE=1
      done | gzip -9c
   ;;
   *)
      exit
   ;;
esac

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Sat 23 Mar 2013, 05:57    Post subject: accessing web services with busybox ash shell + nc (netcat)  

accessing web services with busybox ash shell and nc (aka netcat)

Code:
#!/bin/ash

# line to get the wsdl, but instead use:
# http://soapclient.com/soaptest.html instead
# you can use it to get the proper requests - hint: view source
#echo -e "GET /hosps?wsdl HTTP/1.1\r\n\r\n" | nc 192.168.0.102 8888
newline="
"

#you'll need your outside IP address if the web service is on your PC
get_ip(){
IP=`echo -e "GET / HTTP/1.1\r
host: myip.dnsd.me

" | nc myip.dnsd.me 80`
echo ${IP##*$newline}
}
# get_ip(){ #bash only version no nc dep, but /dev/tcp may not be compiled in
# exec 3<>/dev/tcp/myip.dnsdynamic.org/80
# echo -e "GET / HTTP/1.1\r\nhost: myip.dnsd.me\r\n\r\n" >&3
# IP=`cat <&3`
# echo ${IP##*
# }


SOAP(){ # $1=url $2=port $3=namespace $4=endpoint $5=action $6=parameter
#ex. SOAP localhost 8888 "http://patient.ch01/" "/hosps" "getHosps" "some name"

A='<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Body>
      <mns1:'"$5"' xmlns:mns1="'"$3"'">
         '"$6"'
      </mns1:'"$5"'>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
'
echo -e "POST $4 HTTP/1.1\r
Content-Type: text/xml
Content-Length: ${#A}

$A"  | nc "$1" "$2"
}

SOAP 192.168.0.102 8888 "http://patient.ch01/" "/hosps" "getHosps"



here's an example of it in use:

Code:
#!/bin/ash

SOAP(){ # $1=url $2=port $3=namespace $4=endpoint $5=action $6=parameter
#ex. SOAP localhost 8888 "http://patient.ch01/" "/hosps" "getHosps" "some name"
A='<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Body>
      <mns1:'"$5"' xmlns:mns1="'"$3"'">
         '"$6"'
      </mns1:'"$5"'>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
'
echo -e "POST $4 HTTP/1.1\r
Content-Type: text/xml
Content-Length: ${#A}

$A"  | nc "$1" "$2"
}

D(){ echo $2 $3
echo "$1" | awk '
   BEGIN{RS="<return><name>"}
   (tolower($0) ~/'"${2}"'/ && tolower($0) ~/'"${3}"'/){
      gsub(/<[^>]*>/,"\t");
      print "\nDr. "$1" "$2 " has " $NF " patients."
      print "\tAge  First Name      Last Name"
      for (i=3;i<NF;i+=3){printf "\t%-4s %-15s %s\n",$i,$(i+1),$(i+2)}
   }'
}

P(){ echo $2 $3
echo "$1" | awk 'BEGIN{RS="<return><name>"}
tolower($0) ~/'"${2}"'/{
   gsub(/<[^>]*>/,"\t");
   for (i=3;i<NF;i+=3){
      age=i;
      first=i+1;
      last=i+2;
      if(tolower($first) ~/'"${2}"'/)
         if(tolower($last) ~/'"${3}"'/)
            print $first, $last,"is age",$age,"and is a patient of Dr.",$1,$2
   }
}'
}

soap=`SOAP 192.168.0.102 80 "http://patient.ch01/" "/hosps" "getHosps"`
while read -p "
Enter a name followed by a D for doctor or P for patient:

" first last func; do
first=`echo $first|tr [A-Z] [a-z]`
last=`echo $last|tr [A-Z] [a-z]`
case $func in
   D)D "$soap" "$first" "$last";;
   P)P "$soap" "$first" "$last";;
   *)echo "no D/P selected, exiting.";exit;;
esac
done


edit temp code

Code:
#!/bin/sh

#global variables ... will eventually go to external file to be modified/sourced
MIN_PW_LEN=6

createUser(){ #input: $1=UserLogin, $2=UserPassword, $3=UserDisplayName
   #output: int (0-no errors, 1+ error)
   #todo (makes sure UserLogin does not already exist)
   [ "$1" ] || return 1 #empty UserLogin
   [ `userExists $UserLogin` ] && return 2 #UserLogin exists
   [ ${#2} -lt ${MIN_PW_LEN} ]  && return 3 #UserPasword too short
   echo 'insert into _Users(UserLogin, UserPassword, UserDisplayName, UserDeleted) values("'${1}'","'${2}'","'$3'",0);.quit;'
}

checkUserPassword(){ #input: $1=UserLogin, $2=UserPassword (both clear text for now)
   #output: int (0-no errors, 1+ error)
}

deleteUser(){ #input: UserLogin
   #output: int (0-no errors, 1+ error)
   
}

getAllUsers(){ #output: List of UserLogin

}

getUserDisplayName(){ #input: $1=UserLogin
   #output: UserDisplayName
}

initDB(){
#create table _Users(UserUID INTEGER PRIMARY KEY ASC, UserLogin VARCHAR(32) UNIQUE NOT NULL, UserPassword VARCHAR(32),UserDisplayName VARCHAR(64), UserDeleted BOOL );
#note INTEGER PRIMARY KEY ASC is redundant to row id?
}


sendHeader(){
printf "Content-type: application/javascript\r\n\r\n"
}

sendResponse(){
}

splitQueryString(){ #not used
   OLDIFS="$IFS"
   IFS="&"
   for param in $1; do
      case "$param" in
         *=*)echo $param;;
      esac
   done
   IFS="$OLDIFS"
}


updateUser(){ #input: $1=UserLogin, $2=UserPassword, $3=UserDisplayName
   # output: int (0-no errors, 1+ error)
   # (makes sure UserLogin does exist updattes UserPassword, UserDisplayName, sets UserDelete to false)
   [ "$1" ] || return 1 #empty UserLogin
   [ `userExists $UserLogin` ] && return 4 #UserLogin does not exist
   [ ${#2} -lt ${MIN_PW_LEN} ]  && return 3 #UserPasword too short
}

userExists(){
}

`splitQueryString`

case "$action" in
   checkUserPassword)checkUserPassword "$UserLogin" "$UserPassword";;
   createUser)createUser "$UserLogin" "$UserPassword" "$UserDisplayName";;
   deletUser)deleteUser "$UserLogin";;
   getAllUsers)getAllUsers;;
   getUserDisplayName)getUserDisplayName "$UserLogin";;
   updateUser)updateUser "$UserLogin" "$UserPassword" "$UserDisplayName";;
esac

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Sun 07 Apr 2013, 23:19    Post subject:  

I patched the sqlite3 shell to output json for use in web services (you could get away with using its csv output + sed, but this is a pretty small patch)

Code:
--- shell.c~   2013-03-29 22:07:49.000000000 +0800
+++ shell.c   2013-04-07 02:27:33.792883620 +0800
@@ -453,6 +453,7 @@ struct callback_data {
 #define MODE_Tcl      6  /* Generate ANSI-C or TCL quoted elements */
 #define MODE_Csv      7  /* Quote strings, numbers are plain */
 #define MODE_Explain  8  /* Like MODE_Column, but do not truncate data */
+#define MODE_Json     9  /* Like MODE_Column, but do not truncate data */
 
 static const char *modeDescr[] = {
   "line",
@@ -464,6 +465,7 @@ static const char *modeDescr[] = {
   "tcl",
   "csv",
   "explain",
+  "json",
 };
 
 /*
@@ -826,6 +828,21 @@ static int shell_callback(void *pArg, in
       fprintf(p->out,"\n");
       break;
     }
+    case MODE_Json: {
+      if( p->cnt++==0 && p->showHeader ){
+      fprintf(p->out,(nArg==1)?"":"[");
+        for(i=0; i<nArg; i++){
+          fprintf(p->out,"\"%s\"%s",azCol[i], (i==nArg-1) ? (nArg==1)?",":"]," : ",");
+        }
+      }
+      if( azArg==0 ) break;
+      fprintf(p->out,(nArg==1)?"":"[");
+      for(i=0; i<nArg; i++){
+        output_csv(p, azArg[i], i<nArg-1);
+        if (i==nArg-1) fprintf(p->out,"%s", (nArg==1)?",":"],");
+      }
+      break;
+    }
     case MODE_Insert: {
       p->cnt++;
       if( azArg==0 ) break;
@@ -2066,6 +2083,9 @@ static int do_meta_command(char *zLine,
     }else if( n2==3 && strncmp(azArg[1],"csv",n2)==0 ){
       p->mode = MODE_Csv;
       sqlite3_snprintf(sizeof(p->separator), p->separator, ",");
+    }else if( n2==3 && strncmp(azArg[1],"json",n2)==0 ){
+      p->mode = MODE_Json;
+      sqlite3_snprintf(sizeof(p->separator), p->separator, ",");
     }else if( n2==4 && strncmp(azArg[1],"tabs",n2)==0 ){
       p->mode = MODE_List;
       sqlite3_snprintf(sizeof(p->separator), p->separator, "\t");
@@ -3086,6 +3106,9 @@ int main(int argc, char **argv){
     }else if( strcmp(z,"-csv")==0 ){
       data.mode = MODE_Csv;
       memcpy(data.separator,",",2);
+    }else if( strcmp(z,"-json")==0 ){
+      data.mode = MODE_Json;
+      memcpy(data.separator,",",2);
     }else if( strcmp(z,"-separator")==0 ){
       sqlite3_snprintf(sizeof(data.separator), data.separator,
                        "%s",cmdline_option_value(argc,argv,++i));

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Wed 17 Apr 2013, 19:46    Post subject:  

here is an example for using busybox's cgi-bin to host a puppy package database (hard coded for now, but could use the query string to select quirky/wary/racy/...)
Code:
#!/bin/sh
printf "Content-encoding: gzip
Content-type: application/javascript

"
awk 'BEGIN{FS="|";OFS="\",\"";ORS="\"],\n";printf "petCallback([\n"}
{print "\t[\""$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14}
END{printf "])\n"}' /root/.packages/Packages-puppy-quirky-official |gzip -9c


and a crappy test page that puts it in an unformatted table
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head><title></title></head>
<body>
<table id="pets"></table>

<script>
   function petCallback(data){
      var row,cell,text,table = document.getElementById("pets")
      for (var i = 0,rows=data.length,cols=data[0].length; i < rows; i++) {
         row = document.createElement("tr");
         for (var j = 0; j < cols; j++) {
            cell = document.createElement("td");
            text = document.createTextNode(data[i][j]);
            cell.appendChild(text);
            row.appendChild(cell);
         }
      table.appendChild(row);
      }
   }
   var script=document.createElement('script'),head=document.getElementsByTagName("head")[0]
   script.src="http://localhost/cgi-bin/pets?"+(new Date()/1) //prevent cacheing
   head.insertBefore(script, head.firstChild);
</script>
</body>
</html>

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Sat 20 Jul 2013, 00:16    Post subject:  

I have the beginning of a statically compilable js library (targeted to the closure compiler) let me know if there are any requests.
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Sun 21 Jul 2013, 15:05    Post subject:    

Here it is:
contains frequently used functions and examples on how to make google's closure compiler work better for you
liba.js.tar.gz
Description 
gz

 Download 
Filename  liba.js.tar.gz 
Filesize  37.67 KB 
Downloaded  307 Time(s) 

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Thu 19 Sep 2013, 03:21    Post subject:  

In case I ever want to use a device's dpi to select icon sizes (stupid iphones)
Code:
<script>
function dpi(){
   var res={},div=document.createElement("div")
   div.style.position="absolute"
   div.style.width="1in"
   div.style.height="1in"
   div.style.left="-100%"
   div.style.top="-100%"
   document.getElementsByTagName('body')[0].appendChild(div)
   res["xdpi"]=div.offsetWidth
   res["ydpi"]=div.offsetHeight
   div=""
   return res
}
alert("xdpi="+dpi().xdpi+", ydpi="+dpi().ydpi)
</script>

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
sc0ttman


Joined: 16 Sep 2009
Posts: 2376
Location: UK

PostPosted: Thu 19 Sep 2013, 05:56    Post subject:  

I'm sure this stuff is probably awesome... what is it?

What's the end game? Or we anywhere in the realm of some sort of better JS stuff that can be compiled into other stuff? ..elinks?

Or is this all for producing web frontends? Does this all need a webserver?

what could you do with sqlite patched to produce JSON? A simple db backend for websites via json+ajax? could it simply replace the standard sqlite and function as normal?

_________________
Akita Linux, VLC-GTK, Pup Search, Pup File Search
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Thu 19 Sep 2013, 20:18    Post subject:  

The liba.js is for traditional web programming - just a clean room implementation of the most commonly used extras. Maybe I'm a bit conceited, but I felt I could do better than all of the contributors to jquery, google-closure and the other popular js libs out there when it comes to compiled code size and ease of use. The existing kits either require you to remember to either add dependency info into your code to work and compile down (google's) or just doesn't reduce much at all over the minified version (jquery, yui,...). My library is designed for people who want their site to load as fast as possible or to be obfuscated as much as possible without restrictive licensing concerns.

Currently it would need a server for saved states and interaction, but I've actually made a json patch for sqlite, however it was an uninformed hack... I need to redo it to simply query the data type (its only ~10 lines, 8 of which are cut-n-paste). I would like to figure out a way to do it with html5's local storage.

My if-I-had-all-the-time-in-the-world project would be a complete webpage optimizer that parsed html, css, svg, js and extensions and optimized them all into a single zopfli compressed page while generating optimized sprite sheets from img tags and separating out any browser specific workarounds to be loaded automatically (and provide related warning info along with possible workarounds) On the plus side of this, the same parser/lexer could be used for a browser or user interface. Netsurf's MIT licensed libs would be a good starting point to parse it all to a DOM tree then use that to render a page/interface... and rather than caching pages, cache an optimized DOM tree

btw I did build optipng-zopfli (useful in devx) ... it gives ~5% smaller optimized pngs than standard optipng, but it takes for-ev-er.

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Thu 26 Sep 2013, 18:33    Post subject:  

here is a tentative json output patch for sqlite3 shell (for server side database interaction)
sqlite3-json_shell.patch.gz
Description 
gz

 Download 
Filename  sqlite3-json_shell.patch.gz 
Filesize  1.33 KB 
Downloaded  229 Time(s) 

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 3 of 5 [66 Posts]   Goto page: Previous 1, 2, 3, 4, 5 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1727s ][ Queries: 13 (0.0187s) ][ GZIP on ]