//jQuery読む
window.jQuery = window.$ = require('../../js/common/jquery.js');
var Hammer = require('../../js/common/hammer.min.js');
$.strip_tags = function(str, allowed) {
if(!str){
return "";
}
allowed = (((allowed || '') + '').toLowerCase().match(/<[a-z][a-z0-9]*>/g) || [])
.join('');
var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>?/gi,
commentsAndPhpTags = /|<\?(?:php)?[\s\S]*?\?>/gi;
return str.replace(commentsAndPhpTags, '').replace(tags, function($0, $1) {
return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : '';
});
};
function escapeHTML(str) {
if(!str){
return "";
}
return str.replace(/&/g, '&')
.replace(//g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
}
//PHPのnl2brと同様
function nl2br(str) {
if(!str){
return "";
}
str = str.replace(/\r\n/g, "
");
str = str.replace(/(\n|\r)/g, "
");
return str;
}
function br2nl(str) {
if(!str){
return "";
}
str = str.replace(/
/g, "\r\n");
return str;
}
function formattime(date){
var str=date.getFullYear()+"-";
if(date.getMonth()+1<10){
str=str+"0"+(date.getMonth()+1)+"-";
}else{
str=str+(date.getMonth()+1)+"-";
}
if(date.getDate()<10){
str=str+"0"+date.getDate()
}else{
str=str+date.getDate()
}
str=str+"T";
if(date.getHours()<10){
str=str+"0"+date.getHours()+":"
}else{
str=str+date.getHours()+":"
}
if(date.getMinutes()<10){
str=str+"0"+date.getMinutes()
}else{
str=str+date.getMinutes()
}
return escapeHTML(str);
}
function formattimeutc(date){
var str=date.getUTCFullYear()+"-";
if(date.getUTCMonth()+1<10){
str=str+"0"+(date.getUTCMonth()+1)+"-";
}else{
str=str+(date.getUTCMonth()+1)+"-";
}
if(date.getUTCDate()<10){
str=str+"0"+date.getUTCDate()
}else{
str=str+date.getUTCDate()
}
str=str+"T";
if(date.getUTCHours()<10){
str=str+"0"+date.getUTCHours()+":"
}else{
str=str+date.getUTCHours()+":"
}
if(date.getUTCMinutes()<10){
str=str+"0"+date.getUTCMinutes()
}else{
str=str+date.getUTCMinutes()
}
return escapeHTML(str);
}
var electron = require("electron");
var ipc = electron.ipcRenderer;
ipc.send('custom-css-request', "");
ipc.on('custom-css-response', function (event, arg) {
if(arg==""){ return false; }
var styleNode = document.createElement("style");
styleNode.setAttribute("type","text/css")
var content = document.createTextNode(arg)
styleNode.append(content)
document.getElementsByTagName("head")[0].append(styleNode)
})
ipc.on('theme-css-response', function (event, arg) {
if(arg==""){ return false; }
var styleNode = document.createElement("style");
styleNode.setAttribute("type","text/css")
var content = document.createTextNode(arg)
styleNode.append(content)
document.getElementsByTagName("head")[0].append(styleNode)
})
function makeCID(){
return randomStr(8)+"-"+randomStr(4)+"-"+randomStr(4)+"-"+randomStr(4)+"-"+randomStr(12);
}
function randomStr(l){
// 生成する文字列に含める文字セット
var c = "abcdefghijklmnopqrstuvwxyz0123456789";
var cl = c.length;
var r = "";
for(var i=0; i (i + 1) ? str.charCodeAt(i + 1) : 0;
if ($.isSurrogatePear(upper, lower)) {
i++;
}
}
return ret;
};
$.mb_substr = function(str, begin, end) {
var ret = '';
for (var i = 0, len = 0; i < str.length; i++, len++) {
var upper = str.charCodeAt(i);
var lower = str.length > (i + 1) ? str.charCodeAt(i + 1) : 0;
var s = '';
if ($.isSurrogatePear(upper, lower)) {
i++;
s = String.fromCharCode(upper, lower);
} else {
s = String.fromCharCode(upper);
}
if (begin <= len && len < end) {
ret += s;
}
}
return ret;
};