Приглашаем принять участие в Летней школе
СберЛаб-НГУ с 1 июля по 2 августа!
Если тебе всегда было интересно программирование, у тебя есть желание работать и развиваться в IT-сфере, ты учишься в университете – тебе определенно к нам!
Летняя школа СберЛаб-НГУ это:
Практическая и теоретическая подготовка в процессе проектной работы;
Кураторство команд от преподавателей НГУ и экспертов IT-направлений компаний из экосистемы Сбер;
Проекты, реализуемые в лаборатории, могут стать выпускной квалификационной работой в НГУ;
Новый пункт достижений в резюме: выпускники лаборатории приравниваются к специалистам с опытом работы 1-2 года;
Возможность трудоустройства сразу после окончания учебы!
По итогам участия в Летней школе выплачивается стипендия и выдаётся сертификат.
А также: участники, успешно прошедшие обучение в Летней школе, получат приглашение продолжить прохождение практики с выплатой стипендии в СберЛаб-НГУ в течение нового учебного года.
Прохождение стажировки в лаборатории позволит совместить практику в отрасли с обучением в университете!
Занятия и работа над проектами будут проводиться в аудиториях нового корпуса НГУ, а предполагаемая нагрузка составляет 40ч в неделю.
Успей подать заявку, заполнив форму: https://forms.gle/BW1LfacPC7JhfgFh9
При регистрации необходимо указать 3 наиболее интересных для тебя проекта в порядке приоритета.
Выбор не окончательный, списки команд будут сформированы в первые 2 дня проведения летней школы, но нам нужно понимать твои предпочтения.
Ознакомиться со списком всех проектов можно в приложенном файле
А также, подписывайся на группу и следи за нашими новостями!
`;
}
var xdata = {id: 0, functions: {}};
function xeval(template, values = {}, chunkid = 0) {
var id = ++xdata.id;
// save pointer for item updates
//if (chunkid) template = template.replace(">", ` xid='${chunkid}'>`);
template = template.replace(">", ` data-eval='${id}'>`);
template = template.replace(new RegExp("@{", "g"), "${");
template = "`" + template + "`";
// rendering function
var effectfn = function() {
var m = values;
with(values) return eval(template);
};
xdata.functions[id] = {fn: effectfn, values: values};
return effectfn(); }
function xtrigger(itemid) {
var nodes = document.querySelectorAll(`[xid='${itemid}']`); // performance
Array.prototype.forEach.call(nodes, node => xdraw(node));
}
function xdraw(node) {
node = node.closest("[data-eval]");
var itemdata = xgetdata(node);
if (node.hasAttribute("x-nooptimize")) {
//var time1 = performance.now();
node.outerHTML = itemdata.fn();
//console.log("outer_html:", performance.now() - time1);
} else {
//var time1 = performance.now();
var newNode = xhtmldom(itemdata.fn());
//var time2 = performance.now();
xreplacetree(node, newNode);
//var time3 = performance.now();
//console.log("new_tree:", time2 - time1, "diff_tree:", time3 - time2);
}
}
function xreplacetree(a, w) {
var same = (a.nodeType == w.nodeType);
if (a.nodeType == Node.TEXT_NODE) {
same = same && (a.nodeValue == w.nodeValue);
if (!same) a.nodeValue = w.nodeValue;
} else
if (a.nodeType == Node.ELEMENT_NODE) {
same = same && (a.localName == w.localName);
same = same && (a.attributes.length == w.attributes.length);
same = same && (a.childNodes.length == w.childNodes.length);
//for (var i = 0; i < w.attributes.length && same; i++)
// same &&= a.attributes[i].name == w.attributes[i].name;
if (same) {
if (a.nodeType == Node.ELEMENT_NODE) {
for (var i = 0; i < w.attributes.length; i++) {
//if (w.attributes[i].name == "value") continue;
if (a.attributes[i].value != w.attributes[i].value)
a.attributes[i].value = w.attributes[i].value;
}
var childs = Array.prototype.slice.call(w.childNodes, 0);
for (var i = 0; i < childs.length; i++) xreplacetree(a.childNodes[i], childs[i]);
}
} else
a.replaceWith(w); // replaceWith - slow
}
}
function xhtmldom(html) {
return document.createRange().createContextualFragment(html).firstElementChild;
}
function xgetdata(node) {
var ptrnode = node.closest("[data-eval]"); if (!ptrnode) return {};
return xdata.functions[ptrnode.dataset.eval] || {}; }
function xgetscope(node) {
return xgetdata(node).values || {}; }
function xfor(items, handler) {
var result = [];
Array.prototype.forEach.call(items, (value, key) => {
var itemhtml = handler(value, key); result.push(itemhtml);
});
return result.join("\n"); }
function xaddhtml(node, html) {
node.appendChild(document.createRange().createContextualFragment(html)); return node.lastElementChild; }
function xremovehtml(selector) {
var exist = document.querySelector(selector); if (exist) exist.remove(); }
Object.defineProperty(HTMLElement.prototype, "m", {
get() { return xgetscope(this); }
});
function h_multifile_input(item)
{
return xeval(`
@{xfor(jasmineGetFiles(item), (imgitem) => \`
\`)}
`, {item: item});
}
function multifile_pickfiles(input)
{
var module = input.closest("main");
jasmineAddFiles(input.m.item, () => {
xdraw(module);
});
}
function multifile_remfile(input, id)
{
jasmineRemoveItem(jasmineGetItem(id)); //fix
jasmineBroomItemCache(0, 0, input.m.item); //fix
xdraw(input);
}
/*
...
...
*/
function sortable(ev, movex = true, movey = true)
{
return sortable__start.call(document.body, ev, movex, movey);
}
function sortable__start(ev, movex = 1, movey = 1)
{
ev.preventDefault();
var touchmove = ev.type == "touchmove";
var touchstart = ev.type == "touchstart";
var touch = touchmove || touchstart;
//---
if (!this._sort) {
if (touch) {
this.ontouchend = sortable__up;
this.ontouchcancel = sortable__up;
if (touchstart)
this.addEventListener("touchmove", sortable__move, {passive: false});
} else {
this.onpointerup = sortable__up;
this.onpointerover = sortable__over;
this.onpointerleave = sortable__up;
this.onpointermove = sortable__move;
}
//--
var el = ev.currentTarget;
el = el.closest("[data-id]"); // fixit
if (touch) {
el = el.closest("[data-id]");
if (!el) return alert("No id");
}
var bbox = el.getBoundingClientRect();
var style = getComputedStyle(el);
//--
sortable__getPointerEvent(ev);
//
var basestyle =
//---
this._sort = {};
this._sort.element = el;
this._sort.parent = el.parentNode;
this._sort.class = "." + el.classList[0];
this._sort.touchdx = bbox.left - ev.clientX;
this._sort.touchdy = bbox.top - ev.clientY;
this._sort.movex = movex;
this._sort.movey = movey;
//---
var parent = el.parentNode || el.closest("body > main") || document.body;
//clog(parent);
//---
this._sort.ghost = parent.appendChild(el.cloneNode(true));
this._sort.ghost.style.position = "fixed";
this._sort.ghost.style.zIndex = "10000";
this._sort.ghost.style.pointerEvents = "none";
this._sort.ghost.style.opacity = 1.0;
this._sort.ghost.style.width = bbox.width + "px";
this._sort.ghost.style.height = bbox.height + "px";
this._sort.ghost.style.left = bbox.left + "px";
this._sort.ghost.style.top = bbox.top + "px";
this._sort.ghost.style.margin = "0px";
this._sort.ghost.style.padding = style.padding;
this._sort.ghost.style.opacity = style.opacity;
this._sort.ghost.focus();
//
this._sort.originOpacity =
this._sort.element.style.opacity;
//this._sort.element.style.opacity = 0;
this._sort.element.style.pointerEvents = "none";
this._sort.element.style.visibility = "hidden";
}
if (touchmove)
sortable__move.call(this, ev);
}
function sortable__up(ev)
{
ev.preventDefault();
this.onpointerup = null;
this.onpointerover = null;
this.onpointerleave = null;
this.onpointermove = null;
this.ontouchmove = null;
this.ontouchend = null;
this.ontouchcancel = null;
this.removeEventListener("touchmove", sortable__move);
//--
this._sort.element.style.pointerEvents = "";
//this._sort.element.style.opacity = this._sort.originOpacity;
this._sort.element.style.visibility = "";
//--
if (this._sort.ghost)
this._sort.ghost.remove();
if (this._sort.swapped) {
var ids = [];
//var asc = this._sort.element.parentNode.dataset.asc;
//var table = this._sort.element.closest('[data-table]').dataset.table;
var items = this._sort.element.parentNode.querySelectorAll("[data-id]");
items.forEach((item) => {
if (item.dataset.id)
ids.push(parseInt(item.dataset.id) || item.dataset.id);
});
//this._sort.element.parentNode.dispatchEvent(
// new CustomEvent("reorder", {detail: {ids: ids, table: table, asc: asc}, bubbles: true}));
//ids = ids.join(",");
this._sort.element.parentNode.dispatchEvent(
new CustomEvent("sort", {detail: {ids: ids}, bubbles: true}));
if (window.onreorder)
window.onreorder({detail: {ids: ids}});
var onsort = this._sort.element.closest("[onsort]");
if (onsort) {
var onsortfn = new Function("event", onsort.getAttribute("onsort"));
onsortfn({detail: {ids: ids}});
onsort.dispatchEvent(new CustomEvent("sort", {detail: {ids: ids}}));
}
}
this._sort = null;
}
function sortable__move(ev)
{
ev.preventDefault();
ev.stopPropagation();
sortable__getPointerEvent(ev);
if (this._sort.movex) this._sort.ghost.style.left = (ev.clientX + this._sort.touchdx) + "px";
if (this._sort.movey) this._sort.ghost.style.top = (ev.clientY + this._sort.touchdy) + "px";
//--
var touchmove = ev.type == "touchmove";
if (touchmove) {
var hover = document.elementFromPoint(ev.clientX, ev.clientY);
if (hover) hover = hover.closest(this._sort.class);
if (hover) {
this._sort.swapped = true;
sortable__swap(this._sort.element, hover);
}
}
}
function sortable__getPointerEvent(ev)
{
if (ev.changedTouches) {
ev.clientX = ev.changedTouches[0].clientX;
ev.clientY = ev.changedTouches[0].clientY;
}
}
function sortable__over(ev)
{
ev.preventDefault();
var hover = ev.target.closest(this._sort.class);
if (hover) {
if (hover.parentNode == this._sort.element.parentNode) {
this._sort.swapped = true;
sortable__swap(this._sort.element, hover);
}
}
}
function sortable__swap(el1, el2)
{
if (!el1 || !el2 || el1 == el2) return;
var pos1 = Array.prototype.indexOf.call(el1.parentNode.children, el1);
var pos2 = Array.prototype.indexOf.call(el2.parentNode.children, el2);
if (pos2 < pos1) {
el1.parentNode.insertBefore(el1, el2);
} else {
el1.parentNode.insertBefore(el1, el2.nextElementSibling);
}
}
function urlGet(name)
{
var pairs = location.hash.substr(1).split(";");
var values = {};
xwalk(pairs, pair => {
pair = pair.split(":");
values[pair[0]] = pair[1];
});
return values[name];
}
// jasmineAddItem
function jasmineAddItem(item, onload, save = true)
{
// uncache
jasmineBroomItemCache(item.folderid);
// local
store.items.push(item);
if (!item.id) item.id = jasmineNewId();
// remote
if (save) jasmineSaveItem(item, onload);
return item;
}
// jasmineRemoveItem
function jasmineRemoveItem(item, onload, save = true)
{
// uncache
jasmineBroomItemCache(0, item.id);
// local
var removeIndex = store.items.findIndex(i => i.id == item.id);
if (removeIndex >= 0) store.items.splice(removeIndex, 1);
// remote
if (save && item.id > 0)
jasmineAjax("./?api=app::client_item_remove", {values: {id: item.id}, onload: (msg) => {
if (msg) return alert(msg);
onload && onload();
}});
else
onload && onload();
}
// jasmineSaveItem
function jasmineSaveItem(item, onload)
{
jasmineAjax("./?api=app::client_item_save", {values: {item: jasminePrivateCleanFields(item)}, file: item._file, onjson: (json) => {
if (json.image) item.image = json.image;
if (json.id) { jasminePrivateReplaceId(item.id, json.id); item.id = json.id; }
delete(item._file);
delete(item._preview);
onload && onload();
}});
}
// jasmineGetItem
function jasmineGetItem(id)
{
return store.items.find(i => i.id == id);
}
// jasmineSortItems
function jasmineSortItems(ids)
{
var sortLocal = function(ids) {
var weights = {};
var sortedids = ids.slice();
sortedids.sort(function(a, b) { return a - b });
for (var i = 0; i < ids.length; i++) {
weights[ids[i]] = sortedids[i];
var item = jasmineGetItem(ids[i]);
item.weight = sortedids[i];
}
return weights;
};
// local
var weights = sortLocal(ids);
clog("sort", ids, weights);
// remote
if (ids[0] > 0)
jasmineAjax(".?api=app::client_item_sort", {values: {weights: weights}, onload: r=> {
clog("sort", r);
}});
}
// jasmineBroom
function jasmineBroom(item)
{
}
// jasmineAddFiles
function jasmineAddFiles(item, onload)
{
var addNext = (files, index = 0) => {
if (files[index])
jasmineAddFile(item, files[index], () => {
onload && onload();
addNext(files, index + 1);
});
};
jasmineHelperPickFiles((files) => addNext(files, 0));
}
// jasmineAddFile
function jasmineAddFile(item, file, onload)
{
jasmineBroomItemCache(0, 0, item);
var newitem = jasmineAddItem({kind: "image", folderid: item.id}, 0, false);
jasmineSetFile(newitem, file, onload);
}
// jasmine_item_setfile
function jasmineSetFile(item, file, onload)
{
if (item.id < 0) {
/*
jasmineHelperResizeImage(file, {scale: 80 * 80}, (imgdata) => {
item._file = file;
item._preview = imgdata;
onload && onload();
});
*/
item._file = file;
item._preview = window.URL.createObjectURL(file);
onload && onload();
}
}
// jasmineBroomItemCache
function jasmineBroomItemCache(id, removedid = 0, broomitem = null)
{
if (removedid) {
var item = jasmineGetItem(removedid);
if (item) id = item.folderid;
}
if (id) {
var item = jasmineGetItem(id);
for (var i in item) {
if (strbegins(i, "_cache")) {
delete(item[i]);
}
}
}
if (broomitem)
delete(broomitem._cacheFiles);
}
// jasmineGetFiles
function jasmineGetFiles(item)
{
if (!item._cacheFiles || 1) {
var images = store.items.filter(i => i.folderid == item.id && i.kind == "image");
images.sort(function(a, b) { return a.weight - b.weight });
item._cacheFiles = images;
}
return item._cacheFiles;
}
// jasmineHasFiles
function jasmineHasFiles(item)
{
return jasmineGetFiles(item).length;
}
// jasmineTopFile
function jasmineTopFile(item)
{
return jasmineGetFiles(item)[0];
}
// jasmineItemPreview
function jasmineItemPreview(item)
{
if (item && item._preview) return item._preview;
if (item && item.url) return item.url;
if (item && item.image) return ("./upl/0/" + item.id + "-1.jpg?" + item.image);
return "";
}
// jasmineItemPicture
function jasmineItemPicture(item)
{
if (item && item._preview) return item._preview;
if (item && item.url) return item.url;
if (item && item.image) return ("./upl/0/" + item.id + "-0.jpg?" + item.image);
return "";
}
// jasmineHelperPickFiles
function jasmineHelperPickFiles(onfile, multiple = "multiple")
{
var fileInput = document.body.appendChild(document.createRange().createContextualFragment(
`
`).firstElementChild);
setTimeout(() => { if (fileInput.parentNode) fileInput.remove() }, 10);
fileInput.onchange = () => { onfile(fileInput.files) }
fileInput.click();
}
// jasmineHelperResizeImage
function jasmineHelperResizeImage(imgfile, config = {scale: 320 * 200, blur: 0}, onload = 0)
{
var reader = new FileReader();
reader.readAsDataURL(imgfile);
reader.onload = function() {
var image = new Image();
image.src = reader.result;
image.onload = function() {
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
var sourcesquare = image.width * image.height;
var scale = Math.sqrt(Math.min(1, config.scale / sourcesquare));
canvas.width = image.width * scale;
canvas.height = image.height * scale;
if (config.blur) { context.filter = `blur(${config.blur}px)`; }
context.drawImage(image, 0, 0, canvas.width, canvas.height);
var resizedImage = canvas.toDataURL('image/jpeg');
if (onload) onload(resizedImage);
}
}
}
// jasmine_cleantmp
function jasminePrivateCleanTmp()
{
var items = store.items.filter(i => i.id < 0);
xwalk(items, i => jasmineRemoveItem(i));
}
// jasminePrivateCleanFields
function jasminePrivateCleanFields(item)
{
var result = {};
for (var i in item) {
if (i[0] != "_") result[i] = item[i]; }
return result;
}
// jasminePrivateReplaceId
function jasminePrivateReplaceId(oldid, newid)
{
var inneritems = store.items.filter(i => i.folderid == oldid);
xwalk(inneritems, i => i.folderid = newid);
}
// jasmineSaveAll
function jasmineSaveAll(onloaditem, onloadall)
{
var check_again = function() {
var exist = store.items.find(i => i.id < 0 && !(i.folderid < 0));
return exist && true;
}
var save_one = function(items, index) {
var item = items[index];
if (item) {
jasmine.saveingSatus = `${index + 1}/${items.length}`;
jasmineSaveItem(item, () => { onloaditem && onloaditem(); save_one(items, index + 1); });
} else {
// finish
if (check_again()) {
return jasmineSaveAll(onloaditem, onloadall);
} else {
delete(jasmine.saveingSatus);
onloadall && onloadall();
return jasmineHideLoader();
}
}
}
var items = store.items.filter(i => i.id < 0 && !(i.folderid < 0));
save_one(items, 0);
}
// jasmineShowLoader
function jasmineShowLoader()
{
var loader = document.body.appendChild(jasmineBuildElement(`
`));
window.onuploadprogress = (ev) => {
var percent = Math.round(ev.loaded / ev.total * 100);
var size = Math.round(ev.total/1000);
loader.innerHTML = `
${jasmine.saveingSatus||''} ${percent}% ${size} Kb`;
}
}
// jasmineHideLoader
function jasmineHideLoader()
{
var loader = document.body.querySelector(".jasmine-loader");
if (loader) { loader.remove(); window.onuploadprogress = null; }
}
// jasmineNewId
function jasmineNewId()
{
return jasmine.autoincrement--;
}
// jasmineAjax
function jasmineAjax(url, config)
{
var xhttp = new XMLHttpRequest();
var formData = new FormData(config.form);
var pack = (value) => {
return typeof(value) == "object"
? JSON.stringify(value, null, "\t") : value; }
if (config.file) {
formData.append("file", config.file);
}
if (config.values) for (var key in config.values) {
formData.append(key, pack(config.values[key]));
}
if (config.config) for (var key in config.config) {
formData.append(key, pack(config.config[key]));
}
if (config.file) {
xhttp.upload.onprogress = function(ev) {
if (window.onuploadprogress) window.onuploadprogress(ev);
}
}
xhttp.onreadystatechange = function() {
if (this.readyState != 4) return;
if (config.onload)
return config.onload(this.responseText, this.status);
//
if (config.onjson) {
var json; try { json = JSON.parse(this.responseText) } catch (ex) {
return alert(this.responseText + "(" + url + ")");
}
config.onjson(json);
}
}
xhttp.open("post", url, true); xhttp.send(formData);
}
// utils
function jasmineBuildElement(html) {
return document.createRange().createContextualFragment(html).firstElementChild;
}
// globstate
var jasmine = {autoincrement: -1};
// clog utils
//-----------------
clog = console.log;
window.onsubmit = function(ev) { ev.preventDefault(); }
function mtime() { return Date.now(); }
function xwalk(array, callback) { Array.prototype.forEach.call(array, callback); }
Object.defineProperty(HTMLElement.prototype, "html", {
get() { return this.innerHTML; },
set(value) { return this.innerHTML = value; },
});
function strbegins(bigstr, smallstr) { return bigstr.indexOf(smallstr) == 0; }