Skip to content

Commit

Permalink
first it of signup/login
Browse files Browse the repository at this point in the history
  • Loading branch information
vijayrudraraju committed Dec 23, 2011
1 parent efa1172 commit e0e722e
Show file tree
Hide file tree
Showing 13 changed files with 207 additions and 150 deletions.
37 changes: 28 additions & 9 deletions _attachments/index.html
Expand Up @@ -19,7 +19,7 @@

<body>
<div data-role="page" id="input" data-title="toiweb">
<div id="account">
<div id="account1">
</div>
<div data-role="content">
<div data-role="fieldcontain">
Expand All @@ -38,10 +38,8 @@
</div><!-- /page -->

<div data-role="page" id="query" data-title="toiweb">
<div data-role="header">
<h1>query</h1>
<a href="#login" data-role="button" data-rel="dialog" data-icon="gear" class="ui-btn-right">User</a>
</div><!-- /header -->
<div id="account2">
</div>
<div data-role="content">
<div data-role="fieldcontain">
<label for="textarea2">textarea2</label>
Expand All @@ -66,16 +64,37 @@ <h1>query</h1>
</div><!-- /footer -->
</div><!-- /page -->


<div data-role="page" id="login" data-title="toiweb">
<div data-role="header">
<h1>login</h1>
</div><!-- /header -->
<div data-role="content">
<div data-role="fieldcontain">
<label for="userid">user id</label>
<input type="text" name="userid" id="userid"></textarea>
<label for="userpass">user pass</label>
<input type="password" name="userpass" id="userpass"></textarea>
<form>
<label for="userid" class="ui-hidden-accessible">user id</label>
<input type="text" name="userid" id="userid" placeholder="user id"/>
<label for="userpass" class="ui-hidden-accessible">user pass</label>
<input type="password" name="userpass" id="userpass" placeholder="user pass"/>
<input type="submit" value="login" id="loginsubmit"/>
</form>
</div><!-- /fieldcontain -->
</div><!-- /content -->
</div><!-- /page -->

<div data-role="page" id="signup" data-title="toiweb">
<div data-role="header">
<h1>signup</h1>
</div><!-- /header -->
<div data-role="content">
<div data-role="fieldcontain">
<form>
<label for="newuserid" class="ui-hidden-accessible">new user id</label>
<input type="text" name="newuserid" id="newuserid" placeholder="new user id"/>
<label for="userpass" class="ui-hidden-accessible">new user pass</label>
<input type="password" name="newuserpass" id="newuserpass" placeholder="new user pass"/>
<input type="submit" value="signup" id="signupsubmit"/>
</form>
</div><!-- /fieldcontain -->
</div><!-- /content -->
</div><!-- /page -->
Expand Down
258 changes: 142 additions & 116 deletions _attachments/js/main.js
@@ -1,136 +1,162 @@
// vijay rudraraju

$.couch.app(function(app) {
$("#account").evently("account", app);
//$('#account').trigger('create');
});

