diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3080ecd --- /dev/null +++ b/LICENSE @@ -0,0 +1,6 @@ +session.js 0.4.1 +(c) 2012 Iain, CodeJoust +session.js is freely distributable under the MIT license. +Portions of session.js are inspired or borrowed from Underscore.js, and quirksmode.org demo javascript. +This version uses google's jsapi library for location services. +For details, see: https://github.com/codejoust/session.js diff --git a/README.md b/README.md index a47c8a5..5408329 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ To use: include the file session.js, then access the visitor object. It uses the google javascript loader to get location data. For async loading, use the window.session_loaded callback. -[Live Demo](http://go.iain.in/sessionjslivedemo01) +[Live API Demo](http://go.iain.in/sessionjslivedemo01) | [Example Usage Page](http://go.iain.in/sessionjslivedemo02) Configurable options are below. @@ -16,13 +16,42 @@ Configurable options are below. Include `session.js` in the head or footer. #### Download/Linking: +Recommended: +[Api v0.4 Uncompressed](http://codejoust.github.com/session.js/session-0.4.js) + +Quick Example: + +```html + + +``` + +#### Other Source Options: +Lock version to v0.4 (current stable): +[uncompressed](http://codejoust.github.com/session.js/session-0.4.js), +[compressed](http://codejoust.github.com/session.js/session-0.4.min.js). + Edge: -[uncompressed](https://raw.github.com/codejoust/session.js/master/session.js), -[compressed](https://raw.github.com/codejoust/session.js/master/session.min.js) -Lock version to v0.3 (last stable version): -[uncompressed](https://raw.github.com/codejoust/session.js/v0.4/session.js) [compressed](https://raw.github.com/codejoust/session.js/v0.4/session.min.js) +[uncompressed](http://codejoust.github.com/session.js/session.js), +[compressed](http://codejoust.github.com/session.js/session.min.js) + -If used in the footer (before the `
+Script Output:
++ loading... ++ + + + + + + + + + +
` tag), you can use the `window.session_loaded = function(session){}` callback).
+If used in the footer (before the `` tag), you can use the `window.session = {start: function(sess){ /* loaded session data */ }}` callback, before including the session.js. This is recommended when using session.js with location data.
### API demo dump of `window.session`:
@@ -35,16 +64,16 @@ If used in the footer (before the `` tag), you can use the `window.sessio
},
"current_session": {
"visits": 1,
- "start": 1325991619228,
- "last_visit": 1325991619228,
- "url": "http://localhost:8000/demo.html",
- "path": "/demo.html",
- "referrer": "http://localhost:8000/",
+ "start": 1326170811877,
+ "last_visit": 1326170811877,
+ "url": "http://codejoust.github.com/session.js/",
+ "path": "/session.js/",
+ "referrer": "",
"referrer_info": {
- "host": "localhost:8000",
- "path": "/",
+ "host": "codejoust.github.com",
+ "path": "/session.js/",
"protocol": "http:",
- "port": "8000",
+ "port": 80,
"search": "",
"query": {}
},
@@ -54,19 +83,19 @@ If used in the footer (before the `` tag), you can use the `window.sessio
}
},
"original_session": {
- "visits": 41,
- "start": 1325990490065,
- "last_visit": 1325991619229,
- "url": "http://localhost:8000/demo.html",
- "path": "/demo.html",
+ "visits": 29,
+ "start": 1326032481755,
+ "last_visit": 1326170811879,
+ "url": "http://codejoust.github.com/session.js/",
+ "path": "/session.js/",
"referrer": "",
"referrer_info": {
- "host": "localhost:8000",
- "path": "/demo.html",
+ "host": "codejoust.github.com",
+ "path": "/session.js/",
"protocol": "http:",
- "port": "8000",
+ "port": 80,
"search": "",
- "query": ""
+ "query": {}
},
"search": {
"engine": null,
@@ -84,14 +113,18 @@ If used in the footer (before the `` tag), you can use the `window.sessio
"java": true,
"quicktime": true
},
+ "time": {
+ "tz_offset": -5,
+ "observes_dst": true
+ },
"device": {
"screen": {
"width": 1280,
"height": 1024
},
"viewport": {
- "width": 1063,
- "height": 860
+ "width": 1230,
+ "height": 952
},
"is_tablet": false,
"is_phone": false,
@@ -117,9 +150,13 @@ Default options are shown below.
ipinfodb.com location [demo](http://codejoust.github.com/session.js/ipinfodb_demo.html).
+Synchronous information (everything but location not cached in a cookie),
+is available immediately after including session.js.
+
```js
window.session = {
options: {
+ // Default Settings Example
// Use the HTML5 Geolocation API
// this ONLY returns lat & long, no city/address
use_html5_location: false,
@@ -129,21 +166,22 @@ window.session = {
// Leaving true allows for fallback for both
// the HTML5 location and the IPInfoDB
gapi_location: true,
- // Name of the location cookie
+ // Name of the location cookie (set blank to disable cookie)
// - WARNING: different providers use the same cookie
// - if switching providers, remember to use another cookie or provide checks for old cookies
location_cookie: "location",
// Location cookie expiration in hours
- location_cookie_timeout: 2,
+ location_cookie_timeout: 5,
// Session expiration in days
session_timeout: 32,
- // Session cookie name
+ // Session cookie name (set blank to disable cookie)
session_cookie: "first_session"
+ };
},
- start: {
- // Session location loaded.
+ start: function(session){
+ // Session location loaded into window.session and first argument.
}
}
```
-
\ No newline at end of file
+
diff --git a/debug.html b/debug.html
new file mode 100644
index 0000000..928e9d4
--- /dev/null
+++ b/debug.html
@@ -0,0 +1,240 @@
+
+
+
+
+ + + + + + +
+