Skip to content

Instantly share code, notes, and snippets.

@satyr
Forked from satyr/yats.ubiq.js
Created January 11, 2009 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satyr/45590 to your computer and use it in GitHub Desktop.
Save satyr/45590 to your computer and use it in GitHub Desktop.
yet another twitter search <http://pcod.no-ip.org/yats/>
const Name = 'yats',
Yats = 'http://pcod.no-ip.org/yats/',
Base = ''+ <div class={Name}><base href={Yats}/><style><![CDATA[
h2 {margin:0; padding:0}
img {width:16px; height:16px; border:none}
ol {margin:2px 0; padding:0}
li {float:left; clear:left; width:100%; padding:0 0 4px 0}
li div {float:left; padding-right:2px}
h2, p {clear:left; font-size:84%}
kbd {text-decoration:underline; vertical-align:top}
.error {font-style:oblique}
.pagination {display:none}
.logo {
clear:both; background:#333; width:160px; text-align:center; margin:0}
.logo a {color:#fff !important; text-decoration:none}
.loading + .logo {opacity:0.4}
.error + .logo {opacity:0.7}
]]></style><div id={Name}> </div
><h1 class="logo"><a href={Yats}>twitter&#x691c;&#x7D22;</a></h1></div>;
function ng(c){
c.textContent = Array.slice(arguments, 1).join(' ');
c.className = 'error';
}
function url({object: {text: t}, format: {data: l}})(
(t = Utils.trim(t)) &&
(Yats +'search?query='+ encodeURIComponent(t) + '&lang='+ (l || '')));
CmdUtils.CreateCommand({
name: Name,
icon: 'http://twitter.com/favicon.ico',
arguments: {
object: noun_arb_text,
format: {Japanese: 'ja', English: 'en'},
},
description: 'yet another twitter search'.link(Yats),
execute: function yats_exec(args){ Utils.openUrlInBrowser(url(args)) },
preview: function yats_view(pb, args){
do var c = pb.ownerDocument.getElementById(Name);
while(!c && (pb.innerHTML = Base));
var u = url(args);
if(!u) return;
c.className += ' loading';
CmdUtils.previewAjax(pb, {
url: u,
success: function yats_succ(htm){
if(!/<div class="results"[\s\S]+?(?=<p class="pagination")/.test(htm))
return ng(c, 'No results.');
c.innerHTML = RegExp.lastMatch;
c.className = '';
$('.user-image a', c).each(function(k){
$(this).attr('accesskey', k = k.toString(36))
.append('<kbd>'+ k +'</kbd>');
});
$('a[href^="."]', c).each(function(){
this.href = Yats + this.getAttribute('href');
});
},
error: function yats_errr(x){ ng(c, x.status, x.statusText) },
});
},
author: 'satyr', license: 'MIT',
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment