1, the recent retreat (closed development), imitation Nodejs built a and URL-related small module, with a paging component is very good:
(1), get parameters: var id=iurls.query.id or var id=iurls.param (' id ');
(2), set parameters: Return Location.search;iurls.setparam (name, value);
(3), GET request: Iurls.search ({});
1 varIurls =function(Loc) {2 varSearch = LOC.SEARCH.SUBSTR (1);3 varSearcharr = Search.indexof (' & ')! =-1? Search.split (' & ')): [Search];4 5 functionGeturldata (k) {6 varparam = {};7 for(vari = 0; i < k.length; i++) {8 if(K[i]! = "") {9 varv = k[i].split (' = '));Ten for(varj = 0; J < V.length; J + +) { One varKey = decodeURIComponent (v[0]); A varValue = decodeURIComponent (v[1]); -Param[key] =value; - } the}Else { - return‘‘; - } - } + returnparam; - } + return { A Query:geturldata (Searcharr), atSetParam:function(name, value) { - //return Search - varparam =Geturldata (Searcharr); - if(param) { -Param[name] =value; - varPararr = []; in for(varIinchparam) { -Pararr.push (i + ' = ' +param[i]); to } + returnPararr.join (' & ')); -}Else { the returnname + ' = ' +value; * } $ //location.href=location.pathname+ "?" +pararr.join (' & ');Panax Notoginseng //return Pararr.join (' & '); - }, theParamfunction(PAR) { + returnGeturldata (Searcharr) [par]; A }, theSearchfunction(s) { + varur =S.url; - vardata = S.data | | {}; $ varhref = "; $ if(UR) { - if(Ur.indexof ('? ')! =-1) { -href =ur; the}Else { -href = ur + '? 'Wuyi } the } - varDatas = []; Wu for(varNameinchdata) { - if(name) { AboutDatas.push (name + ' = ' +Data[name]); $ } - } - if(href! = ") { -href = Href.charat (href.indexof ('? ') + 1) = = ""? Href:href + ' & '; Alocation.href = href + datas.join (' & ')); +}Else { theLocation.href = Loc.pathname + '? ' + datas.join (' & ')); - } $ } the } the} (window.location);
2, IE9 iframe under the static resources error, although the program can run normally, but some systems will not be able to run; IFrame is not on the page, from the JS output, the solution requires: dynamic creation of the IFRAME;
3, Sass compiled a lot of ways, koala did not want to use, Sublime ctrl+b a key can be compiled; Grunt compilation (Sword--grunt of front-end automation); Gulp compilation (Artifact-gulp of front-end automation); many ways, Suddenly forget the way the SASS command line is compiled, and sometimes it's a simple way to do it:
(1), direct compilation: Sass./path/*.scss./PATH/TO/*.CSS (2), compiled Style:sass--style compressed./path/*.scss./path/to/*.css
* nested: Nested indentation of the CSS code, which is the default value.
* expanded: No indented, extended CSS code.
* Compact: A concise form of CSS code.
* Compressed: Compressed CSS code. (3), monitoring file changes are compiled: Sass--watch./PATH/*.SCSS:./PATH/TO/*.CSS (4), Sass of the Operational Conversion tool: Sass-i into; RGB to 16 in the output: 000000;type-of (()) Output: list;
4. Unzip the file
1 varFS = require (' FS '), 2Unzip = require (' unzip ')); 3 //Fs.createreadstream ('./angular-swipe-master.zip '). Pipe (unzip. Extract ({path: './'}); 4 varextract = Unzip. Extract ({path: './') }); 5Extract.on (' Error ',function(err) {6 Console.log (err);7 }); 8Extract.on (' Finish ',function() { 9Console.log ("unziped!!"); Ten }); OneFs.createreadstream ('./angular-swipe-master.zip '). pipe (extract);
5. Compress files
1 varFS = require ("FS"); 2 varZip = require ("Node-native-zip"); 3 varArchive =Newzip ();4 5 Archive.addfiles ([6{Name: "APP.J", Path: "./app.js" }, 7{Name: "Package.json", Path: "./package.json" } 8],function(err) {9 if(ERR)returnConsole.log (err);Ten varBuff =Archive.tobuffer (); OneFs.writefile ("./test2.zip", Buff,function () { AConsole.log ("ziped"); - }); -});
6, about Nodejs static resource compression and caching see: (Nodejs to create a static resource server and file upload); Just learned express that will, dynamic file gzip compression, for a long time have not found the right method, only to find it is so simple ... Add compression module in app.js: Install first;
1 var compress=require (' compression '); 2 App.use (compress ());
OK the dynamic file can also be gzip compressed;
Retreat for 3 weeks, station no time to update, small partners do not forget Ah!
Source: A collection of front-end (Javascript, HTML, CSS) code Snippets
Some of the assorted front-end related