Skip to content

Commit

Permalink
update for duckduckgo.com redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejs committed Aug 14, 2010
1 parent 276b757 commit dfc1b9c
Show file tree
Hide file tree
Showing 31 changed files with 259 additions and 216 deletions.
2 changes: 0 additions & 2 deletions README.rst
Expand Up @@ -5,5 +5,3 @@ http://lmddgtfy.com
LICENSING
=========
The Duck Duck Go logo, associated icons, HTML code and Javascript files are copyright Duck Duck Go, used with permission.

The Python source and the static/lmddgtfy.js file are copyright Michael Stephens (me@mikej.st) and released under a BSD license.
Empty file removed __init__.py
Empty file.
File renamed without changes
1 change: 1 addition & 0 deletions d296.js

Large diffs are not rendered by default.

File renamed without changes.
9 changes: 9 additions & 0 deletions index.html
@@ -0,0 +1,9 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><link rel="canonical" href="http://duckduckgo.com/"/><meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta name="description" content="New search engine with better results and less garbage."><meta name="keywords" content="search,search engine,new search engine"><title>Search Engine DuckDuckGo</title><link title="Duck Duck Go" type="application/opensearchdescription+xml" rel="search" href="opensearch.xml"><link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yegg" /><link rel="apple-touch-icon" href="icon128.png" /><style type="text/css">.icon{margin-left:5px;}img{-ms-interpolation-mode: bicubic;}html{background:#FFF;color:#444;font-family:"Segoe UI",Arial,sans-serif;}body,form,h1{margin:0;padding:0;}a:hover{text-decoration:underline;}a{text-decoration:none;color:#0068CC;}h1{font-size:100%;font-weight:normal;display:inline;}#cursor{position: absolute;top: 0px;left: 0px;z-index: 1000; }.lmddgtfy{font-family: Helvetica, Arial, sans-serif; font-weight: bold; font-size: 15pt; }#foryou{margin-bottom: 10px; }</style><script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script><script type="text/javascript" src="jquery.query.js"></script><script type="text/javascript" src="lmddgtfy.js"></script></head><body><div style="width:600px;margin:auto;text-align:center;"><input type="text" id="hidden_input" style="display: none;" tabindex="0" /><img id="cursor" src="cursor.png" style="display: none;"/><div class="lmddgtfy">Let me</div><a href="/"><img src="nduck.v104.png" alt="Search Engine Duck Duck Go" style="margin-top:20px;margin-bottom:30px;" border="0" /></a><div class="lmddgtfy" id="foryou">that for you</div><form name="x" action="/"><div style="border:1px solid #ff6666;border-top:1px solid #ff6666;width:390px;margin:auto;"><input type="text" name="q" onFocus="fq=1" onBlur="fq=0" style="outline:none;width:350px;color:#222;background:#FFF;font-family:'Segoe UI',Arial,sans-serif;font-size:20px;border:0 none;margin:0;padding:0;padding-left:5px;padding-top:5px;padding-bottom:5px;" onClick="if (this.value=='put search terms here') {this.value='';this.style.color='#222222';}"><input type="button" name="b" onClick="searchn()" value="" style="background:transparent url(zoom.v101.png) no-repeat scroll 0 0;width:24px;height:24px;padding:0px;margin:0px;cursor:pointer;border:0 none;vertical-align:top;margin-top:8px;margin-left:6px;margin-right:4px;" title="Search" alt="Search" id="search_button"></div><div style="margin-top:20px;"></div><noscript>This site requires JavaScript.</noscript><script type="text/javascript">w=window;d=document;b=0;setTimeout('d.x.q.focus()',100);</script><script src="d296.js" type="text/javascript"></script><script type="text/javascript">fq=0;function searchn() {if(d.x.q.value==''||d.x.q.value=='put search terms here'){d.x.q.value='put search terms here';d.x.q.style.color='#AAAAAA';setTimeout('d.x.q.onclick();d.x.q.focus();',1000);return false;};setTimeout('d.x.submit()',100);}if (YAHOO.util.Cookie.get("i")=='-1') {document.write('<input type="hidden" name="v" value="n">');};if (YAHOO.util.Cookie.get("g")=='p') {d.x.method='POST';};</script><div style="padding-left:0px;padding-top:30px;font-size:14px;text-align:center;width:450px;margin:auto;"><a href="http://duckduckgo.com/about.html">About</a> &nbsp;|&nbsp; <a href="http://duckduckgo.com/settings.html">Settings</a> &nbsp;|&nbsp; <a href="http://duckduckgo.com/goodies.html">Goodies</a><script type="text/javascript">nib(0,'',' &nbsp;|&nbsp; ');</script></div><div style="padding-left:0px;padding-top:25px;font-size:10px;text-align:center;width:450px;margin:auto;">&copy; 2010 - <a href="http://duckduckgo.com/privacy.html">Privacy</a> & <a href="http://duckduckgo.com/terms.html">Terms</a></div></form><script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-16313175-1");
pageTracker._trackPageview();
} catch(err) {}</script></body></html>
224 changes: 224 additions & 0 deletions jquery.query.js
@@ -0,0 +1,224 @@
/**
* jQuery.query - Query String Modification and Creation for jQuery
* Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
* Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
* Date: 2009/8/13
*
* @author Blair Mitchelmore
* @version 2.1.7
*
**/
new function(settings) {
// Various Settings
var $separator = settings.separator || '&';
var $spaces = settings.spaces === false ? false : true;
var $suffix = settings.suffix === false ? '' : '[]';
var $prefix = settings.prefix === false ? false : true;
var $hash = $prefix ? settings.hash === true ? "#" : "?" : "";
var $numbers = settings.numbers === false ? false : true;

jQuery.query = new function() {
var is = function(o, t) {
return o != undefined && o !== null && (!!t ? o.constructor == t : true);
};
var parse = function(path) {
var m, rx = /\[([^[]*)\]/g, match = /^([^[]+)(\[.*\])?$/.exec(path), base = match[1], tokens = [];
while (m = rx.exec(match[2])) tokens.push(m[1]);
return [base, tokens];
};
var set = function(target, tokens, value) {
var o, token = tokens.shift();
if (typeof target != 'object') target = null;
if (token === "") {
if (!target) target = [];
if (is(target, Array)) {
target.push(tokens.length == 0 ? value : set(null, tokens.slice(0), value));
} else if (is(target, Object)) {
var i = 0;
while (target[i++] != null);
target[--i] = tokens.length == 0 ? value : set(target[i], tokens.slice(0), value);
} else {
target = [];
target.push(tokens.length == 0 ? value : set(null, tokens.slice(0), value));
}
} else if (token && token.match(/^\s*[0-9]+\s*$/)) {
var index = parseInt(token, 10);
if (!target) target = [];
target[index] = tokens.length == 0 ? value : set(target[index], tokens.slice(0), value);
} else if (token) {
var index = token.replace(/^\s*|\s*$/g, "");
if (!target) target = {};
if (is(target, Array)) {
var temp = {};
for (var i = 0; i < target.length; ++i) {
temp[i] = target[i];
}
target = temp;
}
target[index] = tokens.length == 0 ? value : set(target[index], tokens.slice(0), value);
} else {
return value;
}
return target;
};

var queryObject = function(a) {
var self = this;
self.keys = {};

if (a.queryObject) {
jQuery.each(a.get(), function(key, val) {
self.SET(key, val);
});
} else {
jQuery.each(arguments, function() {
var q = "" + this;
q = q.replace(/^[?#]/,''); // remove any leading ? || #
q = q.replace(/[;&]$/,''); // remove any trailing & || ;
if ($spaces) q = q.replace(/[+]/g,' '); // replace +'s with spaces

jQuery.each(q.split(/[&;]/), function(){
var key = decodeURIComponent(this.split('=')[0] || "");
var val = decodeURIComponent(this.split('=')[1] || "");

if (!key) return;

if ($numbers) {
if (/^[+-]?[0-9]+\.[0-9]*$/.test(val)) // simple float regex
val = parseFloat(val);
else if (/^[+-]?[0-9]+$/.test(val)) // simple int regex
val = parseInt(val, 10);
}

val = (!val && val !== 0) ? true : val;

if (val !== false && val !== true && typeof val != 'number')
val = val;

self.SET(key, val);
});
});
}
return self;
};

queryObject.prototype = {
queryObject: true,
has: function(key, type) {
var value = this.get(key);
return is(value, type);
},
GET: function(key) {
if (!is(key)) return this.keys;
var parsed = parse(key), base = parsed[0], tokens = parsed[1];
var target = this.keys[base];
while (target != null && tokens.length != 0) {
target = target[tokens.shift()];
}
return typeof target == 'number' ? target : target || "";
},
get: function(key) {
var target = this.GET(key);
if (is(target, Object))
return jQuery.extend(true, {}, target);
else if (is(target, Array))
return target.slice(0);
return target;
},
SET: function(key, val) {
var value = !is(val) ? null : val;
var parsed = parse(key), base = parsed[0], tokens = parsed[1];
var target = this.keys[base];
this.keys[base] = set(target, tokens.slice(0), value);
return this;
},
set: function(key, val) {
return this.copy().SET(key, val);
},
REMOVE: function(key) {
return this.SET(key, null).COMPACT();
},
remove: function(key) {
return this.copy().REMOVE(key);
},
EMPTY: function() {
var self = this;
jQuery.each(self.keys, function(key, value) {
delete self.keys[key];
});
return self;
},
load: function(url) {
var hash = url.replace(/^.*?[#](.+?)(?:\?.+)?$/, "$1");
var search = url.replace(/^.*?[?](.+?)(?:#.+)?$/, "$1");
return new queryObject(url.length == search.length ? '' : search, url.length == hash.length ? '' : hash);
},
empty: function() {
return this.copy().EMPTY();
},
copy: function() {
return new queryObject(this);
},
COMPACT: function() {
function build(orig) {
var obj = typeof orig == "object" ? is(orig, Array) ? [] : {} : orig;
if (typeof orig == 'object') {
function add(o, key, value) {
if (is(o, Array))
o.push(value);
else
o[key] = value;
}
jQuery.each(orig, function(key, value) {
if (!is(value)) return true;
add(obj, key, build(value));
});
}
return obj;
}
this.keys = build(this.keys);
return this;
},
compact: function() {
return this.copy().COMPACT();
},
toString: function() {
var i = 0, queryString = [], chunks = [], self = this;
var encode = function(str) {
str = str + "";
if ($spaces) str = str.replace(/ /g, "+");
return encodeURIComponent(str);
};
var addFields = function(arr, key, value) {
if (!is(value) || value === false) return;
var o = [encode(key)];
if (value !== true) {
o.push("=");
o.push(encode(value));
}
arr.push(o.join(""));
};
var build = function(obj, base) {
var newKey = function(key) {
return !base || base == "" ? [key].join("") : [base, "[", key, "]"].join("");
};
jQuery.each(obj, function(key, value) {
if (typeof value == 'object')
build(value, newKey(key));
else
addFields(chunks, newKey(key), value);
});
};

build(this.keys);

if (chunks.length > 0) queryString.push($hash);
queryString.push(chunks.join($separator));

return queryString.join("");
}
};

return new queryObject(location.search, location.hash);
};
}(jQuery.query || {}); // Pass in jQuery.query as settings object
54 changes: 24 additions & 30 deletions static/lmddgtfy.js → lmddgtfy.js
@@ -1,5 +1,3 @@
google.load("jquery", "1.4.1");

function px(i) {
return i.toString() + "px";
}
Expand All @@ -16,42 +14,32 @@ function cursorToInputField() {
$("#cursor").animate({
top: px(input.position().top + 35)
}, 500, 'swing', function() {
var str = $("#query").attr("value");
var str = $.query.get("q");
type(str, 1);
});
}, 100);
})
});
}

function cursorToIcon() {
var type = $("#search_type").attr("value");

var icon;
if (type === "d") {
icon = $("#icon2");
} else if (type === "s") {
icon = $("#icon3");
} else if (type === "i") {
icon = $("#icon4");
} else {
icon = $("#icon1");
}
var icon = $("#search_button");

setTimeout(function() {
setTimeout(
function() {
icon.mouseover();
}, 500);

$("#cursor").animate({
top: px(icon.position().top + 15),
left: px(icon.position().left + 20)
}, 1000, 'swing', function() {
setTimeout(go, 300);
setTimeout(go, 300);
});
}

function go() {
var query = escape($("#query").attr("value"));
var type = escape($("#search_type").attr("value"));
window.location = "http://duckduckgo.com/?q=" + query + "&v=" + type;
var qstring = $.query.empty().set("q", $.query.get("q")).toString();
window.location = "http://duckduckgo.com/" + qstring;
}

function type(str, index) {
Expand All @@ -63,12 +51,18 @@ function type(str, index) {
} else {
setTimeout(cursorToIcon, 100);
}
}

google.setOnLoadCallback(function() {
$("#hidden_input").focus();
$("input[name='q']").attr("value", "").attr('readonly', true).focus(function() {
this.blur();
});
setTimeout(cursorToInputField(), 200);
});
}

$("body").ready(
function() {
var q = $.query.get("q");
if (q != "") {
$("#cursor").show();
$("#hidden_input").focus();
$("input[name='q']").attr("value", "").attr('readonly', true).focus(
function() {
this.blur();
});
setTimeout(cursorToInputField(), 200);
}
});
11 changes: 0 additions & 11 deletions manage.py

This file was deleted.

Binary file added nduck.v104.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

Empty file removed search/__init__.py
Empty file.
3 changes: 0 additions & 3 deletions search/models.py

This file was deleted.

0 comments on commit dfc1b9c

Please sign in to comment.