Skip to content

Instantly share code, notes, and snippets.

@onozaty
onozaty / gist:4136459
Last active October 13, 2015 04:07
Script error on IE at input type change.
var input = document.createElement('input');
input.type; // -> "text"
input.type = 'button'; // OK
document.body.appendChild(input);
input.type = 'text'; // Error
Ebi.createElement('#target')
.clear()
.style('border', 'solid 1px black')
.append('text1')
.start('span')
.append('red')
.style({
color: 'red',
fontWeight: 'bold'
})
@onozaty
onozaty / gist:4519326
Last active December 11, 2015 00:49
Google URL Shortener
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (request.readyState == 4) {
if (request.status == 200) {
console.log(request.responseText);
} else {
console.log('error!! status code:' + request.status);
}
}
};
@onozaty
onozaty / gist:4573720
Created January 19, 2013 17:12
Google URL Shortener using HttpClient(http://hc.apache.org/httpcomponents-client-ga/)
HttpPost post = new HttpPost("https://www.googleapis.com/urlshortener/v1/url?key={your API Key}");
post.setHeader("Content-Type", "application/json");
post.setEntity(new StringEntity("{'longUrl': 'http://www.google.com/'}", "UTF-8"));
HttpResponse response = new DefaultHttpClient().execute(post);
String responseText = EntityUtils.toString(response.getEntity());
System.out.print(responseText);
@onozaty
onozaty / gist:4579122
Created January 20, 2013 14:34
Convert to short url from RSS link url. This is IRCBot Console Script.(by Rhino) http://www.enjoyxstudy.com/ircbotconsole/
// set api key
// https://developers.google.com/url-shortener/v1/getting_started#auth
var api = 'https://www.googleapis.com/urlshortener/v1/url?key={your API Key}';
var paramater = JSON.stringify({'longUrl': _link});
var request = new Packages.org.apache.http.client.methods.HttpPost(api);
request.setHeader('Content-Type', 'application/json');
request.setEntity(
new Packages.org.apache.http.entity.StringEntity(paramater, 'UTF-8'));
function show(target) {
var div = document.createElement('div');
div.appendChild(document.createTextNode('xxxx'));
div.style.border = 'solid 1px black';
div.style.zindex = 100;
// 対象と同じ親に追加
target.parentElement.appendChild(div);
@onozaty
onozaty / del.icio.us IncSearch user-extension.js
Last active December 15, 2015 04:58
del.icio.us IncSearch user-extension.js. Added private/public bookmark information to tags for del.icio.us IncSearch.
DeliciousParser.parse = function(xml) {
var posts = xml.getElementsByTagName('post');
var list = [];
for (var i = 0, len = posts.length; i < len; i++) {
var bookmark = {};
var post = posts[i];
bookmark.id = i;
bookmark.url = post.getAttribute('href');
@onozaty
onozaty / gist:6045356
Created July 20, 2013 14:57
Command of the shortcut key does not work
var mainKeyset = aWindow.document.getElementById("mainKeyset");
var keyElement = aWindow.document.createElement("key");
keyElement.setAttribute("id", SHORTCUT_KEY_ELEMENT_ID);
keyElement.setAttribute("key", key);
keyElement.setAttribute("modifiers", modifiers);
keyElement.setAttribute("oncommand", "void(0);");
keyElement.addEventListener("command", function() {
openIncSearch(aWindow);
@onozaty
onozaty / gist:6205160
Created August 11, 2013 14:35
do not work shortcutkey
var keyElement = aWindow.document.createElement("key");
keyElement.setAttribute("key", key);
keyElement.setAttribute("modifiers", modifiers);
keyElement.setAttribute("oncommand", "void(0);");
keyElement.addEventListener("command", function() {
alert('do command');
}, false);
@onozaty
onozaty / gist:6205174
Created August 11, 2013 14:38
work shortcutkey
var keyElement = aWindow.document.createElement("key");
keyElement.setAttribute("key", key);
keyElement.setAttribute("modifiers", modifiers);
keyElement.setAttribute("oncommand", "void(0);");
keyElement.addEventListener("command", function() {
alert('do command');
}, false);