{"_id":"_design/basic","_rev":"492-fb5f0fcc1023d7e8404b4c9b6625b946","vendor":{"couchapp":{"evently":{"profile":{"profileReady":{"after":"function(e, p) {\r\n $$(this).profile = p;\r\n};","data":"function(e, p) {\r\n return p\r\n}","mustache":"
Hello {{nickname}}!
\r\n"},"noProfile":{"data":"function(e, userCtx) {\r\n return userCtx;\r\n}","mustache":"","selectors":{"form":{"submit":"function() {\r\n var md5 = $$(this).app.require(\"vendor/couchapp/lib/md5\");\r\n \r\n // TODO this can be cleaned up with docForm?\r\n // it still needs the workflow to edit an existing profile\r\n var name = $(\"input[name=userCtxName]\",this).val();\r\n var newProfile = {\r\n rand : Math.random().toString(), \r\n nickname : $(\"input[name=nickname]\",this).val(),\r\n email : $(\"input[name=email]\",this).val(),\r\n url : $(\"input[name=url]\",this).val()\r\n }, widget = $(this);\r\n\r\n // setup gravatar_url\r\n if (md5) {\r\n newProfile.gravatar_url = 'http://www.gravatar.com/avatar/'+md5.hex(newProfile.email || newProfile.rand)+'.jpg?s=40&d=identicon'; \r\n }\r\n\r\n // store the user profile on the user account document\r\n $.couch.userDb(function(db) {\r\n var userDocId = \"org.couchdb.user:\"+name;\r\n db.openDoc(userDocId, {\r\n success : function(userDoc) {\r\n userDoc[\"couch.app.profile\"] = newProfile;\r\n db.saveDoc(userDoc, {\r\n success : function() {\r\n newProfile.name = userDoc.name;\r\n $$(widget).profile = newProfile;\r\n widget.trigger(\"profileReady\", [newProfile]);\r\n }\r\n });\r\n }\r\n });\r\n });\r\n return false;\r\n}"}}},"loggedIn":"function(e, r) {\r\n var userCtx = r.userCtx;\r\n var widget = $(this);\r\n // load the profile from the user doc\r\n var db = $.couch.db(r.info.authentication_db);\r\n var userDocId = \"org.couchdb.user:\"+userCtx.name;\r\n db.openDoc(userDocId, {\r\n success : function(userDoc) {\r\n var profile = userDoc[\"couch.app.profile\"];\r\n if (profile) {\r\n // we copy the name to the profile so it can be used later\r\n // without publishing the entire userdoc (roles, pass, etc)\r\n profile.name = userDoc.name;\r\n $$(widget).profile = profile;\r\n widget.trigger(\"profileReady\", [profile]);\r\n } else {\r\n widget.trigger(\"noProfile\", [userCtx]);\r\n }\r\n }\r\n });\r\n}","loggedOut":{"after":"function() {\r\n $$(this).profile = null;\r\n};","mustache":"Please log in to see your profile.
"}},"README":"## Starting the Document this code challenge\r\n\r\nI need help on this code. I only have so many hours in the day. Please be liberal about patching and hacking (and sharing code!) so we can all benefit. \r\n\r\nDocs patches are deeply appreciated. For now you can just stick Markdown files in the Docs directory.\r\n\r\n# Evently\r\n\r\nThese are some vendor Evently widgets that are running on the CouchApp system.\r\n\r\n## Account\r\n This is how you signup, login and logout without worry about the code.\r\n Todo, we could have this work against remote APIs like that Facebook stuff or whatever.\r\n\r\n\r\n## Profile\r\n Use this to load the local users profile for the logged in user. Useful if you're going to be posting new messages. Most applications end up customizing `profile.profileReady` to render the primary data-entry form. This gets you benefits like refreshing on login / logout, etc, automatically.\r\n\r\n\r\n## Docs\r\n This needs to be moved to it's own app.\r\n I have this vision of a docs app designed for offline editing, that involves each Markdown paragraph being it's own document, with automatic use of Bespin for code samples. Any help on this would be thanked much.","account":{"loggedIn":{"after":"function(e, r) {\r\n $$(this).userCtx = r.userCtx;\r\n $$(this).info = r.info;\r\n};","data":"function(e, r) {\r\n return {\r\n name : r.userCtx.name,\r\n uri_name : encodeURIComponent(r.userCtx.name),\r\n auth_db : encodeURIComponent(r.info.authentication_db)\r\n };\r\n}","mustache":"Welcome \r\n{{name}}! \r\nLogout?\r\n","selectors":{"a[href=#logout]":{"click":["doLogout"]}}},"loginForm":{"after":"function() {\r\n $(\"input[name=name]\", this).focus();\r\n}","mustache":"","selectors":{"form":{"submit":"function(e) {\r\n var name = $('input[name=name]', this).val(),\r\n pass = $('input[name=password]', this).val(); \r\n $(this).trigger('doLogin', [name, pass]);\r\n return false;\r\n}"},"a[href=#signup]":{"click":["signupForm"]}}},"_init":"function() {\r\n var elem = $(this);\r\n $$(this).userCtx = null;\r\n $.couch.session({\r\n success : function(r) {\r\n var userCtx = r.userCtx;\r\n if (userCtx.name) {\r\n elem.trigger(\"loggedIn\", [r]);\r\n } else if (userCtx.roles.indexOf(\"_admin\") != -1) {\r\n elem.trigger(\"adminParty\");\r\n } else {\r\n elem.trigger(\"loggedOut\");\r\n };\r\n }\r\n });\r\n}","doLogout":"function() {\r\n var elem = $(this);\r\n $.couch.logout({\r\n success : function() {\r\n elem.trigger(\"_init\");\r\n }\r\n });\r\n}","loggedOut":{"mustache":"Signup or Login","selectors":{"a[href=#login]":{"click":["loginForm"]},"a[href=#signup]":{"click":["signupForm"]}}},"adminParty":{"mustache":"Admin party, everyone is admin! Fix this in Futon before proceeding.
"},"doSignup":"function(e, name, pass) {\r\n var elem = $(this);\r\n $.couch.signup({\r\n name : name\r\n }, pass, {\r\n success : function() {\r\n elem.trigger(\"doLogin\", [name, pass]);\r\n }\r\n });\r\n}","signupForm":{"after":"function() {\r\n $(\"input[name=name]\", this).focus();\r\n}","mustache":"","selectors":{"a[href=#login]":{"click":["loginForm"]},"form":{"submit":"function(e) {\r\n var name = $('input[name=name]', this).val(),\r\n pass = $('input[name=password]', this).val(); \r\n $(this).trigger('doSignup', [name, pass]);\r\n return false;\r\n}"}}},"doLogin":"function(e, name, pass) {\r\n var elem = $(this);\r\n $.couch.login({\r\n name : name,\r\n password : pass,\r\n success : function(r) {\r\n elem.trigger(\"_init\")\r\n }\r\n }); \r\n}"}},"lib":{"redirect":"exports.permanent = function(redirect) {\r\n return {\r\n code : 301,\r\n headers : {\r\n \"Location\" : redirect\r\n }\r\n };\r\n};","code":"exports.ddoc = function(ddoc) {\r\n // only return the parts of the app that we use\r\n var i, j, path, key, obj, ref, out = {},\r\n resources = ddoc.couchapp && ddoc.couchapp.load && ddoc.couchapp.load.app || [];\r\n for (i=0; i < resources.length; i++) {\r\n path = resources[i].split('/');\r\n obj = ddoc;\r\n ref = out;\r\n for (j=0; j < path.length; j++) {\r\n key = path[j];\r\n ref[key] = ref[key] || {};\r\n if (j < path.length - 1) {\r\n obj = obj[key];\r\n ref = ref[key];\r\n }\r\n };\r\n ref[key] = obj[key];\r\n };\r\n return out;\r\n};","utils":"exports.prettyDate = function(time){\r\n \r\n\tvar date = new Date(time.replace(/-/g,\"/\").replace(\"T\", \" \").replace(\"Z\", \" +0000\").replace(/(\\d*\\:\\d*:\\d*)\\.\\d*/g,\"$1\")),\r\n\t\tdiff = (((new Date()).getTime() - date.getTime()) / 1000),\r\n\t\tday_diff = Math.floor(diff / 86400);\r\n\r\n if (isNaN(day_diff)) return time;\r\n\r\n\treturn day_diff < 1 && (\r\n\t\t\tdiff < 60 && \"just now\" ||\r\n\t\t\tdiff < 120 && \"1 minute ago\" ||\r\n\t\t\tdiff < 3600 && Math.floor( diff / 60 ) + \" minutes ago\" ||\r\n\t\t\tdiff < 7200 && \"1 hour ago\" ||\r\n\t\t\tdiff < 86400 && Math.floor( diff / 3600 ) + \" hours ago\") ||\r\n\t\tday_diff == 1 && \"yesterday\" ||\r\n\t\tday_diff < 21 && day_diff + \" days ago\" ||\r\n\t\tday_diff < 45 && Math.ceil( day_diff / 7 ) + \" weeks ago\" ||\r\n time;\r\n // day_diff < 730 && Math.ceil( day_diff / 31 ) + \" months ago\" ||\r\n // Math.ceil( day_diff / 365 ) + \" years ago\";\r\n};","cache":"exports.get = function(db, docid, setFun, getFun) {\r\n db.openDoc(docid, {\r\n success : function(doc) {\r\n getFun(doc.cache);\r\n },\r\n error : function() {\r\n setFun(function(cache) {\r\n db.saveDoc({\r\n _id : docid,\r\n cache : cache\r\n });\r\n getFun(cache);\r\n });\r\n }\r\n });\r\n};\r\n\r\nexports.clear = function(db, docid) {\r\n db.openDoc(docid, {\r\n success : function(doc) {\r\n db.removeDoc(doc);\r\n },\r\n error : function() {}\r\n });\r\n};","list":"// Helpers for writing server-side _list functions in CouchDB\r\nexports.withRows = function(fun) {\r\n var f = function() {\r\n var row = getRow();\r\n return row && fun(row);\r\n };\r\n f.iterator = true;\r\n return f;\r\n}\r\n\r\nexports.send = function(chunk) {\r\n send(chunk + \"\\n\")\r\n}","linkup":"// this code makes http://example.com into a link, \r\n// and also handles @name and #hashtag\r\n\r\n// todo add [[wiki_links]]\r\n\r\nvar mustache = require(\"vendor/couchapp/lib/mustache\");\r\nexports.encode = function(body, person_prefix, tag_prefix) {\r\n body = mustache.escape(body);\r\n person_prefix = person_prefix || \"http://twitter.com/\";\r\n tag_prefix = tag_prefix || \"http://delicious.com/tag/\";\r\n return body.replace(/((ftp|http|https):\\/\\/(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(\\/|\\/([\\w#!:.?+=&%@!\\-\\/]))?)/gi,function(a) {\r\n return ''+a+'';\r\n }).replace(/\\@([\\w\\-]+)/g,function(user,name) {\r\n return ''+user+'';\r\n }).replace(/\\#([\\w\\-\\.]+)/g,function(word,tag) {\r\n return ''+word+'';\r\n });\r\n};","markdown":"//\r\n// showdown.js -- A javascript port of Markdown.\r\n//\r\n// Copyright (c) 2007 John Fraser.\r\n//\r\n// Original Markdown Copyright (c) 2004-2005 John Gruber\r\n//s around\r\n\t// \"paragraphs\" that are wrapped in non-block-level tags, such as anchors,\r\n\t// phrase emphasis, and spans. The list of tags we're looking for is\r\n\t// hard-coded:\r\n\tvar block_tags_a = \"p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del\"\r\n\tvar block_tags_b = \"p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math\"\r\n\r\n\t// First, look for nested blocks, e.g.:\r\n\t//
tags around block-level tags.\r\n\ttext = _HashHTMLBlocks(text);\r\n\ttext = _FormParagraphs(text);\r\n\r\n\treturn text;\r\n}\r\n\r\n\r\nvar _RunSpanGamut = function(text) {\r\n//\r\n// These are all the transformations that occur *within* block-level\r\n// tags like paragraphs, headers, and list items.\r\n//\r\n\r\n\ttext = _DoCodeSpans(text);\r\n\ttext = _EscapeSpecialCharsWithinTagAttributes(text);\r\n\ttext = _EncodeBackslashEscapes(text);\r\n\r\n\t// Process anchor and image tags. Images must come first,\r\n\t// because ![foo][f] looks like an anchor.\r\n\ttext = _DoImages(text);\r\n\ttext = _DoAnchors(text);\r\n\r\n\t// Make links out of things like ` Just type tags\r\n//\r\n\r\n\t// Strip leading and trailing lines:\r\n\ttext = text.replace(/^\\n+/g,\"\");\r\n\ttext = text.replace(/\\n+$/g,\"\");\r\n\r\n\tvar grafs = text.split(/\\n{2,}/g);\r\n\tvar grafsOut = new Array();\r\n\r\n\t//\r\n\t// Wrap tags.\r\n\t//\r\n\tvar end = grafs.length;\r\n\tfor (var i=0; i \");\r\n\t\t\tstr += \" Most applications will customize this template (ddoc.evently.profile.profileReady.mustache) for user input. Customize this format here: ddoc.evently.items._changes.mustache {{message}} Protip: If you setup continuous replication between this database and a remote one, this list will reflect remote changes in near real-time. This would be a good place to add pagination.
\\n\");\r\n\r\n\treturn text;\r\n}\r\n\r\nvar _EscapeSpecialCharsWithinTagAttributes = function(text) {\r\n//\r\n// Within tags -- meaning between < and > -- encode [\\ ` * _] so they\r\n// don't conflict with their use in Markdown for code, italics and strong.\r\n//\r\n\r\n\t// Build a regex to find HTML tags and comments. See Friedl's \r\n\t// \"Mastering Regular Expressions\", 2nd Ed., pp. 200-201.\r\n\tvar regex = /(<[a-z\\/!$](\"[^\"]*\"|'[^']*'|[^'\">])*>|)/gi;\r\n\r\n\ttext = text.replace(regex, function(wholeMatch) {\r\n\t\tvar tag = wholeMatch.replace(/(.)<\\/?code>(?=.)/g,\"$1`\");\r\n\t\ttag = escapeCharacters(tag,\"\\\\`*_\");\r\n\t\treturn tag;\r\n\t});\r\n\r\n\treturn text;\r\n}\r\n\r\nvar _DoAnchors = function(text) {\r\n//\r\n// Turn Markdown link shortcuts into XHTML tags.\r\n//\r\n\t//\r\n\t// First, handle reference-style links: [link text] [id]\r\n\t//\r\n\r\n\t/*\r\n\t\ttext = text.replace(/\r\n\t\t(\t\t\t\t\t\t\t// wrap whole match in $1\r\n\t\t\t\\[\r\n\t\t\t(\r\n\t\t\t\t(?:\r\n\t\t\t\t\t\\[[^\\]]*\\]\t\t// allow brackets nested one level\r\n\t\t\t\t\t|\r\n\t\t\t\t\t[^\\[]\t\t\t// or anything else\r\n\t\t\t\t)*\r\n\t\t\t)\r\n\t\t\t\\]\r\n\r\n\t\t\t[ ]?\t\t\t\t\t// one optional space\r\n\t\t\t(?:\\n[ ]*)?\t\t\t\t// one optional newline followed by spaces\r\n\r\n\t\t\t\\[\r\n\t\t\t(.*?)\t\t\t\t\t// id = $3\r\n\t\t\t\\]\r\n\t\t)()()()()\t\t\t\t\t// pad remaining backreferences\r\n\t\t/g,_DoAnchors_callback);\r\n\t*/\r\n\ttext = text.replace(/(\\[((?:\\[[^\\]]*\\]|[^\\[\\]])*)\\][ ]?(?:\\n[ ]*)?\\[(.*?)\\])()()()()/g,writeAnchorTag);\r\n\r\n\t//\r\n\t// Next, inline-style links: [link text](url \"optional title\")\r\n\t//\r\n\r\n\t/*\r\n\t\ttext = text.replace(/\r\n\t\t\t(\t\t\t\t\t\t// wrap whole match in $1\r\n\t\t\t\t\\[\r\n\t\t\t\t(\r\n\t\t\t\t\t(?:\r\n\t\t\t\t\t\t\\[[^\\]]*\\]\t// allow brackets nested one level\r\n\t\t\t\t\t|\r\n\t\t\t\t\t[^\\[\\]]\t\t\t// or anything else\r\n\t\t\t\t)\r\n\t\t\t)\r\n\t\t\t\\]\r\n\t\t\t\\(\t\t\t\t\t\t// literal paren\r\n\t\t\t[ \\t]*\r\n\t\t\t()\t\t\t\t\t\t// no id, so leave $3 empty\r\n\t\t\t(.*?)>?\t\t\t\t// href = $4\r\n\t\t\t[ \\t]*\r\n\t\t\t(\t\t\t\t\t\t// $5\r\n\t\t\t\t(['\"])\t\t\t\t// quote char = $6\r\n\t\t\t\t(.*?)\t\t\t\t// Title = $7\r\n\t\t\t\t\\6\t\t\t\t\t// matching quote\r\n\t\t\t\t[ \\t]*\t\t\t\t// ignore any spaces/tabs between closing quote and )\r\n\t\t\t)?\t\t\t\t\t\t// title is optional\r\n\t\t\t\\)\r\n\t\t)\r\n\t\t/g,writeAnchorTag);\r\n\t*/\r\n\ttext = text.replace(/(\\[((?:\\[[^\\]]*\\]|[^\\[\\]])*)\\]\\([ \\t]*()(.*?)>?[ \\t]*((['\"])(.*?)\\6[ \\t]*)?\\))/g,writeAnchorTag);\r\n\r\n\t//\r\n\t// Last, handle reference-style shortcuts: [link text]\r\n\t// These must come last in case you've also got [link test][1]\r\n\t// or [link test](/foo)\r\n\t//\r\n\r\n\t/*\r\n\t\ttext = text.replace(/\r\n\t\t(\t\t \t\t\t\t\t// wrap whole match in $1\r\n\t\t\t\\[\r\n\t\t\t([^\\[\\]]+)\t\t\t\t// link text = $2; can't contain '[' or ']'\r\n\t\t\t\\]\r\n\t\t)()()()()()\t\t\t\t\t// pad rest of backreferences\r\n\t\t/g, writeAnchorTag);\r\n\t*/\r\n\ttext = text.replace(/(\\[([^\\[\\]]+)\\])()()()()()/g, writeAnchorTag);\r\n\r\n\treturn text;\r\n}\r\n\r\nvar writeAnchorTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {\r\n\tif (m7 == undefined) m7 = \"\";\r\n\tvar whole_match = m1;\r\n\tvar link_text = m2;\r\n\tvar link_id\t = m3.toLowerCase();\r\n\tvar url\t\t= m4;\r\n\tvar title\t= m7;\r\n\t\r\n\tif (url == \"\") {\r\n\t\tif (link_id == \"\") {\r\n\t\t\t// lower-case and turn embedded newlines into spaces\r\n\t\t\tlink_id = link_text.toLowerCase().replace(/ ?\\n/g,\" \");\r\n\t\t}\r\n\t\turl = \"#\"+link_id;\r\n\t\t\r\n\t\tif (g_urls[link_id] != undefined) {\r\n\t\t\turl = g_urls[link_id];\r\n\t\t\tif (g_titles[link_id] != undefined) {\r\n\t\t\t\ttitle = g_titles[link_id];\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\tif (whole_match.search(/\\(\\s*\\)$/m)>-1) {\r\n\t\t\t\t// Special case for explicit empty url\r\n\t\t\t\turl = \"\";\r\n\t\t\t} else {\r\n\t\t\t\treturn whole_match;\r\n\t\t\t}\r\n\t\t}\r\n\t}\t\r\n\t\r\n\turl = escapeCharacters(url,\"*_\");\r\n\tvar result = \"\" + link_text + \"\";\r\n\t\r\n\treturn result;\r\n}\r\n\r\n\r\nvar _DoImages = function(text) {\r\n//\r\n// Turn Markdown image shortcuts into tags.\r\n//\r\n\r\n\t//\r\n\t// First, handle reference-style labeled images: ![alt text][id]\r\n\t//\r\n\r\n\t/*\r\n\t\ttext = text.replace(/\r\n\t\t(\t\t\t\t\t\t// wrap whole match in $1\r\n\t\t\t!\\[\r\n\t\t\t(.*?)\t\t\t\t// alt text = $2\r\n\t\t\t\\]\r\n\r\n\t\t\t[ ]?\t\t\t\t// one optional space\r\n\t\t\t(?:\\n[ ]*)?\t\t\t// one optional newline followed by spaces\r\n\r\n\t\t\t\\[\r\n\t\t\t(.*?)\t\t\t\t// id = $3\r\n\t\t\t\\]\r\n\t\t)()()()()\t\t\t\t// pad rest of backreferences\r\n\t\t/g,writeImageTag);\r\n\t*/\r\n\ttext = text.replace(/(!\\[(.*?)\\][ ]?(?:\\n[ ]*)?\\[(.*?)\\])()()()()/g,writeImageTag);\r\n\r\n\t//\r\n\t// Next, handle inline images: ![alt text](url \"optional title\")\r\n\t// Don't forget: encode * and _\r\n\r\n\t/*\r\n\t\ttext = text.replace(/\r\n\t\t(\t\t\t\t\t\t// wrap whole match in $1\r\n\t\t\t!\\[\r\n\t\t\t(.*?)\t\t\t\t// alt text = $2\r\n\t\t\t\\]\r\n\t\t\t\\s?\t\t\t\t\t// One optional whitespace character\r\n\t\t\t\\(\t\t\t\t\t// literal paren\r\n\t\t\t[ \\t]*\r\n\t\t\t()\t\t\t\t\t// no id, so leave $3 empty\r\n\t\t\t(\\S+?)>?\t\t\t// src url = $4\r\n\t\t\t[ \\t]*\r\n\t\t\t(\t\t\t\t\t// $5\r\n\t\t\t\t(['\"])\t\t\t// quote char = $6\r\n\t\t\t\t(.*?)\t\t\t// title = $7\r\n\t\t\t\t\\6\t\t\t\t// matching quote\r\n\t\t\t\t[ \\t]*\r\n\t\t\t)?\t\t\t\t\t// title is optional\r\n\t\t\\)\r\n\t\t)\r\n\t\t/g,writeImageTag);\r\n\t*/\r\n\ttext = text.replace(/(!\\[(.*?)\\]\\s?\\([ \\t]*()(\\S+?)>?[ \\t]*((['\"])(.*?)\\6[ \\t]*)?\\))/g,writeImageTag);\r\n\r\n\treturn text;\r\n}\r\n\r\nvar writeImageTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {\r\n\tvar whole_match = m1;\r\n\tvar alt_text = m2;\r\n\tvar link_id\t = m3.toLowerCase();\r\n\tvar url\t\t= m4;\r\n\tvar title\t= m7;\r\n\r\n\tif (!title) title = \"\";\r\n\t\r\n\tif (url == \"\") {\r\n\t\tif (link_id == \"\") {\r\n\t\t\t// lower-case and turn embedded newlines into spaces\r\n\t\t\tlink_id = alt_text.toLowerCase().replace(/ ?\\n/g,\" \");\r\n\t\t}\r\n\t\turl = \"#\"+link_id;\r\n\t\t\r\n\t\tif (g_urls[link_id] != undefined) {\r\n\t\t\turl = g_urls[link_id];\r\n\t\t\tif (g_titles[link_id] != undefined) {\r\n\t\t\t\ttitle = g_titles[link_id];\r\n\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\treturn whole_match;\r\n\t\t}\r\n\t}\t\r\n\t\r\n\talt_text = alt_text.replace(/\"/g,\""\");\r\n\turl = escapeCharacters(url,\"*_\");\r\n\tvar result = \"\";\r\n\t\r\n\treturn result;\r\n}\r\n\r\n\r\nvar _DoHeaders = function(text) {\r\n\r\n\t// Setext-style headers:\r\n\t//\tHeader 1\r\n\t//\t========\r\n\t// \r\n\t//\tHeader 2\r\n\t//\t--------\r\n\t//\r\n\ttext = text.replace(/^(.+)[ \\t]*\\n=+[ \\t]*\\n+/gm,\r\n\t\tfunction(wholeMatch,m1){return hashBlock(\"\" + _RunSpanGamut(m1) + \"
\");});\r\n\r\n\ttext = text.replace(/^(.+)[ \\t]*\\n-+[ \\t]*\\n+/gm,\r\n\t\tfunction(matchFound,m1){return hashBlock(\"\" + _RunSpanGamut(m1) + \"
\");});\r\n\r\n\t// atx-style headers:\r\n\t// # Header 1\r\n\t// ## Header 2\r\n\t// ## Header 2 with closing hashes ##\r\n\t// ...\r\n\t// ###### Header 6\r\n\t//\r\n\r\n\t/*\r\n\t\ttext = text.replace(/\r\n\t\t\t^(\\#{1,6})\t\t\t\t// $1 = string of #'s\r\n\t\t\t[ \\t]*\r\n\t\t\t(.+?)\t\t\t\t\t// $2 = Header text\r\n\t\t\t[ \\t]*\r\n\t\t\t\\#*\t\t\t\t\t\t// optional closing #'s (not counted)\r\n\t\t\t\\n+\r\n\t\t/gm, function() {...});\r\n\t*/\r\n\r\n\ttext = text.replace(/^(\\#{1,6})[ \\t]*(.+?)[ \\t]*\\#*\\n+/gm,\r\n\t\tfunction(wholeMatch,m1,m2) {\r\n\t\t\tvar h_level = m1.length;\r\n\t\t\treturn hashBlock(\"` blocks.\r\n// \r\n\r\n\t/*\r\n\t\ttext = text.replace(text,\r\n\t\t\t/(?:\\n\\n|^)\r\n\t\t\t(\t\t\t\t\t\t\t\t// $1 = the code block -- one or more lines, starting with a space/tab\r\n\t\t\t\t(?:\r\n\t\t\t\t\t(?:[ ]{4}|\\t)\t\t\t// Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width\r\n\t\t\t\t\t.*\\n+\r\n\t\t\t\t)+\r\n\t\t\t)\r\n\t\t\t(\\n*[ ]{0,3}[^ \\t\\n]|(?=~0))\t// attacklab: g_tab_width\r\n\t\t/g,function(){...});\r\n\t*/\r\n\r\n\t// attacklab: sentinel workarounds for lack of \\A and \\Z, safari\\khtml bug\r\n\ttext += \"~0\";\r\n\t\r\n\ttext = text.replace(/(?:\\n\\n|^)((?:(?:[ ]{4}|\\t).*\\n+)+)(\\n*[ ]{0,3}[^ \\t\\n]|(?=~0))/g,\r\n\t\tfunction(wholeMatch,m1,m2) {\r\n\t\t\tvar codeblock = m1;\r\n\t\t\tvar nextChar = m2;\r\n\t\t\r\n\t\t\tcodeblock = _EncodeCode( _Outdent(codeblock));\r\n\t\t\tcodeblock = _Detab(codeblock);\r\n\t\t\tcodeblock = codeblock.replace(/^\\n+/g,\"\"); // trim leading newlines\r\n\t\t\tcodeblock = codeblock.replace(/\\n+$/g,\"\"); // trim trailing whitespace\r\n\r\n\t\t\tcodeblock = \"
\";\r\n\r\n\t\t\treturn hashBlock(codeblock) + nextChar;\r\n\t\t}\r\n\t);\r\n\r\n\t// attacklab: strip sentinel\r\n\ttext = text.replace(/~0/,\"\");\r\n\r\n\treturn text;\r\n}\r\n\r\nvar hashBlock = function(text) {\r\n\ttext = text.replace(/(^\\n+|\\n+$)/g,\"\");\r\n\treturn \"\\n\\n~K\" + (g_html_blocks.push(text)-1) + \"K\\n\\n\";\r\n}\r\n\r\n\r\nvar _DoCodeSpans = function(text) {\r\n//\r\n// * Backtick quotes are used for \" + codeblock + \"\\n
spans.\r\n// \r\n// * You can use multiple backticks as the delimiters if you want to\r\n//\t include literal backticks in the code span. So, this input:\r\n//\t \r\n//\t\t Just type ``foo `bar` baz`` at the prompt.\r\n//\t \r\n//\t Will translate to:\r\n//\t \r\n//\t\t
foo `bar` baz
at the prompt.`bar`
...\r\n//\r\n\r\n\t/*\r\n\t\ttext = text.replace(/\r\n\t\t\t(^|[^\\\\])\t\t\t\t\t// Character before opening ` can't be a backslash\r\n\t\t\t(`+)\t\t\t\t\t\t// $2 = Opening run of `\r\n\t\t\t(\t\t\t\t\t\t\t// $3 = The code block\r\n\t\t\t\t[^\\r]*?\r\n\t\t\t\t[^`]\t\t\t\t\t// attacklab: work around lack of lookbehind\r\n\t\t\t)\r\n\t\t\t\\2\t\t\t\t\t\t\t// Matching closer\r\n\t\t\t(?!`)\r\n\t\t/gm, function(){...});\r\n\t*/\r\n\r\n\ttext = text.replace(/(^|[^\\\\])(`+)([^\\r]*?[^`])\\2(?!`)/gm,\r\n\t\tfunction(wholeMatch,m1,m2,m3,m4) {\r\n\t\t\tvar c = m3;\r\n\t\t\tc = c.replace(/^([ \\t]*)/g,\"\");\t// leading whitespace\r\n\t\t\tc = c.replace(/[ \\t]*$/g,\"\");\t// trailing whitespace\r\n\t\t\tc = _EncodeCode(c);\r\n\t\t\treturn m1+\"\"+c+\"
\";\r\n\t\t});\r\n\r\n\treturn text;\r\n}\r\n\r\n\r\nvar _EncodeCode = function(text) {\r\n//\r\n// Encode/escape certain characters inside Markdown code runs.\r\n// The point is that in code, these characters are literals,\r\n// and lose their special Markdown meanings.\r\n//\r\n\t// Encode all ampersands; HTML entities are not\r\n\t// entities within a Markdown code span.\r\n\ttext = text.replace(/&/g,\"&\");\r\n\r\n\t// Do the angle bracket song and dance:\r\n\ttext = text.replace(//g,\">\");\r\n\r\n\t// Now, escape characters that are magic in Markdown:\r\n\ttext = escapeCharacters(text,\"\\*_{}[]\\\\\",false);\r\n\r\n// jj the line above breaks this:\r\n//---\r\n\r\n//* Item\r\n\r\n// 1. Subitem\r\n\r\n// special char: *\r\n//---\r\n\r\n\treturn text;\r\n}\r\n\r\n\r\nvar _DoItalicsAndBold = function(text) {\r\n\r\n\t// must go first:\r\n\ttext = text.replace(/(\\*\\*|__)(?=\\S)([^\\r]*?\\S[*_]*)\\1/g,\r\n\t\t\"$2\");\r\n\r\n\ttext = text.replace(/(\\*|_)(?=\\S)([^\\r]*?\\S)\\1/g,\r\n\t\t\"$2\");\r\n\r\n\treturn text;\r\n}\r\n\r\n\r\nvar _DoBlockQuotes = function(text) {\r\n\r\n\t/*\r\n\t\ttext = text.replace(/\r\n\t\t(\t\t\t\t\t\t\t\t// Wrap whole match in $1\r\n\t\t\t(\r\n\t\t\t\t^[ \\t]*>[ \\t]?\t\t\t// '>' at the start of a line\r\n\t\t\t\t.+\\n\t\t\t\t\t// rest of the first line\r\n\t\t\t\t(.+\\n)*\t\t\t\t\t// subsequent consecutive lines\r\n\t\t\t\t\\n*\t\t\t\t\t\t// blanks\r\n\t\t\t)+\r\n\t\t)\r\n\t\t/gm, function(){...});\r\n\t*/\r\n\r\n\ttext = text.replace(/((^[ \\t]*>[ \\t]?.+\\n(.+\\n)*\\n*)+)/gm,\r\n\t\tfunction(wholeMatch,m1) {\r\n\t\t\tvar bq = m1;\r\n\r\n\t\t\t// attacklab: hack around Konqueror 3.5.4 bug:\r\n\t\t\t// \"----------bug\".replace(/^-/g,\"\") == \"bug\"\r\n\r\n\t\t\tbq = bq.replace(/^[ \\t]*>[ \\t]?/gm,\"~0\");\t// trim one level of quoting\r\n\r\n\t\t\t// attacklab: clean up hack\r\n\t\t\tbq = bq.replace(/~0/g,\"\");\r\n\r\n\t\t\tbq = bq.replace(/^[ \\t]+$/gm,\"\");\t\t// trim whitespace-only lines\r\n\t\t\tbq = _RunBlockGamut(bq);\t\t\t\t// recurse\r\n\t\t\t\r\n\t\t\tbq = bq.replace(/(^|\\n)/g,\"$1 \");\r\n\t\t\t// These leading spaces screw with content, so we need to fix that:\r\n\t\t\tbq = bq.replace(\r\n\t\t\t\t\t/(\\s*
[^\\r]+?<\\/pre>)/gm,\r\n\t\t\t\tfunction(wholeMatch,m1) {\r\n\t\t\t\t\tvar pre = m1;\r\n\t\t\t\t\t// attacklab: hack around Konqueror 3.5.4 bug:\r\n\t\t\t\t\tpre = pre.replace(/^ /mg,\"~0\");\r\n\t\t\t\t\tpre = pre.replace(/~0/g,\"\");\r\n\t\t\t\t\treturn pre;\r\n\t\t\t\t});\r\n\t\t\t\r\n\t\t\treturn hashBlock(\"
\\n\" + bq + \"\\n
\");\r\n\t\t});\r\n\treturn text;\r\n}\r\n\r\n\r\nvar _FormParagraphs = function(text) {\r\n//\r\n// Params:\r\n// $text - string to process with html
';\r\n\t\t\tx = x + '' + doc.miRNA + ' Vs ' + doc.Gene_Symbol + '
';\r\n\t\t\t\r\n\t\t\tx = x + 'mature miRNA: ' + '' + row.value + '';\r\n\t\t\tx = x + '';\r\n\t\t\tfor (var method in doc.mat_miRNA[row.value]) {\r\n\t\t\t\tif(method == \"mirTarBase\") {\r\n\t\t\t\t\tx = x + '
';\r\n\t\t\tsend(x);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tsend(row.value + \"\\n\");\r\n\t\t}\r\n }\r\n};","sort":"function(head, req) {\r\n\tvar row\r\n\tvar rows=[]\r\n\twhile(row = getRow()) {\r\n\t\trows.push(row) \r\n\t}\r\n\trows.sort(function(a,b) {\r\n\t\treturn b.value-a.value\r\n\t})\r\n\tsend(JSON.stringify({\"rows\" : rows}))\r\n}","matureMIRinteraction":"function(head, req) {\r\n var row;\r\n start({ \"headers\": { \"Content-Type\": \"text/html\" }});\r\n var geneHash = {};\r\n\tvar tx = 'Search targetHub with miRBase ID or Gene ID for target data illustration across prediction methods';\r\n\tsend(tx);\t\t\r\n\twhile (row = getRow()) {\r\n\t\tif (row.doc) {\r\n\t\t\tvar doc = row.doc;\r\n\t\t\tvar x = '';\r\n\t\t\tif(geneHash[doc.Gene_EntrezID] == 1) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\telse { \r\n\t\t\t\tgeneHash[doc.Gene_EntrezID] = 1\r\n\t\t\t}\r\n\t\t\tvar key = new String(row.key);\r\n\t\t\tvar matmiRNA=key.split(\",\");\r\n\t\t\tx = '';\r\n\t\t\t\t\tx = x + '
';\r\n\t\t\t\t} else if(method == \"miRanda\") {\r\n\t\t\t\t\t\tx = x + '';\r\n\t\t\t\t\t\tfor(var transcript in doc.mat_miRNA[row.value][method]) {\r\n\t\t\t\t\t\t\tx = x + '
';\r\n\t\t\t\t} else if((method == \"picTar5\") || (method == \"picTar4\")) {\r\n\t\t\t\t\t\tx = x + '';\r\n\t\t\t\t\t\tfor(var transcript in doc.mat_miRNA[row.value][method]) {\r\n\t\t\t\t\t\t\tx = x + '
';\r\n\t\t\t\t} else if(method == \"targetScan\") {\r\n\t\t\t\t\t\tx = x + '';\r\n\t\t\t\t\t\tfor(var transcript in doc.mat_miRNA[row.value][method]) {\r\n\t\t\t\t\t\t\tx = x + '
';\r\n\t\t\t\t} \r\n\t\t\t}\t\r\n\t\t\tx = x + '
';\r\n\t\t\tx = x + '' + doc.Gene_Symbol + '
';\r\n\t\t\tx = x + '';\r\n\t\t\tfor (var method in doc.mat_miRNA[matmiRNA[0]]) {\r\n\t\t\t\tif(method == \"mirTarBase\") {\r\n\t\t\t\t\tx = x + '
';\r\n\t\t\tsend(x);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tsend(row.value + \"\\n\");\r\n\t\t}\r\n }\r\n};","miRbase":"function(head, req) {\r\n var row;\r\n start({ \"headers\": { \"Content-Type\": \"text/html\" }});\r\n while (row = getRow()) {\r\n\t\tsend(row.value);\r\n\t\t}\r\n};","matureMIRinteractionTSV":"function(head, req) {\r\n var row; var headers;\r\n start({\r\n\t\t'headers': {\r\n\t\t\t'Content-Type': 'application/targethub-results; charset=utf-8; header=present',\r\n\t\t\t'Content-Disposition' : 'attachment; filename=\"results_targetHub.tsv\"'\r\n\t\t}\r\n\t});\r\n var geneHash = {};\r\n\twhile (row = getRow()) {\r\n\t\tif(!headers) {\r\n\t\t\theaders = \"matureMIRNA\" + '\\t' + \"geneSymbol\" + '\\t' + \"geneID\" + '\\t' + \"method\" + '\\t' + \"transcript\" + '\\t' + \"param1\" + '\\t' + \"param2\" + '\\t' + \"param3\" + '\\t' + \"param4\" + '\\n';\r\n\t\t\tsend(headers);\r\n\t\t}\r\n\t\tif (row.doc) {\r\n\t\t\tvar doc = row.doc;\r\n\t\t\tvar x = '';\r\n\t\t\tif(geneHash[doc.Gene_EntrezID] == 1) {\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\telse { \r\n\t\t\t\tgeneHash[doc.Gene_EntrezID] = 1\r\n\t\t\t}\r\n\t\t\tvar key = new String(row.key);\r\n\t\t\tvar matmiRNA=key.split(\",\");\r\n\t\t\tfor (var method in doc.mat_miRNA[matmiRNA[0]]) {\r\n\t\t\t\tif(method == \"mirTarBase\") {\r\n\t\t\t\t\tx = x + matmiRNA[0] + '\\t' + doc.Gene_Symbol + '\\t' + doc.Gene_EntrezID + '\\t';\r\n\t\t\t\t\tx = x + 'mirTarBase' + '\\t';\r\n\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method].experiments;\r\n\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method].supportType;\r\n\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method].interactionID;\r\n\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method].pubmedID;\r\n\t\t\t\t\tx = x + '\\n';\r\n\t\t\t\t} else if(method == \"miRanda\") {\r\n\t\t\t\t\t\tfor(var transcript in doc.mat_miRNA[matmiRNA[0]][method]) {\r\n\t\t\t\t\t\t\tx = x + matmiRNA[0] + '\\t' + doc.Gene_Symbol + '\\t' + doc.Gene_EntrezID + '\\t';\r\n\t\t\t\t\t\t\tx = x + 'miRanda';\r\n\t\t\t\t\t\t\tx = x + '\\t' + transcript;\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method][transcript][\"Tot.Score\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method][transcript][\"Tot.Energy\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method][transcript][\"TranscriptLoc\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method][transcript][\"Position\"];\r\n\t\t\t\t\t\t\tx = x + '\\n';\r\n\t\t\t\t\t\t}\r\n\t\t\t\t} else if((method == \"picTar5\") || (method == \"picTar4\")) {\r\n\t\t\t\t\t\tfor(var transcript in doc.mat_miRNA[matmiRNA[0]][method]) {\r\n\t\t\t\t\t\t\tx = x + matmiRNA[0] + '\\t' + doc.Gene_Symbol + '\\t' + doc.Gene_EntrezID + '\\t';\r\n\t\t\t\t\t\t\tx = x + method;\r\n\t\t\t\t\t\t\tx = x + '\\t' + transcript;\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method][transcript][\"score\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method][transcript][\"siteChr\"] + ':'+ doc.mat_miRNA[matmiRNA[0]][method][transcript][\"siteStart\"] + ':' + doc.mat_miRNA[matmiRNA[0]][method][transcript][\"siteEnd\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method][transcript][\"miRname\"];\r\n\t\t\t\t\t\t\tx = x + '\\n';\r\n\t\t\t\t\t\t}\r\n\t\t\t\t} else if(method == \"targetScan\") {\r\n\t\t\t\t\t\tfor(var transcript in doc.mat_miRNA[matmiRNA[0]][method]) {\r\n\t\t\t\t\t\t\tx = x + matmiRNA[0] + '\\t' + doc.Gene_Symbol + '\\t' + doc.Gene_EntrezID + '\\t';\r\n\t\t\t\t\t\t\tx = x + method;\r\n\t\t\t\t\t\t\tx = x + '\\t' + transcript;\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method][transcript][\"contextScore\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method][transcript][\"aggregatePCT\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method][transcript][\"totalConSites\"];\r\n\t\t\t\t\t\t\t//x = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method][transcript][\"miRfamily\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method][transcript][\"repMIRNA\"];\r\n\t\t\t\t\t\t\tx = x + '\\n';\r\n\t\t\t\t\t\t}\r\n\t\t\t\t} else if(method == \"rna22_3utr\") {\r\n\t\t\t\t\t\tfor(var transcript in doc.mat_miRNA[matmiRNA[0]][method]) {\r\n\t\t\t\t\t\t\tx = x + matmiRNA[0] + '\\t' + doc.Gene_Symbol + '\\t' + doc.Gene_EntrezID + '\\t';\r\n\t\t\t\t\t\t\tx = x + method;\r\n\t\t\t\t\t\t\tx = x + '\\t' + transcript;\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method][transcript][\"bind.energy\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method][transcript][\"duplex.bp\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method][transcript][\"region\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[matmiRNA[0]][method][transcript][\"ensembl.gene\"];\r\n\t\t\t\t\t\t\tx = x + '\\n';\r\n\t\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\t\r\n\t\t\tsend(x);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tsend(row.value + \"\\n\");\r\n\t\t}\r\n }\r\n};","open":"function (head, req) {\r\n\r\n var row;\r\n var ii = 0;\r\n\r\n start({'headers': {\r\n 'Content-Type': 'application/json',\r\n\t\"Access-Control-Allow-Origin\": \"*\"\r\n }});\r\n\r\n send (\"[\");\r\n while ((row = getRow()) !== null) {\r\n\tsend ((ii > 0 ? \",\":\"\") + JSON.stringify(row.doc));\r\n\tii++;\r\n }\r\n send (\"]\");\r\n}","interactionTSV":"function(head, req) {\r\n var row; var headers;\r\n start({\r\n\t\t'headers': {\r\n\t\t\t'Content-Type': 'application/targethub-results; charset=utf-8; header=present',\r\n\t\t\t'Content-Disposition' : 'attachment; filename=\"results_targetHub.tsv\"'\r\n\t\t}\r\n\t});\r\n\t//start({ 'headers': {}});\r\n while (row = getRow()) {\r\n\t\tif(!headers) {\r\n\t\t\theaders = \"miRNA\" + '\\t' + \"matureMIRNA\" + '\\t' + \"geneSymbol\" + '\\t' + \"geneID\" + '\\t' + \"method\" + '\\t' + \"transcript\" + '\\t' + \"param1\" + '\\t' + \"param2\" + '\\t' + \"param3\" + '\\t' + \"param4\" + '\\n';\r\n\t\t\tsend(headers);\r\n\t\t}\r\n\t\tif (row.doc) {\r\n\t\t\tvar x = '';\r\n\t\t\tvar doc = row.doc;\r\n\t\t\tfor (var method in doc.mat_miRNA[row.value]) {\r\n\t\t\t\tif(method == \"mirTarBase\") {\r\n\t\t\t\t\tx = x + doc.miRNA + '\\t' + row.value + '\\t' + doc.Gene_Symbol + '\\t' + doc.Gene_EntrezID + '\\t';\r\n\t\t\t\t\tx = x + 'mirTarBase' + '\\t';\r\n\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method].experiments;\r\n\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method].supportType;\r\n\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method].interactionID;\r\n\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method].pubmedID;\r\n\t\t\t\t\tx = x + '\\n';\r\n\t\t\t\t} else if(method == \"miRanda\") {\r\n\t\t\t\t\t\tfor(var transcript in doc.mat_miRNA[row.value][method]) {\r\n\t\t\t\t\t\t\tx = x + doc.miRNA + '\\t' + row.value + '\\t' + doc.Gene_Symbol + '\\t' + doc.Gene_EntrezID + '\\t';\r\n\t\t\t\t\t\t\tx = x +'miRanda';\r\n\t\t\t\t\t\t\tx = x + '\\t' + transcript;\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method][transcript][\"Tot.Score\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method][transcript][\"Tot.Energy\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method][transcript][\"TranscriptLoc\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method][transcript][\"Position\"];\r\n\t\t\t\t\t\t\tx = x + '\\n';\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t} else if((method == \"picTar5\") || (method == \"picTar4\")) {\r\n\t\t\t\t\t\tfor(var transcript in doc.mat_miRNA[row.value][method]) {\r\n\t\t\t\t\t\t\tx = x + doc.miRNA + '\\t' + row.value + '\\t' + doc.Gene_Symbol + '\\t' + doc.Gene_EntrezID + '\\t';\r\n\t\t\t\t\t\t\tx = x + method;\r\n\t\t\t\t\t\t\tx = x + '\\t' + transcript;\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method][transcript][\"score\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method][transcript][\"siteChr\"] + ':'+ doc.mat_miRNA[row.value][method][transcript][\"siteStart\"] + ':' + doc.mat_miRNA[row.value][method][transcript][\"siteEnd\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method][transcript][\"miRname\"];\r\n\t\t\t\t\t\t\tx = x + '\\n';\r\n\t\t\t\t\t\t}\r\n\t\t\t\t} else if(method == \"targetScan\") {\r\n\t\t\t\t\t\tfor(var transcript in doc.mat_miRNA[row.value][method]) {\r\n\t\t\t\t\t\t\tx = x + doc.miRNA + '\\t' + row.value + '\\t' + doc.Gene_Symbol + '\\t' + doc.Gene_EntrezID + '\\t';\r\n\t\t\t\t\t\t\tx = x + method;\r\n\t\t\t\t\t\t\tx = x + '\\t' + transcript;\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method][transcript][\"contextScore\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method][transcript][\"aggregatePCT\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method][transcript][\"totalConSites\"];\r\n\t\t\t\t\t\t\t//x = x + '\\t' + doc.mat_miRNA[row.value][method][transcript][\"miRfamily\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method][transcript][\"repMIRNA\"];\r\n\t\t\t\t\t\t\tx = x + '\\n';\r\n\t\t\t\t\t\t}\r\n\t\t\t\t} else if(method == \"rna22_3utr\") {\r\n\t\t\t\t\t\tfor(var transcript in doc.mat_miRNA[row.value][method]) {\r\n\t\t\t\t\t\t\tx = x + doc.miRNA + '\\t' + row.value + '\\t' + doc.Gene_Symbol + '\\t' + doc.Gene_EntrezID + '\\t';\r\n\t\t\t\t\t\t\tx = x + method;\r\n\t\t\t\t\t\t\tx = x + '\\t' + transcript;\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method][transcript][\"bind.energy\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method][transcript][\"duplex.bp\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method][transcript][\"region\"];\r\n\t\t\t\t\t\t\tx = x + '\\t' + doc.mat_miRNA[row.value][method][transcript][\"ensembl.gene\"];\r\n\t\t\t\t\t\t\tx = x + '\\n';\r\n\t\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\t\r\n\t\t\tsend(x);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tsend(row.value + \"\\n\");\r\n\t\t}\r\n }\r\n};"},"evently":{"profile":{"profileReady":{"mustache":"';\r\n\t\t\t\t\tx = x + '
';\r\n\t\t\t\t} else if(method == \"miRanda\") {\r\n\t\t\t\t\t\tx = x + '';\r\n\t\t\t\t\t\tfor(var transcript in doc.mat_miRNA[matmiRNA[0]][method]) {\r\n\t\t\t\t\t\t\tx = x + '
';\r\n\t\t\t\t} else if((method == \"picTar5\") || (method == \"picTar4\")) {\r\n\t\t\t\t\t\tx = x + '';\r\n\t\t\t\t\t\tfor(var transcript in doc.mat_miRNA[matmiRNA[0]][method]) {\r\n\t\t\t\t\t\t\tx = x + '
';\r\n\t\t\t\t} else if(method == \"targetScan\") {\r\n\t\t\t\t\t\tx = x + '';\r\n\t\t\t\t\t\tfor(var transcript in doc.mat_miRNA[matmiRNA[0]][method]) {\r\n\t\t\t\t\t\t\tx = x + '
';\r\n\t\t\t\t} \r\n\t\t\t}\t\r\n\t\t\tx = x + 'Recent Messages
\r\n\r\n {{#items}}\r\n
\r\n