This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Blength() 是用來計算string 以Byte為單位 | |
subBtyes(str, max)是用來切割Btyes(str:被切割字串, max:最大Bytes數) | |
例: "我abc我".Blength() = 7 | |
subBtyes("我abc我", 3) // 結果是 我a | |
*/ | |
String.prototype.Blength = function(){ | |
var str = this.match(/[^\x00-\xff]/ig); | |
return str === null ? this.length : this.length + str.length; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
例如 Content = '<div style="background-color: rgba(255, 255, 255, 0.843137);"> gg<br>yy<br><br><br>uu<br><br> ff <br> u<br></div><div style="background-color: rgba(255, 255, 255, 0.843137);"><br></div><div style="background-color: rgba(255, 255, 255, 0.843137);"> i</div> ' | |
此code示範如何將Contne html字串,檢查其有沒有word | |
註: var str="我是中文字" | |
(/\w|[^\x00-\xff]/ig).test(str); //回傳是true | |
*/ | |
var html = $(Content); //jQuery 將字串轉成html | |
var innertext = null; | |
//檢查內容每一行有無中英文 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
設image 的本地預覽圖片路徑 url | |
*/ | |
function setImageSrc() { | |
var url = '', | |
file = filefield.fileInputEl.dom.files[0]; | |
if (window.createObjectURL) { | |
url = window.createObjectURL(file); | |
} else if (window.URL) { // mozilla(firefox) | |
url = window.URL.createObjectURL(file); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
目的: 對購物網站項目的價格做排序 (購物網站網址:http://activity.books.com.tw/ps/prog/2601/page/200/category/217234) | |
方法: 讀取Dom, 並sort() | |
*/ | |
var all = $('li'); //先取全部的li | |
var chose = []; | |
var price = []; | |
var title =[] | |
var bookstore = []; | |
for(var key in all){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* IsValid() 驗證htmleditor 的 value值是否空白,並會排除空白情況 | |
*/ | |
//validate htmleditor | |
function IsValid(value) { | |
var div = document.createElement('div'), text; | |
div.innerHTML = value; | |
text = div.textContent || div.innerText || ""; | |
return (text.replace(/^\s+|\s+$/gm, '') != ""); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
paste: { | |
element: 'inputEl', | |
fn: function(event, inputEl) { | |
var a = add_Content.getValue(); | |
//已過濾表格 儲存在var b | |
var b = a.replace(/((<td[^>]+)style=".*?">)/ig, function(x) { | |
return x = x.replace(/style=".*?"/, 'style="border:solid"'); | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--baseURL 就是 輸出的img src 連結--> | |
<!--該Html 引用<script type="text/javascript" src="http://html2canvas.hertzen.com/build/html2canvas.js"></script>--> | |
<!--Ext.getCmp('wincv-1110').el.dom ,即是該html的DOM--> | |
<!--參考 html2canvas : http://html2canvas.hertzen.com/--> | |
<script type="text/javascript" src="http://html2canvas.hertzen.com/build/html2canvas.js"></script> | |
<script> | |
html2canvas(Ext.getCmp('wincv-1110').el.dom,{onrendered:function(canvas){ | |
var baseURL = canvas.toDataURL("img/png"); | |
console.log(baseURL); | |
}}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Bootstrap-Table: http://bootstrap-table.wenzhixin.net.cn/documentation/ | |
練習下OData參數,從後端分頁GET資料 | |
*/ | |
$('#table').bootstrapTable({ | |
url: '',//api | |
cache: false, | |
contentType: 'application/json', | |
pageNumber: 1, // 起始第1頁 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
reducer 寫法參考:https://github.com/rackt/redux/blob/master/examples/todos-with-undo/reducers.js | |
說明: Redux負責儲存 陣列狀態 | |
用Immutable方式 | |
意思是"不要汙染(改變)原本在reducer的舊的state | |
而是創造一個全新的state回傳, 且舊的state不影響 | |
另外,注意刪減時, Rowt 要有key值 | |
*/ | |
//這是一個 叫做clickAction的Reducer | |
//初始狀態是state={'rows':[(Rowt)]}; Rowt 是html tag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
React style={{marginRight: spacing + 'em'}} when using JSX | |
Therefore, it can help you with routine work .... | |
For example, | |
var x ="border-top-width: 1px; border-bottom-width: 1px; border-left-width: 1px; width: 150px; right: auto; left: 725px; top: 0px; margin: 0px;" | |
inlinestyle(x) | |
//output=> {{borderTopWidth:'1px', BorderbottomWidth:'1px', borderLeftWidth:'1px', width:'150px', right:'auto', left:'725px', top:'0px', margin:'0px'}} | |
*/ | |
function inlinestyle(x){ |
OlderNewer