Skip to content

Instantly share code, notes, and snippets.

View valueof's full-sized avatar
👋

Anton valueof

👋
View GitHub Profile
@valueof
valueof / problem.js
Created September 7, 2011 22:33
"Unexpected call to method or property access" when trying to create a style tag
// Problem
var css = 'a.check-css { color: #f00; }';
var el = document.createElement('style');
el.setAttribute('type', 'text/css');
el.appendChild(document.createTextNode(css)); // Unexpected call to method or property access.
document.getElementsByTagName('head')[0].appendChild(el);
@valueof
valueof / gist:1201958
Created September 7, 2011 22:14
Internet Explorer 8 doesn't have querySelector inside of an iframe
<iframe id="hey"></iframe>
<script>
var hey = document.getElementById("hey");
alert(document.querySelector);
hey.contentWindow.document.write('<html><scr' + 'ipt>alert(document.querySelector);</scr' + 'ipt></html>');
hey.contentWindow.document.close();
</script>
<!DOCTYPE html>
<html lang="en">
<head>
<title>DISQUS JavaScript Tests</title>
<!-- Hiro files -->
<link rel="stylesheet" href="css/tests/hiro.css">
<script src="js/tests/ender.js"></script>
<script src="js/tests/hiro.js"></script>
function outer() {
var a = true;
function inner() {
// Does compiler keep a reference to outer for this function?
}
}
outer();
{ block editArea }
<div class="dsq-textarea-wrapper">
<textarea class="dsq-edit-textarea" id="dsq-edit-textarea-{= comment.id }">{= comment.message }</textarea>
</div>
<div class="dsq-save-edit">
<button type="button"
onclick="DISQUS.dtpl.actions.fire('comments.edit.send', {= comment.id }, this);">{ "Save edit" }</button>
</div>
{ block commentMessage :cls }
<div class="{= cls }" id="dsq-comment-message-{= comment.id }">
{ if comment.killed }
<em>{ "Comment removed." }</em>
{ elif !comment.approved }
<em>{ "This comment was flagged for review." }</em>
{ else }
{= comment.message }
{ if comment.last_modified_by == 'moderator' }
You will need to locate a block with name "postbox_login_options_horizontal".
There, you will see that we create an unordered list (UL) with login buttons as
its items.
You will want to put your buttons just after the FOR loop (i.e. immediately
after the closing { /for }). Just make sure that your LI tag has class
"dsq-login-button".
<ul class="dsq-login-buttons">
{ for option in loginOptions }
@valueof
valueof / disqus_events.js
Created July 12, 2010 18:24
Description and examples for Disqus events
var disqus_config = function () {
var config = this; // Access to the config object
/*
All currently supported events:
* preData — fires just before we request for initial data
* preInit - fires after we get initial data but before we load any dependencies
* onInit - fires when all dependencies are resolved but before dtpl template is rendered
* afterRender - fires when template is rendered but before we show it
* onReady - everything is done
@valueof
valueof / comments-count-sample.html
Created July 8, 2010 08:37
Comments count code example
<html>
<head>
<title>Comments count code example</title>
<!--
Note: Disqus uses custom data- attributes to specify thread identifiers.
Those attributes are part of the HTML5 specs and already supported by all browsers.
For more information, see:
* http://ejohn.org/blog/html-5-data-attributes/
def to_unicode(f):
if isinstance(f, dict):
for k, v in f.iteritems():
f[str(k)] = to_unicode(v)
elif isinstance(f, (list, tuple)):
f = [to_unicode(f) for f in f]
elif isinstance(f, str):
f = f.decode('utf-8')
else:
f = unicode(f)