UNPKG

cejs

Version:

A JavaScript module framework that is simple to use.

529 lines 24.1 kB
�� /** * @name CeL function for API * @fileoverview * ,g�jHhS+T�N include API \(u�v functions0 * @since 2010/6/20 13:28:50 */ /* */ 'use strict'; if (typeof CeL === 'function') CeL.run({name:'data.code.API', code:function(library_namespace) { // nothing required /** * null module constructor * @class �v�['` test \(u�v functions */ var _// JSDT:_module_ = function() { // null module constructor }; /** * for JSDT: g prototype Mbg\KNvu\O Class */ _// JSDT:_module_ .prototype = { }; /* 2008/5/29 20:6:23-6/4 2:10:21 7/3 13:34 showNeighbor: �S�b�f loc->name/address, gnj�e�v�cؚ*QHQ k, bug fix: g�N*Y`��v��/fg��ReQ, g�Nя�v�S���V�p N/fOO@WNg��ReQ 7/9 13:9:15 context menu 7/9 21:12:3 getLocations 2009/7/20 20:27:58 z\O�Ock bug: T1z�v TBfg�Q�s����˄�v�`�l! TO TEST: showClass.setRepository('_ev_'); sC=showClass.showOnScope; sC('mp',GLog.write); sC('Fb','mp'); sC('y','Fb'); sC('A','y'); to use: <script type="text/javascript" src="map.js"></script> <script type="text/javascript">//<![CDATA[ wAPIcode('Gmap'); //]]></script> TODO: R^�(Categories)&RO�r�o�:y Auto Zoom Out http://esa.ilmari.googlepages.com/sorry.htm search data only preload map & markers GDirections Wx� (u�}�}�^�gb� c.f. http://jmaps.digitalspaghetti.me.uk/ http://www.ascc.sinica.edu.tw/nl/90/1706/02.txt ��cp0W@S0W T�}�z http://tgnis.ascc.net http://placesearch.moi.gov.tw/index_tw.php 0W Tx[ T^��ˑY_�} http://webgis.sinica.edu.tw/geo/Termquery.asp ��cp0W@S0W T�vܕ�e{s�gb��|q} http://webgis.sinica.edu.tw/geo/reference.html �}�o�-N.Y0Wꌿ��g@b-0W�nj�eteT�gb� http://datawarehouse.moeacgs.gov.tw/geo/index/GISSearch/MSDefault.htm http://gissrv3.sinica.edu.tw/tgnis_query/link.php?cid=1 http://www.edu.geo.ntnu.edu.tw/modules/wordpress/2008/06/08/yxaewaweaeobmh/ http://gissrv3.sinica.edu.tw/search/left2_detail.php?d_number=1&d_database=25k_2002 http://gissrv3.sinica.edu.tw/search/left2_detail.php?d_number=1085&d_database=5000_1 http://gissrv3.sinica.edu.tw/search/left2_detail.php?d_number=01663&d_database=chen_quo http://gissrv3.sinica.edu.tw/search/left2_detail.php?d_number=1663&d_database=chen_jen http://gissrv3.sinica.edu.tw/search/left2_detail.php?d_number=11880&d_database=tw_fort http://gissrv3.sinica.edu.tw/search/left2_detail.php?d_number=02713&d_database=ching http://gissrv3.sinica.edu.tw/input/detail.php?input_id=45875 nj�e�^ �}_^��W(^%R) T1z 0Wt�^j(�}�}�^) @bl\#~^ ���(@bl\L�?e@S,0Wޞ) %R1z ;��(@b(WW_�) a�(��f) http://www.isp.tw/zip.php \�]wQ 1.�n�^I��c 2.2MO�c�{ 3.BMI<P�S�qϑBl��{ 4.҉�^_^�c�{ 5.�^ϑa���{ 6.@S�x W�x�gb� 7.��^@S_��gb� 8.ё��_j�i�N_��gb� 9.r�i_h�:y�l�gb� 10.id�e�[�x�SW[�k���� 11.u��f�^�gb� 12.fZsY�[hQg��{ 13.��������gb� 14.8^(u_jܕ��q��gb� 15.*�zzlQ�S_j4X�N�x�gb� 16.!|f/S�s�c�{ 17. W�f���f�c�{ 18.%`Qe�S�u�u�_�S�[xQ 19.:\�x \gqh� 20.��lQ_��{ 21.��hy�bnjD}T�{t */ /* R�YS Google Gears http://code.google.com/apis/gears/gears_init.js http://blog.ericsk.org/archives/978 http://chuiwenchiu.spaces.live.com/blog/cns!CA5D9227DF9E78E8!1063.entry Google Gears�O: Gears�R��ck��teT0RHTML5��<h-N we expect developers to use HTML5 for these features moving forward as it's a standards-based approach that will be available across all browsers. http://it.solidot.org/article.pl?sid=09/12/03/0539248 */ function init_Google_Gears() { // �j�g/f&T�]�}�[� Google Gear if (window.google && google.gears) return; var factory = null; //O�d N T�vp��hV ��c(u N T�e_"uu GearFactory if (typeof GearsFactory != 'undefined') // Firefox factory = new GearsFactory(); else try { // IE factory = new ActiveXObject('Gears.Factory'); // privateSetGlobalObject is only required and supported on WinCE. if (factory.getBuildInfo().indexOf('ie_mobile') != -1) factory.privateSetGlobalObject(this); } catch (e) { // Safari if (typeof navigator.mimeTypes != 'undefined' && navigator.mimeTypes["application/x-googlegears"]) { factory = document.createElement("object"); factory.style.display = "none"; factory.width = factory.height = 0; factory.type = "application/x-googlegears"; document.documentElement.appendChild(factory); } } if (!factory) return 1; if (!window.google) window.google = {}; if (!google.gears) google.gears = { factory : factory }; } /* f={catch:true/false/update, restore:false/true.} */ catchFile.ls=0; // localServer catchFile.sn='catch-files'; // storeName: �[� Managed Store �v T1z �� P T1z�S(u�e createManagedStore, removeManagedStore �T openManagedStore N P API catchFile.s=0; // managed store // catchFile.f=function(url,success,captureId){}; catchFile.fL=[location.pathname]; // file list catchFile.doCache=1; catchFile.noAsk=1; function catchFile(fList, f) { var _f = arguments.callee; if (!_f.doCache) return; if (window.location.protocol == 'file:') { sl('catchFile: Google Gears N��(W,g_j N�WL�b,nf��'); return 0; } if (init_Google_Gears()) { if (_f.answered) return 0; _f.answered = 1; if (!_f.noAsk && confirm('O(u,g�R���_��[݈ Google Gears �ˊOU�`���[݈�U�')) // ?action=install&message=�ReQ`O�v �o`&return=�[݈�_��\�V�v�}@W window.location.href = 'http://gears.google.com/'; else sl('<em>catchFile: � N�[݈ Google Gears GR\!q�lO(u,g�R���</em>'); return 1; } if (!_f.ls) try { // �^�z Local Server _f.ls = window.google.gears.factory.create('beta.localserver', '1.0'); } catch (e) { sl('catchFile: Could not create local server: [' + (e.number & 0xFFFF) + '] ' + e.message); return 2; } if (!_f.s) try { // �^�z2QX[zz�� _f.s = _f.ls.createManagedStore(_f.sn); _f.s = _f.ls.createStore(_f.sn); } catch (e) { if (window.location.protocol == 'file:') sl('Google Gears N��(W,g_j N�WL�,nf�!'); else sl('catchFile: Could not create managed store: [' + (e.number & 0xFFFF) + '] ' + e.message); return 3; } if ((fList instanceof String) && fList) { // TODO: untested!! // c�[ json �v url _f.s.manifestUrl(fList); // ���Y�x�[Hr,g�S Tek _f.s.checkForUpdate(); // �p�N�x��/f&T TekP}_g�N ��S�N�ReQ NR�v timer �O�j�g� var timer = google.gears.factory.create('beta.timer'); // �k 500ms �j�gN N var timerId = timer.setInterval(function() { // Tek�[b if (store.currentVersion) { timer.clearInterval(timerId); sl(' Tek�[b'); } }, 500); } else { //_f.fL.append(fList); if (fList && fList.length) { _f.fL = _f.fL.concat(fList); } } // If the store already exists, it will be opened if (_f.s) try { _f.s.capture(_f.fL, _f.f); } catch (e) { if (e.message == 'Url is not from the same origin') sl('���(W T#j�v domain!'); else sl('catchFile: Could not capture file: [' + (e.number & 0xFFFF) + '] ' + e.message); return 4; } /* // uncapture for ( var i = 0; i < fList.length; i++) { _f.s.remove(fList[i]); } // removeStore if (localServer.openStore(storeName)) { localServer.removeStore(storeName); _f.s = null; } */ }; /* http://blog.wctang.info/2007/07/use-google-map-api-without-api-key.html W�I��v z_�S GValidateKey �/f�[�(W main.js �FO|T�S�v�R\O/f�[(W maps.js � */ _// JSDT:_module_ . /** * ��Rcx� domain * @param API API name * @param callback null: do NOT load * @return [ API url, API key ] * @since 2010/6/20 22:12:23 * @see * */ use_API = function(API, callback) { var _s = _.use_API, url_set = _s.API_URL, url = window.location, key_set = _s.API_keys || (_s.API_keys = library_namespace.data.code.API_keys), API_keys; if (!key_set) { throw 'MUST including or setup CeL.data.code.API_keys first!'; } if ( !Array.isArray(url_set = url_set[API]) || typeof url_set[1] !== 'function' || !library_namespace.is_Object(key_set = key_set[url_set[0]]) ){ CeL.error(url = 'use_API: The kind of API [' + API + '] is not included in the code pool!'); throw new Error(url); } if (url.protocol === 'file:') // �S�_�NUO legal key for (url in key_set){ if (typeof key_set[url] === 'string') break; } // this is for domain + path //else if ((url = url.href.replace(/[^\/]+$/, '')) in key_set) ; // this is for domain. N��(u .pathname: IE g\Oyr�kU�n else if (!(url = url.href.match(/^([a-z-]+:\/\/[^\/]+\/)/)) || !((url = url[1]) in key_set)){ CeL.error(url = 'use_API: This domain [' + url + '] is not included in ' + url_set[0] + ' code pool!'); throw new Error(url); } //library_namespace.debug('[' + url + ']\n' + key_set[url] + '\n' + location.href + '\n' + location.pathname); url = url_set[1](API_keys = key_set[url] || '', _s.language || ''); if (callback !== null){ library_namespace.run(url, callback); library_namespace.debug('load [' + url_set[0] + '] ' + API + ': [<a href="' + url + '">' + url + '</a>].'); } return [ url, API_keys ]; }; _// JSDT:_module_ . /** * ���|. e.g., zh-TW, ja, en */ use_API.language = 'zh-TW'; _// JSDT:_module_ . use_API.API_URL = { Gmap : [ 'Google', function(k, l) { return 'http://maps.google.com/maps?file=api&v=2&hl=' + l + '&key=' + k; } ], GAPI : [ 'Google', function(k, l) { return 'http://www.google.com/jsapi?hl=' + l + '&key=' + k; } ], YMap : [ 'Yahoo', function(k) { return 'http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=' + k; } ], twYMap : [ 'Yahoo', function(k) { return 'http://tw.api.maps.yahoo.com/ajaxymap?v=3.8&appid=' + k; } ], Bing: [ 'Microsoft', function(k) { return 'http://api.microsofttranslator.com/V1/Ajax.svc/Embed?appId=' + k; } ] }; _// JSDT:_module_ . /** * �p Microsoft Translator -�n * @param text test to translate * @param callback callback(from text,to text) * @param [from_enc] * @param [to_enc] * @return * @see * <a href="http://msdn.microsoft.com/en-us/library/ff512406.aspx" accessdate="2010/7/12 20:22">Translate Method</a>, * <a href="http://www.west-wind.com/Weblog/posts/107136.aspx" accessdate="2010/7/12 20:22">JSONP for cross-site Callbacks - Rick Strahl's Web Log</a> */ add_Microsoft_translate = function(text, callback, from_enc, to_enc) { if (!text || !callback) return; var _s = _.add_Microsoft_translate, url = _s.url, name = _s.reference_name, count; // R�YS initialization if (!url) _s.url = url = 'http://api.microsofttranslator.com/V2/Ajax.svc/Translate?appId=' + _.use_API('Bing', null)[1]; //library_namespace.debug('<a href="' + url + encodeURIComponent(text) + '">' + url + encodeURIComponent(text) + '</a>'); _s.buffer[count = _s.counter++] = [ text, callback ]; // response, count, function name of add_Microsoft_translate _s['c' + count] = new Function('r', name + '.callback(r,' + count + ',"' + name + '");' ); library_namespace.run( url + '&from=' + (from_enc || _s.from) + '&to=' + (to_enc || _s.to) + '&text=' + encodeURIComponent(text) + '&oncomplete=' + name + '.c' + count ); }; _// JSDT:_module_ . add_Microsoft_translate.from = 'en'; _// JSDT:_module_ . add_Microsoft_translate.to = 'zh-cht'; _// JSDT:_module_ . add_Microsoft_translate.reference_name = library_namespace.Class + '.add_Microsoft_translate'; _// JSDT:_module_ . /** * @inner * @private */ add_Microsoft_translate.counter = 0; _// JSDT:_module_ . /** * @inner * @private */ add_Microsoft_translate.buffer = []; var ELEMENT_NODE = 1; _// JSDT:_module_ . /** * @inner * @private */ add_Microsoft_translate.callback = function(response, count, name) { try{ var _s = library_namespace.get_various(name), origin = _s.buffer[count], callback = origin[1]; origin = origin[0]; delete _s.buffer[count]; delete _s['c' + count]; if (typeof callback === 'function') { callback(response, origin); } else { if (typeof callback === 'string') callback = document.getElementById(callback); if (typeof callback === 'object' && callback.nodeType === ELEMENT_NODE) callback.appendChild(document.createTextNode(response)); } }catch (e) { library_namespace.warn('add_Microsoft_translate.callback: '+name+': error!'); } }; return ( _// JSDT:_module_ ); } });