星期四, 10月 29, 2015

Youtube 讓iframe有透明度

記錄一下在做youtube iframe滿版時遇到元素被遮住的問題,
可以加wmode=transparent 字串到Video的URL後面即可。
遇到IE瀏覽器記得要下meta讓IE執行edge模式

Add this in your html:
http-equiv="X-UA-Compatible" content="IE=edge" />
The page in IE is rendering in Quirk mode.

Try using Youtubes iframe embed method (if thats not what you are already doing, and add: ?wmode=transparent to the url (replace ? with & if it is not the first url variable)

[UI-Bootstrap] 讓0.12.1版的popup value支援html


如果為了讓popover的支援顯示html語法,可以自行手動新增這個directive。


記錄一下google後的記錄~~

代碼如下:

備註: 0.13版似乎已被merge進主幹了

/*新增一個ui.bootstrap.popover*/
angular.module( 'ui.bootstrap.popover' )
.directive( 'popoverHtmlUnsafePopup', function () {
    return {
        restrict: 'EA',
        replace: true,
        scope: { title: '@', content: '@', placement: '@', animation: '&', isOpen: '&' },
        template: '

' }; }) .directive( 'popoverHtmlUnsafe', [ '$tooltip', function ( $tooltip ) { return $tooltip('popoverHtmlUnsafe', 'popover', 'click' ); }]);

其他用法:

1. 另外在往後的版本還有新增popover-is-open,可以提供更多彈性的控制
Starting with the 0.13.4 release, we've added the ability to programmatically control when your tooltip/popover is open or closed via the tooltip-is-open or popover-is-open attributes.

2. popover-trigger="mouseenter" 提供mouse觸發顯示

3. 手機顯示時,讓popover只維持一個關掉的方法

 angular.element(document.body).bind('click', function (e) {
         logger.debug('body click from ng');
         //Find all elements with the popover attribute
         var popups = document.querySelectorAll('*[popover]');

         if (popups) {
             //Go through all of them
             for (var i = 0; i < popups.length; i++) {
                 //The following is the popover DOM elemet
                 var popup = popups[i];
                 //The following is the same jQuery lite element
                 var popupElement = angular.element(popup);

                 var content;
                 var arrow;
                 if (popupElement.next()) {
                     //The following is the content child in the popovers first sibling
                     content = popupElement.next()[0].querySelector('.popover-content');
                     //The following is the arrow child in the popovers first sibling
                     arrow = popupElement.next()[0].querySelector('.arrow');
                 }
                 //If the following condition is met, then the click does not correspond
                 //to a click on the current popover in the loop or its content.
                 //So, we can safely remove the current popover's content and set the
                 //scope property of the popover
                 if (popup != e.target && e.target != content && e.target != arrow) {
                     if (popupElement.next().hasClass('popover')) {
                         //Remove the popover content
                         popupElement.next().remove();
                         //Set the scope to reflect this
                         popupElement.scope().tt_isOpen = false;
                     }
                 }
             }
         }
     });

參考:

    

http://stackoverflow.com/questions/11703093/how-to-dismiss-a-twitter-bootstrap-popover-by-clicking-outside

https://jsfiddle.net/mattdlockyer/C5GBU/2/

http://mattlockyer.com/2013/04/08/close-a-twitter-bootstrap-popover-when-clicking-outside/

http://stackoverflow.com/questions/23048990/can-bootstrap-tooltips-be-turned-off-based-on-device-screen-size

http://plnkr.co/edit/fhsy4V?p=preview

https://github.com/angular-ui/bootstrap/issues/618

http://stackoverflow.com/questions/31770019/angular-ui-bootstrap-popover-how-add-a-close-button




星期二, 10月 20, 2015

[Java] log4j 的設定檔配置筆記

先前有筆記一下如何設定log4j,這篇只要蒐集一些有關log4j.xml的一些工作手寫:D


  • log4j.xml 的優先權會大於 log4j.properties
  • log4j.jar不要放在每個application中
  • Web專案的話log4j.xml 的檔案路徑請放在 WEB-INF/classes/之下
  • Java專案的話可以建一個resoucrce資料夾,並把log4j.xml放在之下
  • 或著自行指定路徑,再利用DOMConfigurator.configure去讀取ex: DOMConfigurator.configure(log4jConfigurationFilename);

參考
http://wiki.apache.org/logging-log4j/Log4jConfigurationHelp

星期六, 10月 17, 2015

[Android] 解決SearchView發生 API版本錯誤

今天在使用SearchView時,
發生elicpse會發生View requires API Level11 (current min is 7): 錯誤

只要


Right click on the project folder > Android tools > Clear Link Markers 就可以解決啦


星期五, 10月 16, 2015

[Anroid] EditText onTextChanged 低級錯誤 infini loop

很腦的bug,記錄一下,不小心造成onTextChanged無窮執行,
起因在於更新UI Text時,又call了一下setText的函數,因為onTextChanged觸發時,Text已在UI變更,不應再使用setText

星期一, 10月 05, 2015

[GoogleMap] 如何動態載入Googlemap API

最近試著使用google map的離線api,目前google可以找到不同版本的,目前測試是3.8.2。
如果是在頁面直接透過script標籤引入mapapi.js是沒什麼大問題的!!

不過由於要實作讓使用者切換線上與離線地圖就發現了很扯的bug,
記錄以下失敗的方法,有需要的朋友可以參考。

嘗試失敗的方法

使用document.write,整個瀏覽器白畫面,無法使用且google map無法完全載入


                     var jsTag = '<' + 'script src="http://localhost:8080/js/libs/offlinemap/google/mapapi.js"' +
                        ' type="text/javascript"><' + '/script>';
                document.write(jsTag);


使用document.createElement的方法,console會噴以下這個錯誤 
Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.


   var element = document.createElement("script");
                element.src = "js/libs/offlinemap/google/mapapi.js";
                element.type = "text/javascript";
                document.getElementsByTagName("head")[0].appendChild(element);

成功的方法

星期日, 8月 09, 2015

[Java] Granule Asset 函式庫測試

記錄一下使用Granule來編譯js/css檔的過程,雖然專案有點舊了,但試用起來效果還不錯。
主要是看上有JSP Tag很好整合。

功能如下

  1. Combine and compresses JS and CSS using different methods: on fly or in build process, CSS and JS fast compression or more sophisticated Google Closure compression, or just simple file combining.
  2. No-lock in solution. The tag just put around existing scripts. The tag can be turn on/off on the different levels: page and application.
  3. Debug and production modes.
  4. Calculate dependencies using Closure Library package/namespace system.
  5. Can automatically choose optimization methods.
  6. Multiple combinations of JS/CSS even with different compression methods on one page.
  7. Support JSP includes.
  8. Several types of cache, memory and file.
  9. Automatically regenerates the bundle if you modify an included file.
  10. Proxy-friendly GZip support.
  11. Rewrites relative URLs in your CSS files.
  12. JSP, JSF, Grails integration.
  13. Multiple loggers support (SLF4J, Log4J, Apache Logger)
  14. Can be setup to preserve license headers of JS libraries.
  15. JDK1.5 and higher even for Google Closure Compiler.

安裝

星期五, 8月 07, 2015

[Java] Granule 解決tomcat8 檔案路徑回傳null問題

https://github.com/JonathanWalsh/Granule

最近找了這個工具來幫js/css瘦身,在tomcat 8下轉換assets file路徑會在getRealPath下產生Exception。

The parameter for getRealPath() is a 'virtual path' which - unfortunately - is a concept used in the Java docs but not actually defined anywhere. It is assumed to be a path to a resource in your web application and the separator in that case is always '/' regardless of platform.

解決方法要在html頁面引用javascript file時,要多加一個/





星期一, 8月 03, 2015

[Shellscript] 批次修改檔名


一行指令修改檔案: D 測試環境Mac OSX已ok

 find . -name '*.jpg' -exec sh -c 'mv "$0" "${0%.jpg}.png"' {} \;


For M$ windows可以參考這個軟體

星期二, 7月 21, 2015

[Raphael.js] ie8 圖片無法置中

今天測試在ie8執行時,發現圖片會無法置中,找到以下這個討論

https://github.com/DmitryBaranovskiy/raphael/issues/361


主要是svg使用vml轉換時的問題,解決方法如下:


只要打開原始碼找到以下這段

fill.size = _.fillsize[0] * abs(sx) + S + _.fillsize[1] * abs(sy);

修改如下即可解決

fill.size = _.fillsize[0] * abs(sx)/1.34 + "pt" + S + _.fillsize[1] * abs(sy)/1.34 + "pt";


星期二, 7月 14, 2015

[jQuery Plugin] jqplot 重新調整tooltip

在jqplot裡面的highlighter擴充模組提供了tooltipContentEditor方法讓使用者可以處理tooltip的效果,測試ok的範例如下:



tooltipContentEditor: function (str, seriesIndex, pointIndex, jqPlot) { plugin.logger.debug('tooltipContentEditor (x,y): ' + str); // console.log('str: ' + str);// x , y // console.log('seriesIndex: ' + seriesIndex); // console.log('pointIndex: ' + pointIndex); // console.log(jqPlot.options.axes.xaxis.ticks); // console.log(jqPlot.data[seriesIndex]); // console.log(jqPlot); var xAxis = jqPlot.options.axes.xaxis.ticks[parseInt(str) - 1]; // str.split(',')[0]; var yAxis = str.split(',')[1];//這樣取比較準 var newElem = '
' + '' //以下這個方法有時候取得的值會異常,例如設成年的時候 // +'
' + jqPlot.series[seriesIndex]["label"] + '
x axis: ' + xAxis + '
y axis: ' + jqPlot.data[seriesIndex][pointIndex] + '
'; + '
y axis:
' + yAxis + '
'; return newElem; }
http://stackoverflow.com/questions/17719534/jqplot-tooltip-content-editor

2015/12/28後記

被qa發了tooltip值異常的問題,擷圖來記錄一下,最後修正最完了的xaxis的解法請參上的範例即可。

星期日, 7月 12, 2015

[jQuery plugin] 解決jqplot 動態繪圖記憶體一直長大的問題

目前在專案上使用jqplot來繪圖,遇到記憶體一直長大的問題,
經過測試以下這個作者的解法是可用的
https://edsilverton.wordpress.com/2011/04/11/avoiding-jqplot-memory-leaks/

在每次重新繪圖時需要把元素整個幹掉,記憶體才會真的往下嶧放掉。

星期六, 7月 11, 2015

[CI] 記錄一下CI框架新手功能

記錄一些CI框架Seed常用的功能手記,讓日後可以快速回憶 :D
雖然已經是被很多人放棄的技術,不過還是有他方便的地方XD

測試版本

CI 2.x

設定起始的base url

Just overwrite the line in config/config.php with the following:
$config['base_url']    = 'http://'.$_SERVER['HTTP_HOST'].'/';
If you are using the sub folder you can use following code:
$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url']    = "$root";

設定資料庫


application/config/database.php:

設定啟動的控制器


打開application/config/routes.php:
$route['default_controller'] = 'index';

設定啟動時載入相關的helper


打開application/config/autoload.php:
// $autoload['helper'] = array();
$autoload['helper'] = array('form','url','assets','images','load_view_helper');

星期五, 7月 10, 2015

[Wordpress] Limit Login Attempts 設定使用者登入太多次的鎖定外掛

如果要預防使用者一直嘗試登入電腦,可以透過 Limit Login Attempts
來限制使用者可以登入錯誤的次數,不過外掛已經有二年未更新了XD

https://wordpress.org/plugins/limit-login-attempts/

星期一, 7月 06, 2015

[Docker] 快快樂樂學Docker指令集

由於上周為了在MAC上面安裝跟開發機一樣的環境,結果費時費力還會爆炸,決定使用docker來統一一下開發的環境。

測試環境

Mac OS X 10.9.5

安裝Docker

1. 下載boot2docker
https://github.com/boot2docker/osx-installer/releases/

安裝後docker 和 boot2docker 的執行檔就已經放在 /usr/local/bin,而且也會多裝一個Virtualbox,因為docker是要跑在linux核心上面

2. 安裝新的linuxVM

$boot2docker init

執行過程中,會去下載 boot2docker.iso,並建立 Linux VM

3. 啟動 boot2docker-vm 虛擬機器 => 有了這個VM才有辦法開始使用docker
$boot2docker start


啟動後會提示需要export 以上設定,否則無法使用docker指令集



另外boot2docker安裝後,可以在應用程式看到一個boot2ocker iCON,也可以用來開這個vm



boot2docker 其他指令集

#取得boot2docker VM IP
$boot2docker ip

#可以在啟動前,先檢查有沒有新版的images
$boot2docker upgrade

docker常用指令集

星期一, 6月 22, 2015

[Android] 無法產生R.java檔

記錄一下第一次import要android專案踩到的雷,基本上網路上都找的到,但大家遇到的CASE都不一定相同。以下自已的解決方法,希望可以幫助遇到一樣問題的人。

R.java無法產生的問題如下:

  • ADT更新不完成 => 套用的SDK版本相關的組件沒安gk
  • 專案內的libs:裡面也放了參照的library,造成偵測到二個版本而無法編譯
          
  • res內的 *.xml一定有格式爆炸了,所以才會無法產生。
    • 有遇到新增新的Activity時,對應的樣版xml檔案內缺少XML 文件宣告而爆炸
  • 重覆引用appcompat_v7 專案的library(這個是新增Android自行產生的專案lib): 僅需使用android-support-v7-appcompat (這專案是從android-sdk_r24.3.3-macosx.zip下載之後內的專案匯入的,主要是要import它build出來的android-support-v7-appcompat.jar與android-support-v4.jar)


如何設定android-support-v7-appcompat設定成專案可以引用的libraries

1. 首先從下載android-sdk_r24.3.3-macosx.zip 解開後,把裡面的/Applications/eclipse/android-sdk-macosx/extras/android/support/v7的專案import到eclipse的workspace

2. 匯入後,在android-support-v7-appcompat的專案按右鍵,選properties,跳出下圖視窗,照紅色框線步驟點擊,第三步要把Library內的is Library打勾,我們就可以build一個library

3. 接著在匯入的專案指定要referenc android-support-v7-appcompat專案所產生的lib,按下ADD按鈕後,會跳出讓你選你要參考的專案lib,記得只能選擇android-support-v7-appcompat的lib而不要選appcompat_v7 專案的lib






請教完同事後,建議沒事不要亂更新IDE的SDK,除非是專案有必要,不然很容易爆炸的XD
android模擬器常發生專案無法run上去的情形,但大原則是專案只要沒有紅色的警告,接上手機來build code基本上都是可以跑的,筆記筆記。

星期日, 6月 14, 2015

[NetBeans] tomcat8.0.x 如何在netbeans 8成功執行

當使用tomcat8要在netbeans8執行時會發生錯誤,
可以修改catalina.bat裡面的JAVA_OPTS參數設定,
請照以下三步驟即可解決無法run tomcat的問題。


Step1: 打開你的catalina.bat
C:\\apache-tomcat-8.0.23\apache-tomcat-8.0.23\bin\catalina.bat


Step2: 找到以下的設定

:noJuliConfig
set "JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%"

:noJuliManager
set "JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%"

Step3: 移掉雙引號

:noJuliConfig
set JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%

:noJuliManager
set JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%


星期六, 6月 13, 2015

[AngularJS-3rd] angular-dialog-service 模組輕鬆整合訊息對話窗效果

記錄一下整合angular-dialog-service的程式筆記

主程式

libs/angular-dialog-service/dialogs.min.js => version 5.0.0

其他相依模組

required ngSanitize, bootstrap.ui,ngTranslate

Demo


以一個編輯用戶的LIST來做說明

編輯使用者
             $scope.editUser = function($index, user) {
            logger.info('edit user');
               var dlg = dialogs.create(
                'partials/users/dialog/dialog.updateUserInfo.html',
                'DialogUpdateUserInfoCtrl',
                user, {}
            );
            dlg.result.then(function(resultData) {

                $scope.users[$index] = resultData; //update users data

               
            }, function() {

            });
        };

刪除使用者
  $scope.deleteUser = function($index, user) {
            logger.info('delete user');
            // console.log(user);
            var dlg = dialogs.confirm(
                '刪除帳戶',
                '你確定要刪除帳戶' + user.U_Email + '嗎?'
            );
            dlg.result.then(function(resultData) {
//reload user data
            });

        };

其他你感興趣的文章

Related Posts with Thumbnails