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
function roundPlus(x, n) { //x - число, n - количество знаков | |
if(isNaN(x) || isNaN(n)) return false; | |
var m = Math.pow(10,n); | |
return (Math.ceil(x*m)/m).toFixed(n); // в большую сторону | |
} |
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
// This is from my comment here: http://wolfram.kriesing.de/blog/index.php/2008/javascript-remove-element-from-array/comment-page-2#comment-466561 | |
/* | |
* How to delete items from an Array in JavaScript, an exhaustive guide | |
*/ | |
// DON'T use the delete operator, it leaves a hole in the array: | |
var arr = [4, 5, 6]; | |
delete arr[1]; // arr now: [4, undefined, 6] |
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
function declOfNum(number, titles) { | |
cases = [2, 0, 1, 1, 1, 2]; | |
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ]; | |
} | |
use: | |
declOfNum(count, ['найдена', 'найдено', 'найдены']); |
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
# Создается CMS компонент(если просто добавить то он будет мертвым, просто висеть в базе) | |
INSERT_UPDATE AccessoriesCMSComponent;$contentCV[unique=true];uid[unique=true];name;title | |
;;AccessoriesComponent;Accessories;Аксессуары | |
# Созается position и какие типы может принимать | |
INSERT_UPDATE ContentSlotName;name[unique=true];template(uid,$contentCV)[unique=true][default='ProductDetailsPageTemplate'];validComponentTypes(code);compTypeGroup(code); | |
;AccessoriesContainer;;AccessoriesCMSComponent;wide; | |
# Создаем ContentSlot и привязываем к нему компонент и position (При многократном добавлении cmsComponents нужно указываеть через лист, чтобы не перезаписать) | |
INSERT_UPDATE ContentSlot;$contentCV[unique=true];uid[unique=true];name;active;cmsComponents(uid,$contentCV); |
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
function getUserLocation() { | |
return $.ajax('https://www.example.com/location.json'); // note the `return` | |
} | |
function getCurrentWeather(userLocation) { | |
return $.ajax('https://www.example.com/weather' + userLocation + '.json'); | |
} | |
getUserLocation().then(getCurrentWeather).then(function(data) { | |
// location data here |
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
'use strict'; | |
var express = require('express'), | |
posts = require('./mock/posts.json'); | |
var app = express(); | |
app.get('/', function(req, res){ | |
res.send("<h1>I am with!</h1>"); | |
}); |
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
'use strict'; | |
var express = require('express'); | |
var app = express(); | |
app.get('/', function(req, res) { | |
res.send("<h1>I love Treehouse!</h1>"); | |
}); |
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
<List | |
headerText="{i18n>invoiceListTitle}" | |
class="sapUiResponsiveMargin" | |
width="auto" | |
items="{invoice>/Invoices}" > | |
<items> | |
<ObjectListItem | |
title="{invoice>Quantity} x {invoice>ProductName}"/> | |
</items> | |
</List> |
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
<ObjectListItem | |
title="{invoice>Quantity} x {invoice>ProductName}" | |
number="{ | |
parts: [{path: 'invoice>ExtendedPrice'}, {path: 'view>/currency'}], | |
type: 'sap.ui.model.type.Currency', | |
formatOptions: { | |
showMeasure: false | |
} | |
}" | |
numberUnit="{view>/currency}" |
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
sap.ui.define([ | |
"sap/ui/core/mvc/Controller", | |
"sap/ui/model/json/JSONModel", | |
"sap/ui/demo/wt/model/formatter", | |
"sap/ui/model/Filter", | |
"sap/ui/model/FilterOperator" | |
], function (Controller, JSONModel, formatter, Filter, FilterOperator) { | |
"use strict"; | |
return Controller.extend("sap.ui.demo.wt.controller.InvoiceList", { | |
formatter: formatter, |
OlderNewer