var gP;
$(document).ready(function() {
//$db = $.couch.db('toiweb');
//$.couch.urlPrefix = "http://localhost:5984/toiweb/_design/toiweb";
$.couch.info({
success: function(data) {
console.log('info');
console.log(data);
}
});
$.couch.allDbs({
success: function(data) {
console.log('allDbs');
console.log(data);
}
});
/*
$.couch.login({
name: 'vijay',
password: 'vijay',
success: function(data) {
console.log('login');
console.log(data);
},
error: function(status) {
console.log(status);
}
});
*/
$.couch.db('toiweb').allDocs({
success: function(data) {
console.log('allDocs');
console.log(data);
}
});

$(document).evently({
_init: function() {
},
pageinit: function() {
},
keypress: function(e) {
$.couch.app(function(app) {
$("#account1").evently("account", app);
$("#account2").evently("account", app);
//$('#account').trigger('create');
});

//$db = $.couch.db('toiweb');
//$.couch.urlPrefix = "http://localhost:5984/toiweb/_design/toiweb";
$.couch.info({
success: function(data) {
console.log('info');
console.log(data);
}
});
$.couch.allDbs({
success: function(data) {
console.log('allDbs');
console.log(data);
}
});
/*
$.couch.login({
name: 'vijay',
password: 'vijay',
success: function(data) {
console.log('login');
console.log(data);
},
error: function(status) {
console.log(status);
}
});
*/
$.couch.db('toiweb').allDocs({
success: function(data) {
console.log('allDocs');
console.log(data);
}
});

$(document).evently({
_init: function() {
},
pageinit: function() {
},
keypress: function(e) {
//e.preventDefault();
},
keydown: function(e) {
if(e.which=='9') {
//e.preventDefault();
},
keydown: function(e) {
if(e.which=='9') {
//e.preventDefault();
} else if(e.which=='13') {
//e.preventDefault();
}
},
keyup: function(e) {
if(e.which=='9') {
//e.preventDefault();
} else if(e.which=='13') {
//e.preventDefault();
//$('#canvas').trigger("enter");
}
} else if(e.which=='13') {
//e.preventDefault();
}
},
keyup: function(e) {
if(e.which=='9') {
//e.preventDefault();
} else if(e.which=='13') {
//e.preventDefault();
//$('#canvas').trigger("enter");
}
});
}
});

$('#textarea1').evently({
_init: function() {
$(this).data('wordIndex',['',0,[]]);
$(this).data('phraseIndex',['',0,[],[]]);
$('#loginsubmit').evently({
_init: function() {
},
click: function() {
console.log('submit login');
var name = $('input[name=userid]').val();
var pass = $('input[name=userpass]').val();
console.log(name, pass);
$('#account1').trigger('doLogin', [name, pass]);
return false;
}
});
$('#signupsubmit').evently({
_init: function() {
},
click: function() {
console.log('submit signup');
var name = $('input[name=newuserid]').val();
var pass = $('input[name=newuserpass]').val();
console.log(name, pass);
$('#account1').trigger('doSignup', [name, pass]);
return false;
}
});

$(this).data('oldTime','');
$(this).data('paragraphIndex',{});
$(this).data('timeIndex',{});
$(this).data('assocIndex',{});
$('#textarea1').evently({
_init: function() {
$(this).data('wordIndex',['',0,[]]);
$(this).data('phraseIndex',['',0,[],[]]);

$(this).html('apple apartment application apart\nhello');
$(this).trigger('keyup');
},
keyup: function(e) {
var newTime = $.now();
var oldTime = $(this).data('oldTime');
$(this).data('oldTime','');
$(this).data('paragraphIndex',{});
$(this).data('timeIndex',{});
$(this).data('assocIndex',{});

// start word index
var lines = $(this).val().split('\n');
var words = [];
var allWords = [];
//console.log('lines');
//console.log(lines);
for (var i=0;i<lines.length;i++) {
//indexParagraph(lines.slice(i),time,$(this).data('paragraphIndex'));
words = lines[i].split(/ +/);
//console.log('words');
//console.log(words);
indexPhrase(words,$(this).data('phraseIndex'));
allWords = allWords.concat(lines[i].split(/ +/));
}
//console.log('allWords');
//console.log(allWords);
for (var i=0;i<allWords.length;i++) {
//for (var j=0;j<words[i].length;j++) {
$(this).html('apple apartment application apart\nhello');
$(this).trigger('keyup');
},
keyup: function(e) {
var newTime = $.now();
var oldTime = $(this).data('oldTime');

// start word index
var lines = $(this).val().split('\n');
var words = [];
var allWords = [];
//console.log('lines');
//console.log(lines);
for (var i=0;i<lines.length;i++) {
//indexParagraph(lines.slice(i),time,$(this).data('paragraphIndex'));
words = lines[i].split(/ +/);
//console.log('words');
//console.log(words);
indexPhrase(words,$(this).data('phraseIndex'));
allWords = allWords.concat(lines[i].split(/ +/));
}
//console.log('allWords');
//console.log(allWords);
for (var i=0;i<allWords.length;i++) {
//for (var j=0;j<words[i].length;j++) {
//console.log('indexing...'+words[i]);
indexWord(allWords[i],newTime,oldTime,$(this).data('wordIndex'));
//}
//indexPhrase(words.slice(i),time,$(this).data('phraseIndex'));
}
//console.log($(this).data('wordIndex'));
// end word index

$(this).data('oldTime',newTime);
}
});
//console.log($(this).data('wordIndex'));
// end word index

$('#textarea2').evently({
_init: function() {
$(this).data('oldTime',newTime);
}
});

},
keyup: function(e) {
var text = $(this).val();
var lines = text.split('\n');
var allWords = [];
for (var i=0;i<lines.length;i++) {
allWords = allWords.concat(lines[i].split(/ +/));
}
$('#textarea2').evently({
_init: function() {

var retrievalResult = retrieveWordQueryTree(text,$('#textarea1').data('wordIndex'),'','');
//console.log('retrievalResult: '+retrievalResult);
$('#feedback1').html(retrievalResult);
retrievalResult = retrievePhraseQueryTree(allWords,$('#textarea1').data('phraseIndex'),'','');
console.log(retrievalResult);
$('#feedback2').html(retrievalResult);
},
keyup: function(e) {
var text = $(this).val();
var lines = text.split('\n');
var allWords = [];
for (var i=0;i<lines.length;i++) {
allWords = allWords.concat(lines[i].split(/ +/));
}
});

var retrievalResult = retrieveWordQueryTree(text,$('#textarea1').data('wordIndex'),'','');
//console.log('retrievalResult: '+retrievalResult);
$('#feedback1').html(retrievalResult);
retrievalResult = retrievePhraseQueryTree(allWords,$('#textarea1').data('phraseIndex'),'','');
console.log(retrievalResult);
$('#feedback2').html(retrievalResult);
}
});
});
5 changes: 4 additions & 1 deletion vendor/couchapp/evently/account/_init.js
Expand Up @@ -5,14 +5,17 @@ function() {
success : function(r) {
var userCtx = r.userCtx;
if (userCtx.name) {
console.log('trigger loggedIn');
elem.trigger("loggedIn", [r]);
} else if (userCtx.roles.indexOf("_admin") != -1) {
console.log('trigger adminParty');
elem.trigger("adminParty");
} else {
console.log('trigger loggedOut');
elem.trigger("loggedOut");
};
//$('#input').trigger('create');
$('#input').page('destroy').page();
$('#query').page('destroy').page();
}
});
}
3 changes: 2 additions & 1 deletion vendor/couchapp/evently/account/doLogin.js
Expand Up @@ -4,7 +4,8 @@ function(e, name, pass) {
name : name,
password : pass,
success : function(r) {
$('.ui-dialog').dialog('close');
elem.trigger("_init")
}
});
}
}
3 changes: 2 additions & 1 deletion vendor/couchapp/evently/account/doSignup.js
Expand Up @@ -4,7 +4,8 @@ function(e, name, pass) {
name : name
}, pass, {
success : function() {
$('.ui-dialog').dialog('close');
elem.trigger("doLogin", [name, pass]);
}
});
}
}
3 changes: 2 additions & 1 deletion vendor/couchapp/evently/account/loggedIn/data.js
@@ -1,7 +1,8 @@
function(e, r) {
return {
title: $(this).parent().attr('id'),
name : r.userCtx.name,
uri_name : encodeURIComponent(r.userCtx.name),
auth_db : encodeURIComponent(r.info.authentication_db)
};
}
}

0 comments on commit e0e722e

Please sign in to comment.